MCPcopy
hub / github.com/pion/webrtc / TestEnableDataChannelBlockWrite

Function TestEnableDataChannelBlockWrite

settingengine_test.go:552–592  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

550}
551
552func TestEnableDataChannelBlockWrite(t *testing.T) {
553 lim := test.TimeOut(time.Second * 30)
554 defer lim.Stop()
555
556 report := test.CheckRoutines(t)
557 defer report()
558
559 s := SettingEngine{}
560 s.DetachDataChannels()
561 s.EnableDataChannelBlockWrite(true)
562 s.SetSCTPMaxReceiveBufferSize(1500)
563
564 offer, answer, err := NewAPI(WithSettingEngine(s)).newPair(Configuration{})
565 assert.NoError(t, err)
566
567 dc, err := offer.CreateDataChannel("data", nil)
568 assert.NoError(t, err)
569 detachChan := make(chan datachannel.ReadWriteCloserDeadliner, 1)
570 dc.OnOpen(func() {
571 detached, err1 := dc.DetachWithDeadline()
572 assert.NoError(t, err1)
573 detachChan <- detached
574 })
575
576 assert.NoError(t, signalPair(offer, answer))
577 untilConnectionState(PeerConnectionStateConnected, offer, answer).Wait()
578
579 // write should block and return deadline exceeded since the receiver is not reading
580 // and the buffer size is 1500 bytes
581 rawDC := <-detachChan
582 assert.NoError(t, rawDC.SetWriteDeadline(time.Now().Add(time.Second)))
583 buf := make([]byte, 1000)
584 for range 10 {
585 _, err = rawDC.Write(buf)
586 if err != nil {
587 break
588 }
589 }
590 assert.ErrorIs(t, err, context.DeadlineExceeded)
591 closePairNow(t, offer, answer)
592}
593
594func TestSettingEngine_getReceiveMTU_Custom(t *testing.T) {
595 var se SettingEngine

Callers

nothing calls this directly

Calls 15

DetachDataChannelsMethod · 0.95
signalPairFunction · 0.85
untilConnectionStateFunction · 0.85
closePairNowFunction · 0.85
newPairMethod · 0.80
DetachWithDeadlineMethod · 0.80
NewAPIFunction · 0.70
WithSettingEngineFunction · 0.70
WriteMethod · 0.65
StopMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…