Skip to content

Commit

Permalink
http2: Add tests for customSettings
Browse files Browse the repository at this point in the history
Test for the http2 settings custom settings were added.
  • Loading branch information
martenrichter committed Aug 13, 2023
1 parent 623e50b commit 9b23524
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
12 changes: 9 additions & 3 deletions test/parallel/test-http2-getpackedsettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ assert.deepStrictEqual(val, check);
['maxHeaderListSize', 2 ** 32 - 1],
['maxHeaderSize', 0],
['maxHeaderSize', 2 ** 32 - 1],
['customSettings', { 9999: 301}]
].forEach((i) => {
// Valid options should not throw.
http2.getPackedSettings({ [i[0]]: i[1] });
Expand Down Expand Up @@ -93,6 +94,8 @@ http2.getPackedSettings({ enablePush: false });
0x00, 0x05, 0x00, 0x00, 0x4e, 0x20,
0x00, 0x06, 0x00, 0x00, 0x00, 0x64,
0x00, 0x08, 0x00, 0x00, 0x00, 0x00,
0x00, 0x08, 0x00, 0x00, 0x00, 0x00,
0x27, 0x0F, 0x00, 0x00, 0x01, 0x2d
]);

const packed = http2.getPackedSettings({
Expand All @@ -104,9 +107,10 @@ http2.getPackedSettings({ enablePush: false });
maxHeaderSize: 100,
enablePush: true,
enableConnectProtocol: false,
foo: 'ignored'
foo: 'ignored',
customSettings: { 9999: 301}
});
assert.strictEqual(packed.length, 42);
assert.strictEqual(packed.length, 48);
assert.deepStrictEqual(packed, check);
}

Expand All @@ -124,7 +128,8 @@ http2.getPackedSettings({ enablePush: false });
0x00, 0x04, 0x00, 0x00, 0x00, 0x64,
0x00, 0x06, 0x00, 0x00, 0x00, 0x64,
0x00, 0x02, 0x00, 0x00, 0x00, 0x01,
0x00, 0x08, 0x00, 0x00, 0x00, 0x00]);
0x00, 0x08, 0x00, 0x00, 0x00, 0x00,
0x27, 0x0F, 0x00, 0x00, 0x01, 0x2d]);

[1, true, '', [], {}, NaN].forEach((input) => {
assert.throws(() => {
Expand Down Expand Up @@ -157,6 +162,7 @@ http2.getPackedSettings({ enablePush: false });
assert.strictEqual(settings.maxHeaderSize, 100);
assert.strictEqual(settings.enablePush, true);
assert.strictEqual(settings.enableConnectProtocol, false);
assert.deepStrictEqual(settings.customSettings, { 9999: 301});
}

{
Expand Down
3 changes: 2 additions & 1 deletion test/parallel/test-http2-update-settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ testUpdateSettingsWith({
'maxHeaderListSize': 1,
'maxFrameSize': 16385,
'enablePush': false,
'enableConnectProtocol': true
'enableConnectProtocol': true,
'customSettings': { 9999: 301}
}
});
testUpdateSettingsWith({
Expand Down

0 comments on commit 9b23524

Please sign in to comment.