From fc67a955e26e7dfdb347f98fa5d72952091afdc6 Mon Sep 17 00:00:00 2001 From: Outsider Date: Thu, 1 Dec 2016 10:31:42 -0600 Subject: [PATCH] test: use const/let and common.mustCall remove process.on('exit') because all callbacks are wrapped by common.mustCall. PR-URL: https://github.com/nodejs/node/pull/9959 Reviewed-By: Colin Ihrig Reviewed-By: James M Snell Reviewed-By: Roman Reiss --- test/parallel/test-tls-cnnic-whitelist.js | 36 ++++++++++------------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/test/parallel/test-tls-cnnic-whitelist.js b/test/parallel/test-tls-cnnic-whitelist.js index f16698c736be39..c2b9c0849296bc 100644 --- a/test/parallel/test-tls-cnnic-whitelist.js +++ b/test/parallel/test-tls-cnnic-whitelist.js @@ -1,16 +1,15 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); +const common = require('../common'); if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var tls = require('tls'); -var fs = require('fs'); -var path = require('path'); -var finished = 0; +const assert = require('assert'); +const tls = require('tls'); +const fs = require('fs'); +const path = require('path'); function filenamePEM(n) { return path.join(common.fixturesDir, 'keys', n + '.pem'); @@ -20,7 +19,7 @@ function loadPEM(n) { return fs.readFileSync(filenamePEM(n)); } -var testCases = [ +const testCases = [ { // Test 0: for the check of a cert not existed in the whitelist. // agent7-cert.pem is issued by the fake CNNIC root CA so that its // hash is not listed in the whitelist. @@ -58,27 +57,22 @@ var testCases = [ ]; function runTest(tindex) { - var tcase = testCases[tindex]; + const tcase = testCases[tindex]; if (!tcase) return; - var server = tls.createServer(tcase.serverOpts, function(s) { + const server = tls.createServer(tcase.serverOpts, (s) => { s.resume(); - }).listen(0, function() { + }).listen(0, common.mustCall(function() { tcase.clientOpts = this.address().port; - var client = tls.connect(tcase.clientOpts); - client.on('error', function(e) { + const client = tls.connect(tcase.clientOpts); + client.on('error', common.mustCall((e) => { assert.strictEqual(e.code, tcase.errorCode); - server.close(function() { - finished++; + server.close(common.mustCall(() => { runTest(tindex + 1); - }); - }); - }); + })); + })); + })); } runTest(0); - -process.on('exit', function() { - assert.equal(finished, testCases.length); -});