Skip to content

Commit

Permalink
http2: add checks for server close callback
Browse files Browse the repository at this point in the history
Verify that server close callbacks are being called

PR-URL: #18182
Refs: #18176
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
  • Loading branch information
jasnell authored and evanlucas committed Jan 30, 2018
1 parent 1c8df28 commit ee6217a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
3 changes: 2 additions & 1 deletion test/parallel/test-http2-create-client-secure-session.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ function onStream(stream, headers) {
function verifySecureSession(key, cert, ca, opts) {
const server = h2.createSecureServer({ cert, key });
server.on('stream', common.mustCall(onStream));
server.on('close', common.mustCall());
server.listen(0, common.mustCall(() => {
opts = opts || { };
opts.secureContext = tls.createSecureContext({ ca });
Expand Down Expand Up @@ -72,7 +73,7 @@ function verifySecureSession(key, cert, ca, opts) {
assert.strictEqual(jsonData.servername,
opts.servername || 'localhost');
assert.strictEqual(jsonData.alpnProtocol, 'h2');
server.close();
server.close(common.mustCall());
client[kSocket].destroy();
}));
}));
Expand Down
4 changes: 3 additions & 1 deletion test/parallel/test-http2-create-client-session.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ function onStream(stream, headers, flags) {
stream.end(body.slice(20));
}

server.on('close', common.mustCall());

server.listen(0);

server.on('listening', common.mustCall(() => {
Expand All @@ -46,7 +48,7 @@ server.on('listening', common.mustCall(() => {

const countdown = new Countdown(count, () => {
client.close();
server.close();
server.close(common.mustCall());
});

for (let n = 0; n < count; n++) {
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-http2-createwritereq.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ server.listen(0, common.mustCall(function() {
testsFinished++;

if (testsFinished === testsToRun) {
server.close();
server.close(common.mustCall());
}
}));

Expand Down
4 changes: 3 additions & 1 deletion test/parallel/test-http2-misbehaving-flow-control.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,16 @@ server.on('stream', (stream) => {
message: 'Stream closed with error code 3'
}));
stream.on('close', common.mustCall(() => {
server.close();
server.close(common.mustCall());
client.destroy();
}));
stream.resume();
stream.respond();
stream.end('ok');
});

server.on('close', common.mustCall());

server.listen(0, () => {
client = net.connect(server.address().port, () => {
client.write(preamble);
Expand Down

0 comments on commit ee6217a

Please sign in to comment.