2017-10-05 16:16:20 -04:00
|
|
|
'use strict';
|
|
|
|
const common = require('../common');
|
|
|
|
if (!common.hasCrypto)
|
|
|
|
common.skip('missing crypto');
|
|
|
|
const assert = require('assert');
|
|
|
|
const fixtures = require('../common/fixtures');
|
|
|
|
const tls = require('tls');
|
|
|
|
|
|
|
|
const iter = 10;
|
|
|
|
|
|
|
|
const server = tls.createServer({
|
|
|
|
key: fixtures.readKey('agent2-key.pem'),
|
|
|
|
cert: fixtures.readKey('agent2-cert.pem')
|
|
|
|
}, common.mustCall((socket) => {
|
2017-12-11 17:55:17 -05:00
|
|
|
let str = '';
|
|
|
|
socket.setEncoding('utf-8');
|
|
|
|
socket.on('data', (chunk) => { str += chunk; });
|
2017-10-05 16:16:20 -04:00
|
|
|
|
|
|
|
socket.on('end', common.mustCall(() => {
|
2017-12-11 17:55:17 -05:00
|
|
|
assert.strictEqual(str, 'a'.repeat(iter - 1));
|
2017-10-05 16:16:20 -04:00
|
|
|
server.close();
|
|
|
|
}));
|
|
|
|
}));
|
|
|
|
|
|
|
|
server.listen(0, common.mustCall(() => {
|
|
|
|
const client = tls.connect({
|
|
|
|
port: server.address().port,
|
|
|
|
rejectUnauthorized: false
|
|
|
|
}, common.mustCall(() => {
|
|
|
|
assert.strictEqual(client.bufferSize, 0);
|
|
|
|
|
|
|
|
for (let i = 1; i < iter; i++) {
|
|
|
|
client.write('a');
|
2020-06-27 19:39:04 +02:00
|
|
|
assert.strictEqual(client.bufferSize, i);
|
2017-10-05 16:16:20 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
client.on('finish', common.mustCall(() => {
|
|
|
|
assert.strictEqual(client.bufferSize, 0);
|
|
|
|
}));
|
|
|
|
|
|
|
|
client.end();
|
|
|
|
}));
|
|
|
|
}));
|