Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,15 @@ export default (common: TestSetup<StreamMuxerFactory>): void => {
expect(inboundStream).to.have.property('writeStatus', 'writable', 'inbound stream writeStatus was incorrect')
expect(inboundStream).to.have.property('readStatus', 'readable', 'inbound stream readStatus was incorrect')
})

it('closes read only', async () => {
expect(outboundStream).to.not.have.nested.property('timeline.close')

await outboundStream.closeRead()

expect(outboundStream).to.have.property('writeStatus', 'writable')
expect(outboundStream).to.have.property('readStatus', 'closed')
})

it('aborts', async () => {
const eventPromises = Promise.all([
Expand Down Expand Up @@ -237,6 +246,19 @@ export default (common: TestSetup<StreamMuxerFactory>): void => {
expect(inboundEvent).to.have.nested.property('error.name', 'StreamResetError')
})

it('resets when remote aborts', async () => {
expect(outboundStream).to.not.have.nested.property('timeline.close')

const closePromise = pEvent(outboundStream, 'close')
inboundStream.abort(new Error('Urk!'))

await closePromise

expect(outboundStream).to.have.property('status', 'reset')
expect(isValidTick(outboundStream.timeline.close)).to.equal(true)
expect(outboundStream.timeline.close).to.be.greaterThanOrEqual(outboundStream.timeline.open)
})

it('does not send close read when remote closes write', async () => {
// @ts-expect-error internal method of AbstractMessageStream
const sendCloseReadSpy = Sinon.spy(outboundStream, 'sendCloseRead')
Expand Down
1 change: 0 additions & 1 deletion packages/transport-webrtc/test/stream.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ function generatePbByFlag (flag?: Message.Flag): Uint8Array {
return lengthPrefixed.encode.single(buf).subarray()
}

// TODO: move to transport interface compliance suite
describe.skip('Stream Stats', () => {
let stream: WebRTCStream
let peerConnection: RTCPeerConnection
Expand Down
Loading