-
Notifications
You must be signed in to change notification settings - Fork 30k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: consolidate http2 tests in one file
PR-URL: #15624 Refs: #14985 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
- Loading branch information
Showing
9 changed files
with
48 additions
and
310 deletions.
There are no files selected for viewing
40 changes: 0 additions & 40 deletions
40
test/parallel/test-http2-server-destroy-before-additional.js
This file was deleted.
Oops, something went wrong.
41 changes: 0 additions & 41 deletions
41
test/parallel/test-http2-server-destroy-before-priority.js
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
31 changes: 0 additions & 31 deletions
31
test/parallel/test-http2-server-destroy-before-shutdown.js
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// Flags: --expose-http2 | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
if (!common.hasCrypto) | ||
common.skip('missing crypto'); | ||
const assert = require('assert'); | ||
const h2 = require('http2'); | ||
|
||
const server = h2.createServer(); | ||
|
||
server.on( | ||
'stream', | ||
common.mustCall((stream) => { | ||
const errorObj = { | ||
type: Error, | ||
code: 'ERR_HTTP2_INVALID_STREAM', | ||
message: 'The stream has been destroyed' | ||
}; | ||
stream.session.destroy(); | ||
|
||
// Test that stream.state getter returns an empty object | ||
// when the stream session has been destroyed | ||
assert.deepStrictEqual(Object.create(null), stream.state); | ||
|
||
// Test that ERR_HTTP2_INVALID_STREAM is thrown while calling | ||
// stream operations after the stream session has been destroyed | ||
common.expectsError(() => stream.additionalHeaders(), errorObj); | ||
common.expectsError(() => stream.priority(), errorObj); | ||
common.expectsError( | ||
() => stream.pushStream({}, common.mustNotCall()), | ||
errorObj | ||
); | ||
common.expectsError(() => stream.respond(), errorObj); | ||
common.expectsError(() => stream.rstStream(), errorObj); | ||
common.expectsError(() => stream.write('data'), errorObj); | ||
}) | ||
); | ||
|
||
server.listen( | ||
0, | ||
common.mustCall(() => { | ||
const client = h2.connect(`http://localhost:${server.address().port}`); | ||
const req = client.request(); | ||
req.resume(); | ||
req.on('end', common.mustCall(() => server.close())); | ||
}) | ||
); |