From b9cfd883ae17f1d3628e4654624fe4514ae8b5e7 Mon Sep 17 00:00:00 2001 From: Trivikram Kamat Date: Mon, 25 Sep 2017 01:33:28 -0700 Subject: [PATCH] test: http2Stream redundant shutdown and single cb PR-URL: https://github.com/nodejs/node/pull/15612 Refs: https://github.com/nodejs/node/issues/14985 Reviewed-By: James M Snell Reviewed-By: Yuta Hiroto Reviewed-By: Luigi Pinca Reviewed-By: Ruben Bridgewater --- .../test-http2-server-shutdown-redundant.js | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 test/parallel/test-http2-server-shutdown-redundant.js diff --git a/test/parallel/test-http2-server-shutdown-redundant.js b/test/parallel/test-http2-server-shutdown-redundant.js new file mode 100644 index 0000000000..708be0868c --- /dev/null +++ b/test/parallel/test-http2-server-shutdown-redundant.js @@ -0,0 +1,29 @@ +'use strict'; + +const common = require('../common'); +if (!common.hasCrypto) + common.skip('missing crypto'); +const assert = require('assert'); +const http2 = require('http2'); + +const server = http2.createServer(); + +// Test blank return when a stream.session.shutdown is called twice +// Also tests stream.session.shutdown with just a callback function (no options) +server.on('stream', common.mustCall((stream) => { + stream.session.shutdown(common.mustCall(() => { + assert.strictEqual( + stream.session.shutdown(common.mustNotCall()), + undefined + ); + })); + stream.session.shutdown(common.mustNotCall()); +})); + +server.listen(0, common.mustCall(() => { + const client = http2.connect(`http://localhost:${server.address().port}`); + + const req = client.request(); + req.resume(); + req.on('end', common.mustCall(() => server.close())); +}));