Skip to content

Commit

Permalink
webrtc: fix race in TestRemoveConnByUfrag (#2620)
Browse files Browse the repository at this point in the history
  • Loading branch information
sukunrt authored Oct 26, 2023
1 parent 81d5c0c commit 2c36d31
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions p2p/transport/webrtc/udpmux/mux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,9 @@ func TestRemoveConnByUfrag(t *testing.T) {
for i := 0; i < 10; i++ {
mc1, err := m.GetConn(ufrag, conns[i].LocalAddr())
require.NoError(t, err)
require.Equal(t, mc1, mc)
if mc1 != mc {
t.Fatalf("expected the two muxed connections to be same")
}
}

// Now remove the ufrag
Expand All @@ -167,13 +169,17 @@ func TestRemoveConnByUfrag(t *testing.T) {
for i := 0; i < 10; i++ {
mc1, err := m.GetConn(ufrag, conns[i].LocalAddr())
require.NoError(t, err)
require.Equal(t, mc1, mc)
if mc1 != mc {
t.Fatalf("expected the two muxed connections to be same")
}
}

// Should be different even if the address is the same
mc1, err := m.GetConn("a", conns[0].LocalAddr())
require.NoError(t, err)
require.NotEqual(t, mc1, mc)
if mc1 == mc {
t.Fatalf("expected the two connections to be different")
}
}

func TestMuxedConnection(t *testing.T) {
Expand Down

0 comments on commit 2c36d31

Please sign in to comment.