@@ -83,6 +83,24 @@ func offerMediaHasDirection(offer SessionDescription, kind RTPCodecType, directi
8383 return false
8484}
8585
86+ func untilConnectionState (state PeerConnectionState , peers ... * PeerConnection ) * sync.WaitGroup {
87+ var triggered sync.WaitGroup
88+ triggered .Add (len (peers ))
89+
90+ for _ , p := range peers {
91+ done := false
92+ hdlr := func (p PeerConnectionState ) {
93+ if ! done && p == state {
94+ done = true
95+ triggered .Done ()
96+ }
97+ }
98+
99+ p .OnConnectionStateChange (hdlr )
100+ }
101+ return & triggered
102+ }
103+
86104func TestNew (t * testing.T ) {
87105 pc , err := NewPeerConnection (Configuration {
88106 ICEServers : []ICEServer {
@@ -716,3 +734,17 @@ func TestAddTransceiver(t *testing.T) {
716734 assert .NoError (t , pc .Close ())
717735 }
718736}
737+
738+ // Assert that SCTPTransport -> DTLSTransport -> ICETransport works after connected
739+ func TestTransportChain (t * testing.T ) {
740+ offer , answer , err := newPair ()
741+ assert .NoError (t , err )
742+
743+ peerConnectionsConnected := untilConnectionState (PeerConnectionStateConnected , offer , answer )
744+ assert .NoError (t , signalPair (offer , answer ))
745+ peerConnectionsConnected .Wait ()
746+
747+ assert .NotNil (t , offer .SCTP ().Transport ().ICETransport ())
748+
749+ closePairNow (t , offer , answer )
750+ }
0 commit comments