11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ci
31cb0ef41Sopenharmony_ciconst common = require('../common');
41cb0ef41Sopenharmony_ciif (!common.hasCrypto)
51cb0ef41Sopenharmony_ci  common.skip('missing crypto');
61cb0ef41Sopenharmony_ci
71cb0ef41Sopenharmony_ciconst assert = require('assert');
81cb0ef41Sopenharmony_ciconst tls = require('tls');
91cb0ef41Sopenharmony_ciconst fixtures = require('../common/fixtures');
101cb0ef41Sopenharmony_ci
111cb0ef41Sopenharmony_ciconst pem = (n) => fixtures.readKey(`${n}.pem`);
121cb0ef41Sopenharmony_ci
131cb0ef41Sopenharmony_cilet clients = 0;
141cb0ef41Sopenharmony_ci
151cb0ef41Sopenharmony_ciconst server = tls.createServer({
161cb0ef41Sopenharmony_ci  key: pem('agent1-key'),
171cb0ef41Sopenharmony_ci  cert: pem('agent1-cert')
181cb0ef41Sopenharmony_ci}, common.mustCall(() => {
191cb0ef41Sopenharmony_ci  if (--clients === 0)
201cb0ef41Sopenharmony_ci    server.close();
211cb0ef41Sopenharmony_ci}, 3));
221cb0ef41Sopenharmony_ci
231cb0ef41Sopenharmony_ciserver.listen(0, common.mustCall(() => {
241cb0ef41Sopenharmony_ci  clients++;
251cb0ef41Sopenharmony_ci  const highBob = tls.connect({
261cb0ef41Sopenharmony_ci    port: server.address().port,
271cb0ef41Sopenharmony_ci    rejectUnauthorized: false,
281cb0ef41Sopenharmony_ci    highWaterMark: 128000,
291cb0ef41Sopenharmony_ci  }, common.mustCall(() => {
301cb0ef41Sopenharmony_ci    assert.strictEqual(highBob.readableHighWaterMark, 128000);
311cb0ef41Sopenharmony_ci    highBob.end();
321cb0ef41Sopenharmony_ci  }));
331cb0ef41Sopenharmony_ci
341cb0ef41Sopenharmony_ci  clients++;
351cb0ef41Sopenharmony_ci  const defaultHighBob = tls.connect({
361cb0ef41Sopenharmony_ci    port: server.address().port,
371cb0ef41Sopenharmony_ci    rejectUnauthorized: false,
381cb0ef41Sopenharmony_ci    highWaterMark: undefined,
391cb0ef41Sopenharmony_ci  }, common.mustCall(() => {
401cb0ef41Sopenharmony_ci    assert.strictEqual(defaultHighBob.readableHighWaterMark, 16 * 1024);
411cb0ef41Sopenharmony_ci    defaultHighBob.end();
421cb0ef41Sopenharmony_ci  }));
431cb0ef41Sopenharmony_ci
441cb0ef41Sopenharmony_ci  clients++;
451cb0ef41Sopenharmony_ci  const zeroHighBob = tls.connect({
461cb0ef41Sopenharmony_ci    port: server.address().port,
471cb0ef41Sopenharmony_ci    rejectUnauthorized: false,
481cb0ef41Sopenharmony_ci    highWaterMark: 0,
491cb0ef41Sopenharmony_ci  }, common.mustCall(() => {
501cb0ef41Sopenharmony_ci    assert.strictEqual(zeroHighBob.readableHighWaterMark, 0);
511cb0ef41Sopenharmony_ci    zeroHighBob.end();
521cb0ef41Sopenharmony_ci  }));
531cb0ef41Sopenharmony_ci}));
54