Skip to content

Commit

Permalink
test: increase http2 coverage
Browse files Browse the repository at this point in the history
Added tests for `getPackedSettings` to check for not passing `settings`
and for `getUnpackedSettings` to check for a few cases when passing
`{ validate: true }`.

PR-URL: #14701
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
  • Loading branch information
michaalbert authored and addaleax committed Aug 10, 2017
1 parent b5556e4 commit 340b3be
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions test/parallel/test-http2-getpackedsettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,12 @@ assert.doesNotThrow(() => http2.getPackedSettings({ enablePush: false }));
assert.deepStrictEqual(packed, check);
}

// check for not passing settings
{
const packed = http2.getPackedSettings();
assert.strictEqual(packed.length, 0);
}

{
const packed = Buffer.from([
0x00, 0x01, 0x00, 0x00, 0x00, 0x64, 0x00, 0x03, 0x00, 0x00,
Expand Down Expand Up @@ -120,6 +126,33 @@ assert.doesNotThrow(() => http2.getPackedSettings({ enablePush: false }));
assert.strictEqual(settings.enablePush, true);
}

//check for what happens if passing {validate: true} and no errors happen
{
const packed = Buffer.from([
0x00, 0x01, 0x00, 0x00, 0x00, 0x64, 0x00, 0x03, 0x00, 0x00,
0x00, 0xc8, 0x00, 0x05, 0x00, 0x00, 0x4e, 0x20, 0x00, 0x04,
0x00, 0x00, 0x00, 0x64, 0x00, 0x06, 0x00, 0x00, 0x00, 0x64,
0x00, 0x02, 0x00, 0x00, 0x00, 0x01]);

assert.doesNotThrow(() => {
http2.getUnpackedSettings(packed, { validate: true });
});
}

// check for maxFrameSize failing the max number
{
const packed = Buffer.from([0x00, 0x05, 0x01, 0x00, 0x00, 0x00]);

assert.throws(() => {
http2.getUnpackedSettings(packed, { validate: true });
}, common.expectsError({
code: 'ERR_HTTP2_INVALID_SETTING_VALUE',
type: RangeError,
message: 'Invalid value for setting "maxFrameSize": 16777216'
}));
}

// check for maxConcurrentStreams failing the max number
{
const packed = Buffer.from([0x00, 0x03, 0xFF, 0xFF, 0xFF, 0xFF]);

Expand Down

0 comments on commit 340b3be

Please sign in to comment.