Fix flakey test TestInterceptorNack

Wait for PeerConnection to reach 'connected' in NACK test. Otherwise
test will fail.
This commit is contained in:
SangHo
2025-04-07 19:14:11 +09:00
committed by Sean DuBois
parent 334692b122
commit 4128a820c8

View File

@@ -334,6 +334,13 @@ func testInterceptorNack(t *testing.T, requestNack bool) { //nolint:cyclop
pc1, err := api.NewPeerConnection(Configuration{})
assert.NoError(t, err)
pc1Connected := make(chan struct{})
pc1.OnConnectionStateChange(func(state PeerConnectionState) {
if state == PeerConnectionStateConnected {
close(pc1Connected)
}
})
track1, err := NewTrackLocalStaticRTP(
RTPCodecCapability{MimeType: MimeTypeVP8},
"video", "pion",
@@ -362,6 +369,8 @@ func testInterceptorNack(t *testing.T, requestNack bool) { //nolint:cyclop
err = pc1.SetRemoteDescription(*pc2.LocalDescription())
assert.NoError(t, err)
<-pc1Connected
var gotNack bool
rtcpDone := make(chan struct{})
go func() {
@@ -416,7 +425,7 @@ func testInterceptorNack(t *testing.T, requestNack bool) { //nolint:cyclop
p.Marker = true
p.PayloadType = 96
p.SequenceNumber = uint16(i) //nolint:gosec // G115
p.Timestamp = uint32(i * 90000 / 50) ///nolint:gosec // G115
p.Timestamp = uint32(i * 90000 / 50) //nolint:gosec // G115
p.Payload = []byte{42}
err2 := track1.WriteRTP(&p)
assert.NoError(t, err2)