Commit 7c8922bf authored by Matt Joiner's avatar Matt Joiner
Browse files

Rename traversal.finished->waitFinished

parent 908761b8
......@@ -115,7 +115,7 @@ func (a *Announce) closer() {
return
}
tx.Assert(tx.Get(a.pending).(int) == 0)
a.traversal.finished(tx)
a.traversal.waitFinished(tx)
tx.Assert(tx.Get(a.pendingAnnouncePeers).(stmutil.Lenner).Len() == 0)
}))
}
......
......@@ -36,7 +36,7 @@ func newTraversal(targetInfohash int160) traversal {
}
}
func (t traversal) finished(tx *stm.Tx) {
func (t traversal) waitFinished(tx *stm.Tx) {
tx.Assert(tx.Get(t.nodesPendingContact).(stmutil.Lenner).Len() == 0)
}
......
......@@ -13,7 +13,7 @@ func TestTraversal(t *testing.T) {
var target int160
traversal := newTraversal(target)
assert.True(t, stm.WouldBlock(stm.VoidOperation(func(tx *stm.Tx) { traversal.nextAddr(tx) })))
assert.False(t, stm.WouldBlock(stm.VoidOperation(traversal.finished)))
assert.False(t, stm.WouldBlock(stm.VoidOperation(traversal.waitFinished)))
stm.Atomically(stm.Compose(func() (ret []stm.Operation) {
for _, v := range sampleAddrMaybeIds[2:6] {
ret = append(ret, traversal.pendContact(v))
......@@ -21,13 +21,13 @@ func TestTraversal(t *testing.T) {
return
}()...))
assert.False(t, stm.WouldBlock(stm.VoidOperation(func(tx *stm.Tx) { traversal.nextAddr(tx) })))
assert.True(t, stm.WouldBlock(stm.VoidOperation(traversal.finished)))
assert.True(t, stm.WouldBlock(stm.VoidOperation(traversal.waitFinished)))
pop := func(tx *stm.Tx) interface{} { return traversal.nextAddr(tx) }
var addrs []krpc.NodeAddr
for !stm.WouldBlock(pop) {
addrs = append(addrs, stm.Atomically(pop).(krpc.NodeAddr))
}
assert.False(t, stm.WouldBlock(stm.VoidOperation(traversal.finished)))
assert.False(t, stm.WouldBlock(stm.VoidOperation(traversal.waitFinished)))
t.Log(addrs)
assert.EqualValues(t, []krpc.NodeAddr{{Port: 1}, {}}, addrs)
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment