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

swarm: fix flaky TestDialExistingConnection test #1509

Merged
merged 1 commit into from
May 19, 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: 5 additions & 2 deletions p2p/net/swarm/dial_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,10 @@ func TestDialExistingConnection(t *testing.T) {
s1 := swarms[0]
s2 := swarms[1]

s1.Peerstore().AddAddrs(s2.LocalPeer(), s2.ListenAddresses(), peerstore.PermanentAddrTTL)
// Only use one of the addresses here.
// Otherwise, we might dial TCP and QUIC simultaneously here, and end up with two connections,
// if the handshake latencies line up exactly.
s1.Peerstore().AddAddrs(s2.LocalPeer(), s2.ListenAddresses()[:1], peerstore.PermanentAddrTTL)

c1, err := s1.DialPeer(context.Background(), s2.LocalPeer())
require.NoError(t, err)
Expand All @@ -489,7 +492,7 @@ func TestDialExistingConnection(t *testing.T) {

// can't use require.Equal here, as this does a deep comparison
if c1 != c2 {
t.Fatal("expecting the same connection from both dials")
t.Fatalf("expecting the same connection from both dials, got %s <-> %s vs %s <-> %s", c1.LocalMultiaddr(), c1.RemoteMultiaddr(), c2.LocalMultiaddr(), c2.RemoteMultiaddr())
}
}

Expand Down