Skip to content

Commit 1d82020

Browse files
committed
refactor- moved closeRead and reset tests to compliance suite
1 parent 851395e commit 1d82020

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

packages/interface-compliance-tests/src/stream-muxer/stream-test.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,15 @@ export default (common: TestSetup<StreamMuxerFactory>): void => {
200200
expect(inboundStream).to.have.property('writeStatus', 'writable', 'inbound stream writeStatus was incorrect')
201201
expect(inboundStream).to.have.property('readStatus', 'readable', 'inbound stream readStatus was incorrect')
202202
})
203+
204+
it('closes read only', async () => {
205+
expect(outboundStream).to.not.have.nested.property('timeline.close')
206+
207+
await outboundStream.closeRead()
208+
209+
expect(outboundStream).to.have.property('writeStatus', 'writable')
210+
expect(outboundStream).to.have.property('readStatus', 'closed')
211+
})
203212

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

249+
it('resets when remote aborts', async () => {
250+
expect(outboundStream).to.not.have.nested.property('timeline.close')
251+
252+
const closePromise = pEvent(outboundStream, 'close')
253+
inboundStream.abort(new Error('Urk!'))
254+
255+
await closePromise
256+
257+
expect(outboundStream).to.have.property('status', 'reset')
258+
expect(isValidTick(outboundStream.timeline.close)).to.equal(true)
259+
expect(outboundStream.timeline.close).to.be.greaterThanOrEqual(outboundStream.timeline.open)
260+
})
261+
240262
it('does not send close read when remote closes write', async () => {
241263
// @ts-expect-error internal method of AbstractMessageStream
242264
const sendCloseReadSpy = Sinon.spy(outboundStream, 'sendCloseRead')

0 commit comments

Comments
 (0)