From 0a1adc061e827f09f0cd063f0117cef1221be69d Mon Sep 17 00:00:00 2001 From: James M Snell Date: Tue, 16 Jan 2018 09:34:20 -0800 Subject: [PATCH] http2: add checks for server close callback Verify that server close callbacks are being called PR-URL: https://github.com/nodejs/node/pull/18182 Refs: https://github.com/nodejs/node/issues/18176 Reviewed-By: Anna Henningsen Reviewed-By: Ruben Bridgewater --- test/parallel/test-http2-create-client-secure-session.js | 3 ++- test/parallel/test-http2-create-client-session.js | 4 +++- test/parallel/test-http2-createwritereq.js | 2 +- test/parallel/test-http2-misbehaving-flow-control.js | 4 +++- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/test/parallel/test-http2-create-client-secure-session.js b/test/parallel/test-http2-create-client-secure-session.js index 6120a58602065d..b0111e15b69c15 100644 --- a/test/parallel/test-http2-create-client-secure-session.js +++ b/test/parallel/test-http2-create-client-secure-session.js @@ -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 }); @@ -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(); })); })); diff --git a/test/parallel/test-http2-create-client-session.js b/test/parallel/test-http2-create-client-session.js index b5be6bc8581452..963db2faa173b7 100644 --- a/test/parallel/test-http2-create-client-session.js +++ b/test/parallel/test-http2-create-client-session.js @@ -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(() => { @@ -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++) { diff --git a/test/parallel/test-http2-createwritereq.js b/test/parallel/test-http2-createwritereq.js index 1d2b31676284d0..1575424d1609b4 100644 --- a/test/parallel/test-http2-createwritereq.js +++ b/test/parallel/test-http2-createwritereq.js @@ -60,7 +60,7 @@ server.listen(0, common.mustCall(function() { testsFinished++; if (testsFinished === testsToRun) { - server.close(); + server.close(common.mustCall()); } })); diff --git a/test/parallel/test-http2-misbehaving-flow-control.js b/test/parallel/test-http2-misbehaving-flow-control.js index 8a0b411b8de65c..161a88ea1fb407 100644 --- a/test/parallel/test-http2-misbehaving-flow-control.js +++ b/test/parallel/test-http2-misbehaving-flow-control.js @@ -72,7 +72,7 @@ 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(); @@ -80,6 +80,8 @@ server.on('stream', (stream) => { stream.end('ok'); }); +server.on('close', common.mustCall()); + server.listen(0, () => { client = net.connect(server.address().port, () => { client.write(preamble);