Skip to content

Commit 4128a82

Browse files
San9H0Sean-Der
authored andcommitted
Fix flakey test TestInterceptorNack
Wait for PeerConnection to reach 'connected' in NACK test. Otherwise test will fail.
1 parent 334692b commit 4128a82

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

interceptor_test.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,13 @@ func testInterceptorNack(t *testing.T, requestNack bool) { //nolint:cyclop
334334
pc1, err := api.NewPeerConnection(Configuration{})
335335
assert.NoError(t, err)
336336

337+
pc1Connected := make(chan struct{})
338+
pc1.OnConnectionStateChange(func(state PeerConnectionState) {
339+
if state == PeerConnectionStateConnected {
340+
close(pc1Connected)
341+
}
342+
})
343+
337344
track1, err := NewTrackLocalStaticRTP(
338345
RTPCodecCapability{MimeType: MimeTypeVP8},
339346
"video", "pion",
@@ -362,6 +369,8 @@ func testInterceptorNack(t *testing.T, requestNack bool) { //nolint:cyclop
362369
err = pc1.SetRemoteDescription(*pc2.LocalDescription())
363370
assert.NoError(t, err)
364371

372+
<-pc1Connected
373+
365374
var gotNack bool
366375
rtcpDone := make(chan struct{})
367376
go func() {
@@ -416,7 +425,7 @@ func testInterceptorNack(t *testing.T, requestNack bool) { //nolint:cyclop
416425
p.Marker = true
417426
p.PayloadType = 96
418427
p.SequenceNumber = uint16(i) //nolint:gosec // G115
419-
p.Timestamp = uint32(i * 90000 / 50) ///nolint:gosec // G115
428+
p.Timestamp = uint32(i * 90000 / 50) //nolint:gosec // G115
420429
p.Payload = []byte{42}
421430
err2 := track1.WriteRTP(&p)
422431
assert.NoError(t, err2)

0 commit comments

Comments
 (0)