-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: http2 test coverage for updateOptionsBuffer
PR-URL: #15105 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
- Loading branch information
Showing
1 changed file
with
67 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// Flags: --expose-internals | ||
'use strict'; | ||
|
||
require('../common'); | ||
|
||
// Test coverage for the updateOptionsBuffer method used internally | ||
// by the http2 implementation. | ||
|
||
const { updateOptionsBuffer } = require('internal/http2/util'); | ||
const { optionsBuffer } = process.binding('http2'); | ||
const { ok, strictEqual } = require('assert'); | ||
|
||
const IDX_OPTIONS_MAX_DEFLATE_DYNAMIC_TABLE_SIZE = 0; | ||
const IDX_OPTIONS_MAX_RESERVED_REMOTE_STREAMS = 1; | ||
const IDX_OPTIONS_MAX_SEND_HEADER_BLOCK_LENGTH = 2; | ||
const IDX_OPTIONS_PEER_MAX_CONCURRENT_STREAMS = 3; | ||
const IDX_OPTIONS_PADDING_STRATEGY = 4; | ||
const IDX_OPTIONS_FLAGS = 5; | ||
|
||
{ | ||
updateOptionsBuffer({ | ||
maxDeflateDynamicTableSize: 1, | ||
maxReservedRemoteStreams: 2, | ||
maxSendHeaderBlockLength: 3, | ||
peerMaxConcurrentStreams: 4, | ||
paddingStrategy: 5 | ||
}); | ||
|
||
strictEqual(optionsBuffer[IDX_OPTIONS_MAX_DEFLATE_DYNAMIC_TABLE_SIZE], 1); | ||
strictEqual(optionsBuffer[IDX_OPTIONS_MAX_RESERVED_REMOTE_STREAMS], 2); | ||
strictEqual(optionsBuffer[IDX_OPTIONS_MAX_SEND_HEADER_BLOCK_LENGTH], 3); | ||
strictEqual(optionsBuffer[IDX_OPTIONS_PEER_MAX_CONCURRENT_STREAMS], 4); | ||
strictEqual(optionsBuffer[IDX_OPTIONS_PADDING_STRATEGY], 5); | ||
|
||
const flags = optionsBuffer[IDX_OPTIONS_FLAGS]; | ||
|
||
ok(flags & (1 << IDX_OPTIONS_MAX_DEFLATE_DYNAMIC_TABLE_SIZE)); | ||
ok(flags & (1 << IDX_OPTIONS_MAX_RESERVED_REMOTE_STREAMS)); | ||
ok(flags & (1 << IDX_OPTIONS_MAX_SEND_HEADER_BLOCK_LENGTH)); | ||
ok(flags & (1 << IDX_OPTIONS_PEER_MAX_CONCURRENT_STREAMS)); | ||
ok(flags & (1 << IDX_OPTIONS_PADDING_STRATEGY)); | ||
} | ||
|
||
{ | ||
optionsBuffer[IDX_OPTIONS_MAX_SEND_HEADER_BLOCK_LENGTH] = 0; | ||
|
||
updateOptionsBuffer({ | ||
maxDeflateDynamicTableSize: 1, | ||
maxReservedRemoteStreams: 2, | ||
peerMaxConcurrentStreams: 4, | ||
paddingStrategy: 5 | ||
}); | ||
|
||
strictEqual(optionsBuffer[IDX_OPTIONS_MAX_DEFLATE_DYNAMIC_TABLE_SIZE], 1); | ||
strictEqual(optionsBuffer[IDX_OPTIONS_MAX_RESERVED_REMOTE_STREAMS], 2); | ||
strictEqual(optionsBuffer[IDX_OPTIONS_MAX_SEND_HEADER_BLOCK_LENGTH], 0); | ||
strictEqual(optionsBuffer[IDX_OPTIONS_PEER_MAX_CONCURRENT_STREAMS], 4); | ||
strictEqual(optionsBuffer[IDX_OPTIONS_PADDING_STRATEGY], 5); | ||
|
||
const flags = optionsBuffer[IDX_OPTIONS_FLAGS]; | ||
|
||
ok(flags & (1 << IDX_OPTIONS_MAX_DEFLATE_DYNAMIC_TABLE_SIZE)); | ||
ok(flags & (1 << IDX_OPTIONS_MAX_RESERVED_REMOTE_STREAMS)); | ||
ok(!(flags & (1 << IDX_OPTIONS_MAX_SEND_HEADER_BLOCK_LENGTH))); | ||
ok(flags & (1 << IDX_OPTIONS_PEER_MAX_CONCURRENT_STREAMS)); | ||
ok(flags & (1 << IDX_OPTIONS_PADDING_STRATEGY)); | ||
} |