Skip to content

Commit b3d2513

Browse files
committed
redo test to use duplex pair instead of PassThrough
1 parent c64f6b1 commit b3d2513

File tree

1 file changed

+21
-14
lines changed

1 file changed

+21
-14
lines changed

test/parallel/test-http2-session-unref.js

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ const common = require('../common');
99
if (!common.hasCrypto)
1010
common.skip('missing crypto');
1111
const http2 = require('http2');
12-
const { PassThrough } = require('stream');
12+
const makeDuplexPair = require('../common/duplexpair');
1313

1414
const server = http2.createServer();
15+
const { clientSide, serverSide } = makeDuplexPair();
1516

1617
// 'session' event should be emitted 3 times:
1718
// - the vanilla client
@@ -25,22 +26,28 @@ server.listen(0, common.mustCall(() => {
2526
const port = server.address().port;
2627

2728
// unref new client
28-
let client = http2.connect(`http://localhost:${port}`);
29-
client.unref();
29+
{
30+
const client = http2.connect(`http://localhost:${port}`);
31+
client.unref();
32+
}
3033

3134
// unref destroyed client
32-
client = http2.connect(`http://localhost:${port}`);
33-
client.destroy();
34-
client.unref();
35-
36-
// unref client with generic Duplex stream
37-
client = http2.connect(`http://localhost:${port}`, {
38-
createConnection: common.mustCall(() => PassThrough())
39-
});
40-
client.unref();
35+
{
36+
const client = http2.connect(`http://localhost:${port}`);
37+
client.destroy();
38+
client.unref();
39+
}
40+
41+
// unref destroyed client
42+
{
43+
const client = http2.connect(`http://localhost:${port}`, {
44+
createConnection: common.mustCall(() => clientSide)
45+
});
46+
client.destroy();
47+
client.unref();
48+
}
4149
}));
50+
server.emit('connection', serverSide);
4251
server.unref();
4352

44-
server.emit('connection', PassThrough());
45-
4653
setTimeout(common.mustNotCall(() => {}), 1000).unref();

0 commit comments

Comments
 (0)