Skip to content

Commit

Permalink
test: use common.mustCall(), and log the events
Browse files Browse the repository at this point in the history
PR-URL: #25508
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
sam-github authored and addaleax committed Feb 7, 2019
1 parent 1b542e8 commit 50d2c8e
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions test/parallel/test-tls-set-encoding.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const messageUtf8 = 'x√ab c';
const messageAscii = 'xb\b\u001aab c';

const server = tls.Server(options, common.mustCall(function(socket) {
console.log('server: on secureConnection', socket.getProtocol());
socket.end(messageUtf8);
}));

Expand All @@ -55,12 +56,18 @@ server.listen(0, function() {
client.setEncoding('ascii');

client.on('data', function(d) {
console.log('client: on data', d);
assert.ok(typeof d === 'string');
buffer += d;
});

client.on('secureConnect', common.mustCall(() => {
console.log('client: on secureConnect');
}));

client.on('close', common.mustCall(function() {
console.log('client: on close');

client.on('close', function() {
// readyState is deprecated but we want to make
// sure this isn't triggering an assert in lib/net.js
// See https://github.com/nodejs/node-v0.x-archive/issues/1069.
Expand All @@ -75,5 +82,5 @@ server.listen(0, function() {
assert.strictEqual(messageAscii, buffer);

server.close();
});
}));
});

0 comments on commit 50d2c8e

Please sign in to comment.