Skip to content

Commit 4457e09

Browse files
committed
fix: flaky test by delaying connections
1 parent 60f97dc commit 4457e09

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

topology_test.go

+7
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,13 @@ func (t *Topology) Connect(ctx context.Context, a *DHT, b *DHT) {
142142
err := a.AddAddresses(ctx, []peer.AddrInfo{bAddr}, time.Hour)
143143
require.NoError(t.tb, err)
144144

145+
// If two peers simultaneously connect they could end up in a state where
146+
// one peer is waiting on the connection for the other one although there
147+
// already exists a valid connection. This sleep below makes sure that we
148+
// don't trigger a "simultaneous" connect. Remove this call to Sleep when
149+
// https://github.com/libp2p/go-libp2p/issues/2589 is resolved.
150+
time.Sleep(10 * time.Millisecond)
151+
145152
// Add a's addresses to b
146153
err = b.AddAddresses(ctx, []peer.AddrInfo{aAddr}, time.Hour)
147154
require.NoError(t.tb, err)

0 commit comments

Comments
 (0)