diff --git a/mempool/reactor_test.go b/mempool/reactor_test.go index a2f0f272e..45458a983 100644 --- a/mempool/reactor_test.go +++ b/mempool/reactor_test.go @@ -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)) diff --git a/p2p/switch_test.go b/p2p/switch_test.go index d7443e94d..b06e05868 100644 --- a/p2p/switch_test.go +++ b/p2p/switch_test.go @@ -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()) }