Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: refactor test-tls-timeout-server-2 #9876

Closed
wants to merge 2 commits into from
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
20 changes: 10 additions & 10 deletions test/parallel/test-tls-timeout-server-2.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
'use strict';
var common = require('../common');
var assert = require('assert');
const common = require('../common');
const assert = require('assert');

if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
var tls = require('tls');
const tls = require('tls');

var fs = require('fs');
const fs = require('fs');

var options = {
const options = {
key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'),
cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem')
};

var server = tls.createServer(options, function(cleartext) {
var s = cleartext.setTimeout(50, function() {
const server = tls.createServer(options, common.mustCall(function(cleartext) {
const s = cleartext.setTimeout(50, function() {
cleartext.destroy();
server.close();
});
assert.ok(s instanceof tls.TLSSocket);
});
}));

server.listen(0, function() {
server.listen(0, common.mustCall(function() {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unsure what the convention of using common.mustCall is. This one could be removed and the test would still work as expected, since line 18 also has a common.mustCall.

My instinct is to use common.mustCall as much as possible to avoid any problems in the future as this code is further refactored, but happy to change this based on what other people tend to do.

Copy link
Contributor

Choose a reason for hiding this comment

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

common.mustCall() should be used to ensure that all assertions are executed.

tls.connect({
host: '127.0.0.1',
port: this.address().port,
rejectUnauthorized: false
});
});
}));