From 9a01cf3cacbf4a18cf1ff7269f0459f49a12e855 Mon Sep 17 00:00:00 2001 From: Devon Rifkin Date: Thu, 1 Dec 2016 09:49:49 -0600 Subject: [PATCH 1/2] test: refactor test-tls-timeout-server-2 * Use `common.mustCall` for all callbacks * Use `const` instead of `var` --- test/parallel/test-tls-timeout-server-2.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/test/parallel/test-tls-timeout-server-2.js b/test/parallel/test-tls-timeout-server-2.js index a054f41f623455..7a70c947e35c9d 100644 --- a/test/parallel/test-tls-timeout-server-2.js +++ b/test/parallel/test-tls-timeout-server-2.js @@ -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, common.mustCall(function() { cleartext.destroy(); server.close(); - }); + })); assert.ok(s instanceof tls.TLSSocket); -}); +})); -server.listen(0, function() { +server.listen(0, common.mustCall(function() { tls.connect({ host: '127.0.0.1', port: this.address().port, rejectUnauthorized: false }); -}); +})); From 8b7762919b776d9dd061f8efe633da8d98f1cc09 Mon Sep 17 00:00:00 2001 From: Devon Rifkin Date: Sat, 3 Dec 2016 22:22:34 -0800 Subject: [PATCH 2/2] fixup for github comments MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The `common.mustCall` isn’t necessary, since the test will fail from timing out if the callback is never called. --- test/parallel/test-tls-timeout-server-2.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/parallel/test-tls-timeout-server-2.js b/test/parallel/test-tls-timeout-server-2.js index 7a70c947e35c9d..1613e9fc4e06d6 100644 --- a/test/parallel/test-tls-timeout-server-2.js +++ b/test/parallel/test-tls-timeout-server-2.js @@ -16,10 +16,10 @@ const options = { }; const server = tls.createServer(options, common.mustCall(function(cleartext) { - const s = cleartext.setTimeout(50, common.mustCall(function() { + const s = cleartext.setTimeout(50, function() { cleartext.destroy(); server.close(); - })); + }); assert.ok(s instanceof tls.TLSSocket); }));