From 87be4e3c800e0c34d5f956ba54e8b97382ffb2ab Mon Sep 17 00:00:00 2001 From: Brian Chirgwin Date: Thu, 1 Dec 2016 11:10:28 -0600 Subject: [PATCH] test: refactor test-tls-interleave var -> let / const added common.mustCall() to callback assert.equal() -> assert.strictEqual() PR-URL: https://github.com/nodejs/node/pull/10017 Reviewed-By: Colin Ihrig --- test/parallel/test-tls-interleave.js | 34 +++++++++++++++------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/test/parallel/test-tls-interleave.js b/test/parallel/test-tls-interleave.js index d03ed249d53253..9cccee82506005 100644 --- a/test/parallel/test-tls-interleave.js +++ b/test/parallel/test-tls-interleave.js @@ -1,37 +1,38 @@ '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 assert = require('assert'); -var fs = require('fs'); +const tls = require('tls'); -var dir = common.fixturesDir; -var options = { key: fs.readFileSync(dir + '/test_key.pem'), - cert: fs.readFileSync(dir + '/test_cert.pem'), - ca: [ fs.readFileSync(dir + '/test_ca.pem') ] }; +const fs = require('fs'); -var writes = [ +const dir = common.fixturesDir; +const options = { key: fs.readFileSync(dir + '/test_key.pem'), + cert: fs.readFileSync(dir + '/test_cert.pem'), + ca: [ fs.readFileSync(dir + '/test_ca.pem') ] }; + +const writes = [ 'some server data', 'and a separate packet', 'and one more', ]; -var receivedWrites = 0; +let receivedWrites = 0; -var server = tls.createServer(options, function(c) { +const server = tls.createServer(options, function(c) { writes.forEach(function(str) { c.write(str); }); -}).listen(0, function() { +}).listen(0, common.mustCall(function() { const connectOpts = { rejectUnauthorized: false }; - var c = tls.connect(this.address().port, connectOpts, function() { + const c = tls.connect(this.address().port, connectOpts, function() { c.write('some client data'); c.on('readable', function() { - var data = c.read(); + let data = c.read(); if (data === null) return; @@ -47,8 +48,9 @@ var server = tls.createServer(options, function(c) { } }); }); -}); +})); + process.on('exit', function() { - assert.equal(receivedWrites, writes.length); + assert.strictEqual(receivedWrites, writes.length); });