Skip to content

Commit

Permalink
test: Try to fix test timeout (#2930)
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoPolo authored and sukunrt committed Aug 30, 2024
1 parent 3912e93 commit 701d7c3
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions p2p/transport/webrtc/transport_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1014,13 +1014,16 @@ func TestConnectionClosedWhenRemoteCloses(t *testing.T) {
listenT, p := getTransport(t)
listener, err := listenT.Listen(ma.StringCast("/ip4/127.0.0.1/udp/0/webrtc-direct"))
require.NoError(t, err)
defer listener.Close()

accepted := make(chan struct{})
dialer, _ := getTransport(t)
var wg sync.WaitGroup
wg.Add(1)
go func() {
defer wg.Done()
c, err := listener.Accept()
close(accepted)
if !assert.NoError(t, err) {
return
}
Expand All @@ -1031,6 +1034,7 @@ func TestConnectionClosedWhenRemoteCloses(t *testing.T) {

c, err := dialer.Dial(context.Background(), listener.Multiaddr(), p)
require.NoError(t, err)
<-accepted
c.Close()
wg.Wait()
}

0 comments on commit 701d7c3

Please sign in to comment.