Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reduce flakiness of AutoRelay TestBackoff test #1400

Merged
merged 1 commit into from
Apr 16, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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