Skip to content

Commit

Permalink
swarm: only dial a single transport in TestDialWorkerLoopBasic (#1526)
Browse files Browse the repository at this point in the history
  • Loading branch information
marten-seemann authored May 25, 2022
1 parent 6c56eea commit f3195e9
Showing 1 changed file with 5 additions and 4 deletions.
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

0 comments on commit f3195e9

Please sign in to comment.