Skip to content

Commit

Permalink
add log for debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
sukunrt committed Dec 5, 2024
1 parent 35c4bdb commit 723e429
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 17 deletions.
2 changes: 2 additions & 0 deletions p2p/net/swarm/dial_worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package swarm

import (
"context"
"fmt"
"math"
"sync"
"time"
Expand Down Expand Up @@ -295,6 +296,7 @@ loop:
}
ad.dialed = true
ad.dialRankingDelay = now.Sub(ad.createdAt)
fmt.Printf("dialling %s after %s\n", ad.addr, ad.dialRankingDelay)
err := w.s.dialNextAddr(ad.ctx, w.peer, ad.addr, w.resch)
if err != nil {
// Errored without attempting a dial. This happens in case of
Expand Down
24 changes: 7 additions & 17 deletions p2p/test/basichost/basic_host_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"fmt"
"strings"
"sync"
"testing"
"time"

Expand Down Expand Up @@ -252,24 +251,15 @@ func TestWebRTCWithQUICManyConnections(t *testing.T) {
require.NoError(t, err)
defer d.Close()

startDial := make(chan struct{})
var wg sync.WaitGroup
wg.Add(N)
for i := 0; i < N; i++ {
go func() {
defer wg.Done()
<-startDial
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
// With happy eyeballs these dialers will connect over only /quic-v1
// and not stall the /webrtc-direct handshake goroutines.
// it is fine if the dial fails, we just want to ensure that there's space
// in the /webrtc-direct listen queue
_ = dialers[i].Connect(ctx, peer.AddrInfo{ID: h.ID(), Addrs: h.Addrs()})
}()
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
// With happy eyeballs these dialers will connect over only /quic-v1
// and not stall the /webrtc-direct handshake goroutines.
// it is fine if the dial fails, we just want to ensure that there's space
// in the /webrtc-direct listen queue
_ = dialers[i].Connect(ctx, peer.AddrInfo{ID: h.ID(), Addrs: h.Addrs()})
}
close(startDial)
wg.Wait()

ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
Expand Down

0 comments on commit 723e429

Please sign in to comment.