snapshot of https://github.com/pion/webrtc.git (main, 2026-09-15; blobs > 131072B omitted)
Some checks failed
REUSE Compliance Check / lint (push) Failing after 0s
Browser E2E / Test (push) Failing after 3s
Test / test (1.24) (push) Failing after 0s
Test / test-i386 (1.25) (push) Failing after 0s
Test / test-i386 (1.24) (push) Failing after 0s
Test / test-windows (1.25) (push) Failing after 0s
Test / test-windows (1.24) (push) Failing after 0s
Test / test (1.25) (push) Failing after 0s
Examples Tests / Test (push) Failing after 3s
Test / test-macos (1.25) (push) Failing after 0s
Test / test-macos (1.24) (push) Failing after 0s
Go mod tidy / tidy (push) Failing after 0s
Test / test-wasm (push) Failing after 0s
CodeQL / analyze (push) Failing after 1s
Fuzz / fuzz (push) Failing after 0s
Some checks failed
REUSE Compliance Check / lint (push) Failing after 0s
Browser E2E / Test (push) Failing after 3s
Test / test (1.24) (push) Failing after 0s
Test / test-i386 (1.25) (push) Failing after 0s
Test / test-i386 (1.24) (push) Failing after 0s
Test / test-windows (1.25) (push) Failing after 0s
Test / test-windows (1.24) (push) Failing after 0s
Test / test (1.25) (push) Failing after 0s
Examples Tests / Test (push) Failing after 3s
Test / test-macos (1.25) (push) Failing after 0s
Test / test-macos (1.24) (push) Failing after 0s
Go mod tidy / tidy (push) Failing after 0s
Test / test-wasm (push) Failing after 0s
CodeQL / analyze (push) Failing after 1s
Fuzz / fuzz (push) Failing after 0s
This commit is contained in:
97
ortc_datachannel_test.go
Normal file
97
ortc_datachannel_test.go
Normal file
@@ -0,0 +1,97 @@
|
||||
// SPDX-FileCopyrightText: 2026 The Pion community <https://pion.ly>
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
//go:build !js
|
||||
|
||||
package webrtc
|
||||
|
||||
import (
|
||||
"io"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/pion/transport/v4/test"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestDataChannel_ORTC_SCTPTransport(t *testing.T) {
|
||||
lim := test.TimeOut(time.Second * 20)
|
||||
defer lim.Stop()
|
||||
|
||||
report := test.CheckRoutines(t)
|
||||
defer report()
|
||||
|
||||
stackA, stackB, err := newORTCPair()
|
||||
assert.NoError(t, err)
|
||||
|
||||
getSelectedCandidatePairErrChan := make(chan error)
|
||||
stackB.sctp.OnDataChannel(func(d *DataChannel) {
|
||||
_, getSelectedCandidatePairErr := d.Transport().Transport().ICETransport().GetSelectedCandidatePair()
|
||||
getSelectedCandidatePairErrChan <- getSelectedCandidatePairErr
|
||||
})
|
||||
|
||||
assert.NoError(t, signalORTCPair(stackA, stackB))
|
||||
|
||||
var id uint16 = 1
|
||||
_, err = stackA.api.NewDataChannel(stackA.sctp, &DataChannelParameters{
|
||||
Label: "Foo",
|
||||
ID: &id,
|
||||
})
|
||||
assert.NoError(t, err)
|
||||
|
||||
assert.NoError(t, <-getSelectedCandidatePairErrChan)
|
||||
assert.NoError(t, stackA.close())
|
||||
assert.NoError(t, stackB.close())
|
||||
}
|
||||
|
||||
func TestDataChannel_ORTCE2E(t *testing.T) {
|
||||
lim := test.TimeOut(time.Second * 20)
|
||||
defer lim.Stop()
|
||||
|
||||
report := test.CheckRoutines(t)
|
||||
defer report()
|
||||
|
||||
stackA, stackB, err := newORTCPair()
|
||||
assert.NoError(t, err)
|
||||
|
||||
awaitSetup := make(chan struct{})
|
||||
awaitString := make(chan struct{})
|
||||
awaitBinary := make(chan struct{})
|
||||
stackB.sctp.OnDataChannel(func(d *DataChannel) {
|
||||
close(awaitSetup)
|
||||
|
||||
d.OnMessage(func(msg DataChannelMessage) {
|
||||
if msg.IsString {
|
||||
close(awaitString)
|
||||
} else {
|
||||
close(awaitBinary)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
assert.NoError(t, signalORTCPair(stackA, stackB))
|
||||
|
||||
var id uint16 = 1
|
||||
dcParams := &DataChannelParameters{
|
||||
Label: "Foo",
|
||||
ID: &id,
|
||||
}
|
||||
channelA, err := stackA.api.NewDataChannel(stackA.sctp, dcParams)
|
||||
assert.NoError(t, err)
|
||||
|
||||
<-awaitSetup
|
||||
|
||||
assert.NoError(t, channelA.SendText("ABC"))
|
||||
assert.NoError(t, channelA.Send([]byte("ABC")))
|
||||
|
||||
<-awaitString
|
||||
<-awaitBinary
|
||||
|
||||
assert.NoError(t, stackA.close())
|
||||
assert.NoError(t, stackB.close())
|
||||
|
||||
// attempt to send when channel is closed
|
||||
assert.ErrorIs(t, channelA.Send([]byte("ABC")), io.ErrClosedPipe)
|
||||
assert.ErrorIs(t, channelA.SendText("test"), io.ErrClosedPipe)
|
||||
assert.ErrorIs(t, channelA.ensureOpen(), io.ErrClosedPipe)
|
||||
}
|
||||
Reference in New Issue
Block a user