From 2c36d31678cf9fe321e80159e6d0e1954658576c Mon Sep 17 00:00:00 2001 From: Sukun Date: Thu, 26 Oct 2023 15:34:05 +0530 Subject: [PATCH] webrtc: fix race in TestRemoveConnByUfrag (#2620) --- p2p/transport/webrtc/udpmux/mux_test.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/p2p/transport/webrtc/udpmux/mux_test.go b/p2p/transport/webrtc/udpmux/mux_test.go index c05fc3112..89c12de1a 100644 --- a/p2p/transport/webrtc/udpmux/mux_test.go +++ b/p2p/transport/webrtc/udpmux/mux_test.go @@ -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 @@ -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) {