mirror of
https://github.com/pion/webrtc.git
synced 2025-10-05 23:26:58 +08:00
Fix flakey test TestInterceptorNack
Wait for PeerConnection to reach 'connected' in NACK test. Otherwise test will fail.
This commit is contained in:
@@ -334,6 +334,13 @@ func testInterceptorNack(t *testing.T, requestNack bool) { //nolint:cyclop
|
|||||||
pc1, err := api.NewPeerConnection(Configuration{})
|
pc1, err := api.NewPeerConnection(Configuration{})
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
||||||
|
pc1Connected := make(chan struct{})
|
||||||
|
pc1.OnConnectionStateChange(func(state PeerConnectionState) {
|
||||||
|
if state == PeerConnectionStateConnected {
|
||||||
|
close(pc1Connected)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
track1, err := NewTrackLocalStaticRTP(
|
track1, err := NewTrackLocalStaticRTP(
|
||||||
RTPCodecCapability{MimeType: MimeTypeVP8},
|
RTPCodecCapability{MimeType: MimeTypeVP8},
|
||||||
"video", "pion",
|
"video", "pion",
|
||||||
@@ -362,6 +369,8 @@ func testInterceptorNack(t *testing.T, requestNack bool) { //nolint:cyclop
|
|||||||
err = pc1.SetRemoteDescription(*pc2.LocalDescription())
|
err = pc1.SetRemoteDescription(*pc2.LocalDescription())
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
||||||
|
<-pc1Connected
|
||||||
|
|
||||||
var gotNack bool
|
var gotNack bool
|
||||||
rtcpDone := make(chan struct{})
|
rtcpDone := make(chan struct{})
|
||||||
go func() {
|
go func() {
|
||||||
@@ -416,7 +425,7 @@ func testInterceptorNack(t *testing.T, requestNack bool) { //nolint:cyclop
|
|||||||
p.Marker = true
|
p.Marker = true
|
||||||
p.PayloadType = 96
|
p.PayloadType = 96
|
||||||
p.SequenceNumber = uint16(i) //nolint:gosec // G115
|
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}
|
p.Payload = []byte{42}
|
||||||
err2 := track1.WriteRTP(&p)
|
err2 := track1.WriteRTP(&p)
|
||||||
assert.NoError(t, err2)
|
assert.NoError(t, err2)
|
||||||
|
Reference in New Issue
Block a user