0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
nodejs/test/parallel/test-tls-connect-hwm-option.js
rickyes 58682d823a tls: add highWaterMark option for connect
PR-URL: https://github.com/nodejs/node/pull/32786
Fixes: https://github.com/nodejs/node/issues/32781
Reviewed-By: Zeyu Yang <himself65@outlook.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Andrey Pechkurov <apechkurov@gmail.com>
2020-04-27 16:52:19 +03:00

54 lines
1.3 KiB
JavaScript

'use strict';
const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');
const assert = require('assert');
const tls = require('tls');
const fixtures = require('../common/fixtures');
const pem = (n) => fixtures.readKey(`${n}.pem`);
let clients = 0;
const server = tls.createServer({
key: pem('agent1-key'),
cert: pem('agent1-cert')
}, common.mustCall(() => {
if (--clients === 0)
server.close();
}, 3));
server.listen(0, common.mustCall(() => {
clients++;
const highBob = tls.connect({
port: server.address().port,
rejectUnauthorized: false,
highWaterMark: 128000,
}, common.mustCall(() => {
assert.strictEqual(highBob.readableHighWaterMark, 128000);
highBob.end();
}));
clients++;
const defaultHighBob = tls.connect({
port: server.address().port,
rejectUnauthorized: false,
highWaterMark: undefined,
}, common.mustCall(() => {
assert.strictEqual(defaultHighBob.readableHighWaterMark, 16 * 1024);
defaultHighBob.end();
}));
clients++;
const zeroHighBob = tls.connect({
port: server.address().port,
rejectUnauthorized: false,
highWaterMark: 0,
}, common.mustCall(() => {
assert.strictEqual(zeroHighBob.readableHighWaterMark, 0);
zeroHighBob.end();
}));
}));