Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 15 additions & 13 deletions test/parallel/test-tls-pause.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');

// This test ensures that the data received over tls-server after pause
// is same as what it was sent

const assert = require('assert');
const tls = require('tls');
const fixtures = require('../common/fixtures');
Expand All @@ -37,24 +40,23 @@ const bufSize = 1024 * 1024;
let sent = 0;
let received = 0;

const server = tls.Server(options, function(socket) {
const server = tls.Server(options, common.mustCall((socket) => {
socket.pipe(socket);
socket.on('data', function(c) {
socket.on('data', (c) => {
console.error('data', c.length);
});
});
}));

server.listen(0, function() {
server.listen(0, common.mustCall(() => {
let resumed = false;
const client = tls.connect({
port: this.address().port,
port: server.address().port,
rejectUnauthorized: false
}, function() {
}, common.mustCall(() => {
console.error('connected');
client.pause();
console.error('paused');
send();
function send() {
const send = (() => {
console.error('sending');
const ret = client.write(Buffer.allocUnsafe(bufSize));
console.error(`write => ${ret}`);
Expand All @@ -69,9 +71,9 @@ server.listen(0, function() {
resumed = true;
client.resume();
console.error('resumed', client);
}
});
client.on('data', function(data) {
})();
}));
client.on('data', (data) => {
console.error('data');
assert.ok(resumed);
received += data.length;
Expand All @@ -83,8 +85,8 @@ server.listen(0, function() {
server.close();
}
});
});
}));

process.on('exit', function() {
process.on('exit', () => {
assert.strictEqual(sent, received);
});