mirror of
https://github.com/nodejs/node.git
synced 2025-05-11 16:21:27 +00:00

Currently, when configured --without-ssl tests that use process.binding('crypto') fail with the following error: === release test-accessor-properties === Path: parallel/test-accessor-properties node/test/parallel/test-accessor-properties.js:16 const crypto = process.binding('crypto'); ^ Error: No such module: crypto at Object.<anonymous> (test-accessor-properties.js:16:24) at Module._compile (module.js:660:30) at Object.Module._extensions..js (module.js:671:10) at Module.load (module.js:577:32) at tryModuleLoad (module.js:517:12) at Function.Module._load (module.js:509:3) at Function.Module.runMain (module.js:701:10) at startup (bootstrap_node.js:194:16) at bootstrap_node.js:645:3 This commit adds a hasCrypto check. PR-URL: https://github.com/nodejs/node/pull/17867 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
89 lines
3.4 KiB
JavaScript
89 lines
3.4 KiB
JavaScript
// Flags: --expose-internals
|
|
'use strict';
|
|
|
|
const common = require('../common');
|
|
if (!common.hasCrypto)
|
|
common.skip('missing crypto');
|
|
|
|
// 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_MAX_HEADER_LIST_PAIRS = 5;
|
|
const IDX_OPTIONS_MAX_OUTSTANDING_PINGS = 6;
|
|
const IDX_OPTIONS_MAX_OUTSTANDING_SETTINGS = 7;
|
|
const IDX_OPTIONS_FLAGS = 8;
|
|
|
|
{
|
|
updateOptionsBuffer({
|
|
maxDeflateDynamicTableSize: 1,
|
|
maxReservedRemoteStreams: 2,
|
|
maxSendHeaderBlockLength: 3,
|
|
peerMaxConcurrentStreams: 4,
|
|
paddingStrategy: 5,
|
|
maxHeaderListPairs: 6,
|
|
maxOutstandingPings: 7,
|
|
maxOutstandingSettings: 8
|
|
});
|
|
|
|
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);
|
|
strictEqual(optionsBuffer[IDX_OPTIONS_MAX_HEADER_LIST_PAIRS], 6);
|
|
strictEqual(optionsBuffer[IDX_OPTIONS_MAX_OUTSTANDING_PINGS], 7);
|
|
strictEqual(optionsBuffer[IDX_OPTIONS_MAX_OUTSTANDING_SETTINGS], 8);
|
|
|
|
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));
|
|
ok(flags & (1 << IDX_OPTIONS_MAX_HEADER_LIST_PAIRS));
|
|
ok(flags & (1 << IDX_OPTIONS_MAX_OUTSTANDING_PINGS));
|
|
ok(flags & (1 << IDX_OPTIONS_MAX_OUTSTANDING_SETTINGS));
|
|
}
|
|
|
|
{
|
|
optionsBuffer[IDX_OPTIONS_MAX_SEND_HEADER_BLOCK_LENGTH] = 0;
|
|
optionsBuffer[IDX_OPTIONS_MAX_OUTSTANDING_PINGS] = 0;
|
|
|
|
updateOptionsBuffer({
|
|
maxDeflateDynamicTableSize: 1,
|
|
maxReservedRemoteStreams: 2,
|
|
peerMaxConcurrentStreams: 4,
|
|
paddingStrategy: 5,
|
|
maxHeaderListPairs: 6
|
|
});
|
|
|
|
strictEqual(optionsBuffer[IDX_OPTIONS_MAX_DEFLATE_DYNAMIC_TABLE_SIZE], 1);
|
|
strictEqual(optionsBuffer[IDX_OPTIONS_MAX_RESERVED_REMOTE_STREAMS], 2);
|
|
strictEqual(optionsBuffer[IDX_OPTIONS_PEER_MAX_CONCURRENT_STREAMS], 4);
|
|
strictEqual(optionsBuffer[IDX_OPTIONS_PADDING_STRATEGY], 5);
|
|
strictEqual(optionsBuffer[IDX_OPTIONS_MAX_HEADER_LIST_PAIRS], 6);
|
|
strictEqual(optionsBuffer[IDX_OPTIONS_MAX_SEND_HEADER_BLOCK_LENGTH], 0);
|
|
strictEqual(optionsBuffer[IDX_OPTIONS_MAX_OUTSTANDING_PINGS], 0);
|
|
|
|
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_PEER_MAX_CONCURRENT_STREAMS));
|
|
ok(flags & (1 << IDX_OPTIONS_PADDING_STRATEGY));
|
|
ok(flags & (1 << IDX_OPTIONS_MAX_HEADER_LIST_PAIRS));
|
|
|
|
ok(!(flags & (1 << IDX_OPTIONS_MAX_SEND_HEADER_BLOCK_LENGTH)));
|
|
ok(!(flags & (1 << IDX_OPTIONS_MAX_OUTSTANDING_PINGS)));
|
|
}
|