Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit baf1acc

Browse filesBrowse files
trivikrMylesBorins
authored andcommitted
test: http2 client ping errors
PR-URL: #18849 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent 62c9992 commit baf1acc
Copy full SHA for baf1acc

File tree

Expand file treeCollapse file tree

1 file changed

+48
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+48
-0
lines changed
Open diff view settings
Collapse file

‎test/parallel/test-http2-ping.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-http2-ping.js
+48Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,60 @@ server.listen(0, common.mustCall(() => {
7171
assert.deepStrictEqual(payload, ret);
7272
})));
7373
}
74+
7475
// Only max 2 pings at a time based on the maxOutstandingPings option
7576
assert(!client.ping(common.expectsError({
7677
code: 'ERR_HTTP2_PING_CANCEL',
7778
type: Error,
7879
message: 'HTTP2 ping cancelled'
7980
})));
81+
82+
// should throw if payload is not of type ArrayBufferView
83+
{
84+
[1, true, {}, []].forEach((invalidPayload) =>
85+
common.expectsError(
86+
() => client.ping(invalidPayload),
87+
{
88+
type: TypeError,
89+
code: 'ERR_INVALID_ARG_TYPE',
90+
message: 'The "payload" argument must be one of type' +
91+
' Buffer, TypedArray, or DataView'
92+
}
93+
)
94+
);
95+
}
96+
97+
// should throw if payload length is not 8
98+
{
99+
const shortPayload = Buffer.from('abcdefg');
100+
const longPayload = Buffer.from('abcdefghi');
101+
[shortPayload, longPayload].forEach((payloadWithInvalidLength) =>
102+
common.expectsError(
103+
() => client.ping(payloadWithInvalidLength),
104+
{
105+
type: RangeError,
106+
code: 'ERR_HTTP2_PING_LENGTH',
107+
message: 'HTTP2 ping payload must be 8 bytes'
108+
}
109+
)
110+
);
111+
}
112+
113+
// should throw error is callback is not of type function
114+
{
115+
const payload = Buffer.from('abcdefgh');
116+
[1, true, {}, []].forEach((invalidCallback) =>
117+
common.expectsError(
118+
() => client.ping(payload, invalidCallback),
119+
{
120+
type: TypeError,
121+
code: 'ERR_INVALID_CALLBACK',
122+
message: 'Callback must be a function'
123+
}
124+
)
125+
);
126+
}
127+
80128
const req = client.request();
81129
req.resume();
82130
req.on('end', common.mustCall(() => {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.