diff --git a/test/parallel/test-http2-client-rststream-before-connect.js b/test/parallel/test-http2-client-rststream-before-connect.js index b0faaa5de2a398..7909fd97fc313b 100644 --- a/test/parallel/test-http2-client-rststream-before-connect.js +++ b/test/parallel/test-http2-client-rststream-before-connect.js @@ -16,18 +16,30 @@ server.on('stream', (stream) => { server.listen(0, common.mustCall(() => { const client = h2.connect(`http://localhost:${server.address().port}`); const req = client.request(); - req.close(1); + const closeCode = 1; + + common.expectsError( + () => req.close(2 ** 32), + { + type: RangeError, + code: 'ERR_OUT_OF_RANGE', + message: 'The "code" argument is out of range' + } + ); + assert.strictEqual(req.closed, false); + + req.close(closeCode, common.mustCall()); assert.strictEqual(req.closed, true); // make sure that destroy is called req._destroy = common.mustCall(req._destroy.bind(req)); - // second call doesn't do anything - assert.doesNotThrow(() => req.close(8)); + // Second call doesn't do anything. + req.close(closeCode + 1); req.on('close', common.mustCall((code) => { assert.strictEqual(req.destroyed, true); - assert.strictEqual(code, 1); + assert.strictEqual(code, closeCode); server.close(); client.close(); })); @@ -35,7 +47,7 @@ server.listen(0, common.mustCall(() => { req.on('error', common.expectsError({ code: 'ERR_HTTP2_STREAM_ERROR', type: Error, - message: 'Stream closed with error code 1' + message: `Stream closed with error code ${closeCode}` })); req.on('response', common.mustCall());