diff options
author | Trivikram Kamat <trivikr.dev@gmail.com> | 2017-10-08 16:56:44 -0700 |
---|---|---|
committer | James M Snell <jasnell@gmail.com> | 2017-10-15 15:23:13 -0700 |
commit | 68df587b1ee6b28f6abf5efffbd2475cf54508e2 (patch) | |
tree | 20386a73a4aaba3cbf7bc9aa1315323c01876e3a /test/parallel/test-http2-client-destroy.js | |
parent | 75f154b1f0b10d03200cc590582f37474379e825 (diff) | |
download | android-node-v8-68df587b1ee6b28f6abf5efffbd2475cf54508e2.tar.gz android-node-v8-68df587b1ee6b28f6abf5efffbd2475cf54508e2.tar.bz2 android-node-v8-68df587b1ee6b28f6abf5efffbd2475cf54508e2.zip |
test: http2 client operations after destroy
PR-URL: https://github.com/nodejs/node/pull/16094
Ref: https://github.com/nodejs/node/issues/14985
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>
Diffstat (limited to 'test/parallel/test-http2-client-destroy.js')
-rw-r--r-- | test/parallel/test-http2-client-destroy.js | 49 |
1 files changed, 24 insertions, 25 deletions
diff --git a/test/parallel/test-http2-client-destroy.js b/test/parallel/test-http2-client-destroy.js index 94f66930aa..f10bf60ce3 100644 --- a/test/parallel/test-http2-client-destroy.js +++ b/test/parallel/test-http2-client-destroy.js @@ -71,19 +71,40 @@ const h2 = require('http2'); ); } -// test destroy before connect +// test destroy before client operations { const server = h2.createServer(); server.listen( 0, common.mustCall(() => { const client = h2.connect(`http://localhost:${server.address().port}`); - - const req = client.request({ ':path': '/' }); + const req = client.request(); client.destroy(); req.on('response', common.mustNotCall()); req.resume(); + + const sessionError = { + type: Error, + code: 'ERR_HTTP2_INVALID_SESSION', + message: 'The session has been destroyed' + }; + + common.expectsError(() => client.request(), sessionError); + common.expectsError(() => client.settings({}), sessionError); + common.expectsError(() => client.priority(req, {}), sessionError); + common.expectsError(() => client.shutdown(), sessionError); + + // Wait for setImmediate call from destroy() to complete + // so that state.destroyed is set to true + setImmediate(() => { + common.expectsError(() => client.request(), sessionError); + common.expectsError(() => client.settings({}), sessionError); + common.expectsError(() => client.priority(req, {}), sessionError); + common.expectsError(() => client.shutdown(), sessionError); + common.expectsError(() => client.rstStream(req), sessionError); + }); + req.on( 'end', common.mustCall(() => { @@ -95,28 +116,6 @@ const h2 = require('http2'); ); } -// test destroy before request -{ - const server = h2.createServer(); - server.listen( - 0, - common.mustCall(() => { - const client = h2.connect(`http://localhost:${server.address().port}`); - client.destroy(); - - assert.throws( - () => client.request({ ':path': '/' }), - common.expectsError({ - code: 'ERR_HTTP2_INVALID_SESSION', - message: 'The session has been destroyed' - }) - ); - - server.close(); - }) - ); -} - // test destroy before goaway { const server = h2.createServer(); |