some more robust sleeps

This commit is contained in:
Ethan Buchman
2017-11-14 22:31:23 +00:00
parent 844c43e044
commit e69d36d54f
2 changed files with 10 additions and 4 deletions

View File

@@ -81,7 +81,7 @@ func _waitForTxs(t *testing.T, wg *sync.WaitGroup, txs types.Txs, reactorIdx int
mempool := reactors[reactorIdx].Mempool
for mempool.Size() != len(txs) {
time.Sleep(time.Second)
time.Sleep(time.Millisecond * 100)
}
reapedTxs := mempool.Reap(len(txs))

View File

@@ -262,9 +262,15 @@ func TestSwitchReconnectsToPersistentPeer(t *testing.T) {
peer.CloseConn()
// TODO: actually detect the disconnection and wait for reconnect
time.Sleep(100 * time.Millisecond)
assert.NotZero(sw.Peers().Size())
npeers := sw.Peers().Size()
for i := 0; i < 20; i++ {
time.Sleep(100 * time.Millisecond)
npeers = sw.Peers().Size()
if npeers > 0 {
break
}
}
assert.NotZero(npeers)
assert.False(peer.IsRunning())
}