Skip to content

Commit 8c8b123

Browse files
outsiderisitaloacasas
authored andcommitted
test: use const/let and common.mustCall
remove process.on('exit') because all callbacks are wrapped by common.mustCall. PR-URL: #9959 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Roman Reiss <[email protected]>
1 parent 74563f0 commit 8c8b123

File tree

1 file changed

+15
-21
lines changed

1 file changed

+15
-21
lines changed

test/parallel/test-tls-cnnic-whitelist.js

+15-21
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
'use strict';
2-
var common = require('../common');
3-
var assert = require('assert');
2+
const common = require('../common');
43

54
if (!common.hasCrypto) {
65
common.skip('missing crypto');
76
return;
87
}
98

10-
var tls = require('tls');
11-
var fs = require('fs');
12-
var path = require('path');
13-
var finished = 0;
9+
const assert = require('assert');
10+
const tls = require('tls');
11+
const fs = require('fs');
12+
const path = require('path');
1413

1514
function filenamePEM(n) {
1615
return path.join(common.fixturesDir, 'keys', n + '.pem');
@@ -20,7 +19,7 @@ function loadPEM(n) {
2019
return fs.readFileSync(filenamePEM(n));
2120
}
2221

23-
var testCases = [
22+
const testCases = [
2423
{ // Test 0: for the check of a cert not existed in the whitelist.
2524
// agent7-cert.pem is issued by the fake CNNIC root CA so that its
2625
// hash is not listed in the whitelist.
@@ -58,27 +57,22 @@ var testCases = [
5857
];
5958

6059
function runTest(tindex) {
61-
var tcase = testCases[tindex];
60+
const tcase = testCases[tindex];
6261

6362
if (!tcase) return;
6463

65-
var server = tls.createServer(tcase.serverOpts, function(s) {
64+
const server = tls.createServer(tcase.serverOpts, (s) => {
6665
s.resume();
67-
}).listen(0, function() {
66+
}).listen(0, common.mustCall(function() {
6867
tcase.clientOpts = this.address().port;
69-
var client = tls.connect(tcase.clientOpts);
70-
client.on('error', function(e) {
68+
const client = tls.connect(tcase.clientOpts);
69+
client.on('error', common.mustCall((e) => {
7170
assert.strictEqual(e.code, tcase.errorCode);
72-
server.close(function() {
73-
finished++;
71+
server.close(common.mustCall(() => {
7472
runTest(tindex + 1);
75-
});
76-
});
77-
});
73+
}));
74+
}));
75+
}));
7876
}
7977

8078
runTest(0);
81-
82-
process.on('exit', function() {
83-
assert.equal(finished, testCases.length);
84-
});

0 commit comments

Comments
 (0)