Skip to content

Commit

Permalink
fix flaky BackoffConnector test (#1353)
Browse files Browse the repository at this point in the history
  • Loading branch information
marten-seemann authored Mar 10, 2022
1 parent f0db9cc commit 13d0381
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions p2p/discovery/backoff/backoffconnector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,12 @@ func TestBackoffConnector(t *testing.T) {
require.Eventually(t, func() bool { return len(primary.Network().Peers()) == 0 }, 3*time.Second, 10*time.Millisecond)

bc.Connect(context.Background(), loadCh(hosts))
require.Empty(t, primary.Network().Conns(), "shouldn't be connected to any peers")
require.Empty(t, primary.Network().Peers(), "shouldn't be connected to any peers")

time.Sleep(time.Millisecond * 500)
bc.Connect(context.Background(), loadCh(hosts))
require.Eventually(t, func() bool { return len(primary.Network().Peers()) == len(hosts)-2 }, 3*time.Second, 10*time.Millisecond)
// make sure we actually don't connect to host 1 any more
time.Sleep(100 * time.Millisecond)
require.Len(t, primary.Network().Conns(), len(hosts)-2, "wrong number of connections")
require.Len(t, primary.Network().Peers(), len(hosts)-2, "wrong number of connections")
}

0 comments on commit 13d0381

Please sign in to comment.