Skip to content

Commit 8c8b123

Browse files
outsiderisItalo A. Casas
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‎

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
'use strict';
2-
varcommon=require('../common');
3-
varassert=require('assert');
2+
constcommon=require('../common');
43

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

10-
vartls=require('tls');
11-
varfs=require('fs');
12-
varpath=require('path');
13-
varfinished=0;
9+
constassert=require('assert');
10+
consttls=require('tls');
11+
constfs=require('fs');
12+
constpath=require('path');
1413

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

23-
vartestCases=[
22+
consttestCases=[
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
functionrunTest(tindex){
61-
vartcase=testCases[tindex];
60+
consttcase=testCases[tindex];
6261

6362
if(!tcase)return;
6463

65-
varserver=tls.createServer(tcase.serverOpts,function(s){
64+
constserver=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-
varclient=tls.connect(tcase.clientOpts);
70-
client.on('error',function(e){
68+
constclient=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)