• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2
3const common = require('../common');
4if (!common.hasCrypto)
5  common.skip('missing crypto');
6
7const assert = require('assert');
8const tls = require('tls');
9const fixtures = require('../common/fixtures');
10
11const pem = (n) => fixtures.readKey(`${n}.pem`);
12
13let clients = 0;
14
15const server = tls.createServer({
16  key: pem('agent1-key'),
17  cert: pem('agent1-cert')
18}, common.mustCall(() => {
19  if (--clients === 0)
20    server.close();
21}, 3));
22
23server.listen(0, common.mustCall(() => {
24  clients++;
25  const highBob = tls.connect({
26    port: server.address().port,
27    rejectUnauthorized: false,
28    highWaterMark: 128000,
29  }, common.mustCall(() => {
30    assert.strictEqual(highBob.readableHighWaterMark, 128000);
31    highBob.end();
32  }));
33
34  clients++;
35  const defaultHighBob = tls.connect({
36    port: server.address().port,
37    rejectUnauthorized: false,
38    highWaterMark: undefined,
39  }, common.mustCall(() => {
40    assert.strictEqual(defaultHighBob.readableHighWaterMark, 16 * 1024);
41    defaultHighBob.end();
42  }));
43
44  clients++;
45  const zeroHighBob = tls.connect({
46    port: server.address().port,
47    rejectUnauthorized: false,
48    highWaterMark: 0,
49  }, common.mustCall(() => {
50    assert.strictEqual(zeroHighBob.readableHighWaterMark, 0);
51    zeroHighBob.end();
52  }));
53}));
54