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: only dial a single transport in TestDialWorkerLoopBasic #1526

Merged
merged 1 commit into from
May 25, 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
9 changes: 5 additions & 4 deletions p2p/net/swarm/dial_worker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ func TestDialWorkerLoopBasic(t *testing.T) {
defer s1.Close()
defer s2.Close()

s1.Peerstore().AddAddrs(s2.LocalPeer(), s2.ListenAddresses(), peerstore.PermanentAddrTTL)
// Only pass in a single address here, otherwise we might end up with a TCP and QUIC connection dialed.
s1.Peerstore().AddAddrs(s2.LocalPeer(), []ma.Multiaddr{s2.ListenAddresses()[0]}, peerstore.PermanentAddrTTL)

reqch := make(chan dialRequest)
resch := make(chan dialResponse)
Expand All @@ -97,7 +98,7 @@ func TestDialWorkerLoopBasic(t *testing.T) {
case res := <-resch:
require.NoError(t, res.err)
conn = res.conn
case <-time.After(time.Minute):
case <-time.After(10 * time.Second):
t.Fatal("dial didn't complete")
}

Expand All @@ -111,13 +112,13 @@ func TestDialWorkerLoopBasic(t *testing.T) {
case res := <-resch:
require.NoError(t, res.err)
conn2 = res.conn
case <-time.After(time.Minute):
case <-time.After(10 * time.Second):
t.Fatal("dial didn't complete")
}

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

close(reqch)
Expand Down