Skip to content
Closed
Changes from 2 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
20 changes: 11 additions & 9 deletions test/parallel/test-tls-delayed-attach.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');

// Checks tls connection delay while sending and recieving data
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about this?

// This test tries to confirm that a TLS Socket will work as expected even if it
// is created after the original socket has received some data.
//
// Ref: https://github.com/nodejs/node-v0.x-archive/issues/6940
// Ref: https://github.com/nodejs/node-v0.x-archive/pull/6950


const fixtures = require('../common/fixtures');
const assert = require('assert');
const tls = require('tls');
Expand All @@ -37,30 +39,30 @@ const options = {
cert: fixtures.readKey('agent1-cert.pem')
};

const server = net.createServer(function(c) {
const server = net.createServer(common.mustCall((c) => {
setTimeout(function() {
const s = new tls.TLSSocket(c, {
isServer: true,
secureContext: tls.createSecureContext(options)
});

s.on('data', function(chunk) {
s.on('data', (chunk) => {
received += chunk;
});

s.on('end', function() {
s.on('end', common.mustCall(() => {
server.close();
s.destroy();
});
}));
}, 200);
}).listen(0, function() {
const c = tls.connect(this.address().port, {
})).listen(0, common.mustCall(() => {
const c = tls.connect(server.address().port, {
rejectUnauthorized: false
}, function() {
}, () => {
c.end(sent);
});
});
}));

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