Skip to content

Commit

Permalink
reduce flakiness of AutoRelay TestBackoff test (#1400)
Browse files Browse the repository at this point in the history
  • Loading branch information
marten-seemann authored Apr 16, 2022
1 parent 0e72b48 commit bc02323
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions p2p/host/autorelay/autorelay_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,12 +202,13 @@ func TestWaitForCandidates(t *testing.T) {
}

func TestBackoff(t *testing.T) {
const backoff = 500 * time.Millisecond
peerChan := make(chan peer.AddrInfo)
h := newPrivateNode(t,
autorelay.WithPeerSource(peerChan),
autorelay.WithNumRelays(1),
autorelay.WithBootDelay(0),
autorelay.WithBackoff(500*time.Millisecond),
autorelay.WithBackoff(backoff),
)
defer h.Close()

Expand All @@ -218,11 +219,11 @@ func TestBackoff(t *testing.T) {
// make sure we don't add any relays yet
require.Never(t, func() bool {
return len(ma.FilterAddrs(h.Addrs(), isRelayAddr)) > 0
}, 400*time.Millisecond, 50*time.Millisecond)
}, backoff*2/3, 50*time.Millisecond)

require.Eventually(t, func() bool {
return len(ma.FilterAddrs(h.Addrs(), isRelayAddr)) > 0
}, 400*time.Millisecond, 50*time.Millisecond)
}, 2*backoff, 50*time.Millisecond)
}

func TestMaxBackoffs(t *testing.T) {
Expand Down

0 comments on commit bc02323

Please sign in to comment.