Skip to content

Commit ab7c2a0

Browse files
committed
test: improve the code in tls tests
Replaces var for const for include modules and implement missing common.mustCall for some anonymous functions
1 parent 8264a22 commit ab7c2a0

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
'use strict';
2-
var common = require('../common');
3-
var assert = require('assert');
2+
const common = require('../common');
3+
const assert = require('assert');
44

55
if (!common.hasCrypto) {
66
common.skip('missing crypto');
77
return;
88
}
9-
var tls = require('tls');
9+
const tls = require('tls');
1010

11-
var fs = require('fs');
11+
const fs = require('fs');
1212

13-
var key = fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem');
14-
var cert = fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem');
13+
const key = fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem');
14+
const cert = fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem');
1515

16-
tls.createServer({ key: key, cert: cert }, function(conn) {
16+
tls.createServer({ key: key, cert: cert }, common.mustCall(function(conn) {
1717
conn.end();
1818
this.close();
19-
}).listen(0, function() {
19+
})).listen(0, common.mustCall(function() {
2020
var options = { port: this.address().port, rejectUnauthorized: true };
2121
tls.connect(options).on('error', common.mustCall(function(err) {
22-
assert.equal(err.code, 'UNABLE_TO_VERIFY_LEAF_SIGNATURE');
23-
assert.equal(err.message, 'unable to verify the first certificate');
22+
assert.strictEqual(err.code, 'UNABLE_TO_VERIFY_LEAF_SIGNATURE');
23+
assert.strictEqual(err.message, 'unable to verify the first certificate');
2424
this.destroy();
2525
}));
26-
});
26+
}));

0 commit comments

Comments
 (0)