-
Notifications
You must be signed in to change notification settings - Fork 30.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: http2 ERR_INVALID_ARG_TYPE tests
PR-URL: #15766 Ref: #14985 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
- Loading branch information
1 parent
1956ae7
commit 1c14ad9
Showing
2 changed files
with
56 additions
and
35 deletions.
There are no files selected for viewing
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
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,43 @@ | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
if (!common.hasCrypto) | ||
common.skip('missing crypto'); | ||
const http2 = require('http2'); | ||
|
||
const server = http2.createServer(); | ||
|
||
server.on( | ||
'stream', | ||
common.mustCall((stream) => { | ||
const invalidArgTypeError = (param, type) => ({ | ||
type: TypeError, | ||
code: 'ERR_INVALID_ARG_TYPE', | ||
message: `The "${param}" argument must be of type ${type}` | ||
}); | ||
common.expectsError( | ||
() => stream.session.priority(undefined, {}), | ||
invalidArgTypeError('stream', 'Http2Stream') | ||
); | ||
common.expectsError( | ||
() => stream.session.rstStream(undefined), | ||
invalidArgTypeError('stream', 'Http2Stream') | ||
); | ||
common.expectsError( | ||
() => stream.session.rstStream(stream, 'string'), | ||
invalidArgTypeError('code', 'number') | ||
); | ||
stream.session.destroy(); | ||
}) | ||
); | ||
|
||
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())); | ||
req.end(); | ||
}) | ||
); |