Skip to content

Commit

Permalink
redo test to use duplex pair instead of PassThrough
Browse files Browse the repository at this point in the history
  • Loading branch information
kjin committed Dec 21, 2017
1 parent c64f6b1 commit b3d2513
Showing 1 changed file with 21 additions and 14 deletions.
35 changes: 21 additions & 14 deletions test/parallel/test-http2-session-unref.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');
const http2 = require('http2');
const { PassThrough } = require('stream');
const makeDuplexPair = require('../common/duplexpair');

const server = http2.createServer();
const { clientSide, serverSide } = makeDuplexPair();

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

// unref new client
let client = http2.connect(`http://localhost:${port}`);
client.unref();
{
const client = http2.connect(`http://localhost:${port}`);
client.unref();
}

// unref destroyed client
client = http2.connect(`http://localhost:${port}`);
client.destroy();
client.unref();

// unref client with generic Duplex stream
client = http2.connect(`http://localhost:${port}`, {
createConnection: common.mustCall(() => PassThrough())
});
client.unref();
{
const client = http2.connect(`http://localhost:${port}`);
client.destroy();
client.unref();
}

// unref destroyed client
{
const client = http2.connect(`http://localhost:${port}`, {
createConnection: common.mustCall(() => clientSide)
});
client.destroy();
client.unref();
}
}));
server.emit('connection', serverSide);
server.unref();

server.emit('connection', PassThrough());

setTimeout(common.mustNotCall(() => {}), 1000).unref();

0 comments on commit b3d2513

Please sign in to comment.