fix(connection): tracks streams properly (#25)

This commit is contained in:
Jacob Heun
2020-02-04 17:34:56 +01:00
committed by GitHub
parent f6871afd76
commit 5c88d77aaa
3 changed files with 20 additions and 3 deletions

View File

@ -138,7 +138,7 @@ class Connection {
const { stream, protocol } = await this._newStream(protocols)
this.addStream(stream, protocol)
this.addStream(stream, { protocol })
return {
stream,

View File

@ -120,6 +120,19 @@ module.exports = (test) => {
expect(connection.stat.status).to.equal(Status.CLOSED)
})
it('should properly track streams', async () => {
// Open stream
const protocol = '/echo/0.0.1'
const { stream } = await connection.newStream(protocol)
const trackedStream = connection.registry.get(stream.id)
expect(trackedStream).to.have.property('protocol', protocol)
// Close stream
await stream.close()
expect(connection.registry.get(stream.id)).to.not.exist()
})
it('should support a proxy on the timeline', async () => {
sinon.spy(proxyHandler, 'set')
expect(connection.stat.timeline.close).to.not.exist()