6 "github.com/anacrolix/log"
7 qt "github.com/frankban/quicktest"
8 "github.com/pion/webrtc/v3"
11 func TestClosingPeerConnectionDoesNotCloseUnopenedDataChannel(t *testing.T) {
14 pc, dc, _, err := tc.newOffer(log.Default, "", [20]byte{})
15 c.Assert(err, qt.IsNil)
18 peerConnClosed := make(chan struct{})
19 pc.OnConnectionStateChange(func(state webrtc.PeerConnectionState) {
20 if state == webrtc.PeerConnectionStateClosed {
25 // This should not be called because the DataChannel is never opened.
26 t.Fatal("DataChannel.OnClose handler called")
28 t.Logf("data channel ready state before close: %v", dc.ReadyState())
29 dc.OnError(func(err error) {
30 t.Logf("data channel error: %v", err)
33 c.Check(dc.ReadyState(), qt.Equals, webrtc.DataChannelStateClosed)