This repository was archived by the owner on Jun 26, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +20
-3
lines changed
Expand file tree Collapse file tree 3 files changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -138,7 +138,7 @@ class Connection {
138138
139139 const { stream, protocol } = await this . _newStream ( protocols )
140140
141- this . addStream ( stream , protocol )
141+ this . addStream ( stream , { protocol } )
142142
143143 return {
144144 stream,
Original file line number Diff line number Diff line change @@ -120,6 +120,19 @@ module.exports = (test) => {
120120 expect ( connection . stat . status ) . to . equal ( Status . CLOSED )
121121 } )
122122
123+ it ( 'should properly track streams' , async ( ) => {
124+ // Open stream
125+ const protocol = '/echo/0.0.1'
126+ const { stream } = await connection . newStream ( protocol )
127+ const trackedStream = connection . registry . get ( stream . id )
128+ expect ( trackedStream ) . to . have . property ( 'protocol' , protocol )
129+
130+ // Close stream
131+ await stream . close ( )
132+
133+ expect ( connection . registry . get ( stream . id ) ) . to . not . exist ( )
134+ } )
135+
123136 it ( 'should support a proxy on the timeline' , async ( ) => {
124137 sinon . spy ( proxyHandler , 'set' )
125138 expect ( connection . stat . timeline . close ) . to . not . exist ( )
Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ describe('compliance tests', () => {
2525 const openStreams = [ ]
2626 let streamId = 0
2727
28- return new Connection ( {
28+ const connection = new Connection ( {
2929 localPeer,
3030 remotePeer,
3131 localAddr,
@@ -43,7 +43,10 @@ describe('compliance tests', () => {
4343 const id = streamId ++
4444 const stream = pair ( )
4545
46- stream . close = ( ) => stream . sink ( [ ] )
46+ stream . close = async ( ) => {
47+ await stream . sink ( [ ] )
48+ connection . removeStream ( stream . id )
49+ }
4750 stream . id = id
4851
4952 openStreams . push ( stream )
@@ -57,6 +60,7 @@ describe('compliance tests', () => {
5760 getStreams : ( ) => openStreams ,
5861 ...properties
5962 } )
63+ return connection
6064 } ,
6165 async teardown ( ) {
6266 // cleanup resources created by setup()
You can’t perform that action at this time.
0 commit comments