File tree 3 files changed +20
-3
lines changed
3 files changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -138,7 +138,7 @@ class Connection {
138
138
139
139
const { stream, protocol } = await this . _newStream ( protocols )
140
140
141
- this . addStream ( stream , protocol )
141
+ this . addStream ( stream , { protocol } )
142
142
143
143
return {
144
144
stream,
Original file line number Diff line number Diff line change @@ -120,6 +120,19 @@ module.exports = (test) => {
120
120
expect ( connection . stat . status ) . to . equal ( Status . CLOSED )
121
121
} )
122
122
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
+
123
136
it ( 'should support a proxy on the timeline' , async ( ) => {
124
137
sinon . spy ( proxyHandler , 'set' )
125
138
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', () => {
25
25
const openStreams = [ ]
26
26
let streamId = 0
27
27
28
- return new Connection ( {
28
+ const connection = new Connection ( {
29
29
localPeer,
30
30
remotePeer,
31
31
localAddr,
@@ -43,7 +43,10 @@ describe('compliance tests', () => {
43
43
const id = streamId ++
44
44
const stream = pair ( )
45
45
46
- stream . close = ( ) => stream . sink ( [ ] )
46
+ stream . close = async ( ) => {
47
+ await stream . sink ( [ ] )
48
+ connection . removeStream ( stream . id )
49
+ }
47
50
stream . id = id
48
51
49
52
openStreams . push ( stream )
@@ -57,6 +60,7 @@ describe('compliance tests', () => {
57
60
getStreams : ( ) => openStreams ,
58
61
...properties
59
62
} )
63
+ return connection
60
64
} ,
61
65
async teardown ( ) {
62
66
// cleanup resources created by setup()
You can’t perform that action at this time.
0 commit comments