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

fix flaky autorelay tests #1438

Closed
wants to merge 1 commit into from
Closed
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
12 changes: 12 additions & 0 deletions p2p/host/autorelay/autorelay_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package autorelay_test

import (
"context"
"strings"
"sync/atomic"
"testing"
Expand Down Expand Up @@ -61,6 +62,17 @@ func newRelay(t *testing.T) host.Host {
}),
)
require.NoError(t, err)

// The relay service is started asynchronously (triggered by the reachability event).
// Make sure that the relay is up and running before returning.
h1, err := libp2p.New()
require.NoError(t, err)
defer h1.Close()
require.NoError(t, h1.Connect(context.Background(), peer.AddrInfo{ID: h.ID(), Addrs: h.Addrs()}))
require.Eventually(t, func() bool {
protos, _ := h1.Peerstore().SupportsProtocols(h.ID(), circuitv2_proto.ProtoIDv2Hop)
return len(protos) > 0
}, 500*time.Millisecond, time.Millisecond)
return h
}

Expand Down