mirror of
https://github.com/nodejs/node.git
synced 2025-05-09 13:05:07 +00:00

When building --without-ssl and running the tests some of the http2 test fail with the following error message: internal/util.js:82 throw new errors.Error('ERR_NO_CRYPTO'); ^ Error [ERR_NO_CRYPTO]: Node.js is not compiled with OpenSSL crypto support at Object.assertCrypto (internal/util.js:82:11) at internal/http2/core.js:5:26 at NativeModule.compile (bootstrap_node.js:586:7) at NativeModule.require (bootstrap_node.js:531:18) at http2.js:17:5 at NativeModule.compile (bootstrap_node.js:586:7) at Function.NativeModule.require (bootstrap_node.js:531:18) at Function.Module._load (module.js:449:25) at Module.require (module.js:517:17) at require (internal/module.js:11:18) This commit adds hasCrypto checks and skips the tests if there is no crypto support. PR-URL: https://github.com/nodejs/node/pull/14657 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
63 lines
1.8 KiB
JavaScript
63 lines
1.8 KiB
JavaScript
// Flags: --expose-http2
|
|
'use strict';
|
|
|
|
// Tests that attempting to send too many non-acknowledged
|
|
// settings frames will result in a throw.
|
|
|
|
const common = require('../common');
|
|
if (!common.hasCrypto)
|
|
common.skip('missing crypto');
|
|
const assert = require('assert');
|
|
const h2 = require('http2');
|
|
|
|
const maxPendingAck = 2;
|
|
const server = h2.createServer({ maxPendingAck: maxPendingAck + 1 });
|
|
|
|
let clients = 2;
|
|
|
|
function doTest(session) {
|
|
for (let n = 0; n < maxPendingAck; n++)
|
|
assert.doesNotThrow(() => session.settings({ enablePush: false }));
|
|
assert.throws(() => session.settings({ enablePush: false }),
|
|
common.expectsError({
|
|
code: 'ERR_HTTP2_MAX_PENDING_SETTINGS_ACK',
|
|
type: Error
|
|
}));
|
|
}
|
|
|
|
server.on('stream', common.mustNotCall());
|
|
|
|
server.once('session', common.mustCall((session) => doTest(session)));
|
|
|
|
server.listen(0);
|
|
|
|
const closeServer = common.mustCall(() => {
|
|
if (--clients === 0)
|
|
server.close();
|
|
}, clients);
|
|
|
|
server.on('listening', common.mustCall(() => {
|
|
const client = h2.connect(`http://localhost:${server.address().port}`,
|
|
{ maxPendingAck: maxPendingAck + 1 });
|
|
let remaining = maxPendingAck + 1;
|
|
|
|
client.on('close', closeServer);
|
|
client.on('localSettings', common.mustCall(() => {
|
|
if (--remaining <= 0) {
|
|
client.destroy();
|
|
}
|
|
}, maxPendingAck + 1));
|
|
client.on('connect', common.mustCall(() => doTest(client)));
|
|
}));
|
|
|
|
// Setting maxPendingAck to 0, defaults it to 1
|
|
server.on('listening', common.mustCall(() => {
|
|
const client = h2.connect(`http://localhost:${server.address().port}`,
|
|
{ maxPendingAck: 0 });
|
|
|
|
client.on('close', closeServer);
|
|
client.on('localSettings', common.mustCall(() => {
|
|
client.destroy();
|
|
}));
|
|
}));
|