From 395cc885f4eb21c2002dbfe405d31da275699aa8 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Fri, 13 May 2016 23:01:25 -0700 Subject: [PATCH] test: refactor test-tls-reuse-host-from-socket Replace booleans with `common.mustCall()`, migrate from `var` to `const`, and apply minor formatting changes. PR-URL: https://github.com/nodejs/node/pull/6756 Reviewed-By: Fedor Indutny Reviewed-By: Santiago Gimeno Reviewed-By: James M Snell --- .../test-tls-reuse-host-from-socket.js | 26 ++++++------------- 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/test/internet/test-tls-reuse-host-from-socket.js b/test/internet/test-tls-reuse-host-from-socket.js index 8c438f573c21d7..22af92e2769715 100644 --- a/test/internet/test-tls-reuse-host-from-socket.js +++ b/test/internet/test-tls-reuse-host-from-socket.js @@ -1,27 +1,17 @@ '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'); +const tls = require('tls'); -var net = require('net'); -var connected = false; -var secure = false; +const net = require('net'); -process.on('exit', function() { - assert(connected); - assert(secure); - console.log('ok'); -}); - -var socket = net.connect(443, 'www.google.com', function() { - connected = true; - var secureSocket = tls.connect({ socket: socket }, function() { - secure = true; +const socket = net.connect(443, 'www.example.org', common.mustCall(() => { + const secureSocket = tls.connect({socket: socket}, common.mustCall(() => { secureSocket.destroy(); - }); -}); + console.log('ok'); + })); +}));