diff --git a/packages/interface-compliance-tests/src/stream-muxer/stream-test.ts b/packages/interface-compliance-tests/src/stream-muxer/stream-test.ts index 96735cfedb..0fe7b629dc 100644 --- a/packages/interface-compliance-tests/src/stream-muxer/stream-test.ts +++ b/packages/interface-compliance-tests/src/stream-muxer/stream-test.ts @@ -200,6 +200,15 @@ export default (common: TestSetup): 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([ @@ -237,6 +246,19 @@ export default (common: TestSetup): 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') diff --git a/packages/transport-webrtc/test/stream.spec.ts b/packages/transport-webrtc/test/stream.spec.ts index fc4388c83f..bb629857f6 100644 --- a/packages/transport-webrtc/test/stream.spec.ts +++ b/packages/transport-webrtc/test/stream.spec.ts @@ -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