From 0a4fc64c3f23154fc8a8d28147ee16d168dae01f Mon Sep 17 00:00:00 2001 From: Danny Guo Date: Thu, 1 Dec 2016 10:41:38 -0600 Subject: [PATCH] test: clean up tls junk test PR-URL: https://github.com/nodejs/node/pull/9940 Reviewed-By: James M Snell --- test/parallel/test-tls-junk-closes-server.js | 30 +++++++++----------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/test/parallel/test-tls-junk-closes-server.js b/test/parallel/test-tls-junk-closes-server.js index f12393515cbe47..38f90498f84e92 100644 --- a/test/parallel/test-tls-junk-closes-server.js +++ b/test/parallel/test-tls-junk-closes-server.js @@ -1,34 +1,30 @@ 'use strict'; -var common = require('../common'); +const common = require('../common'); if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var tls = require('tls'); -var fs = require('fs'); -var net = require('net'); +const tls = require('tls'); +const fs = require('fs'); +const net = require('net'); -var options = { +const options = { key: fs.readFileSync(common.fixturesDir + '/keys/agent2-key.pem'), cert: fs.readFileSync(common.fixturesDir + '/keys/agent2-cert.pem') }; -var server = tls.createServer(options, function(s) { - s.write('welcome!\n'); - s.pipe(s); -}); +const server = tls.createServer(options, common.fail); -server.listen(0, function() { - var c = net.createConnection(this.address().port); +server.listen(0, common.mustCall(function() { + const c = net.createConnection(this.address().port); - c.on('connect', function() { + c.on('connect', common.mustCall(function() { c.write('blah\nblah\nblah\n'); - }); + })); - c.on('end', function() { + c.on('end', common.mustCall(function() { server.close(); - }); - -}); + })); +}));