From 2ec45fa4aa825319f8185d3a41584d5f238466af Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Wed, 23 Dec 2015 00:58:14 -0800 Subject: [PATCH 1/2] test: refactor test-net-connect-options-ipv6 Remove unused variable and refactor checking for event firing. --- .../parallel/test-net-connect-options-ipv6.js | 20 +++---------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/test/parallel/test-net-connect-options-ipv6.js b/test/parallel/test-net-connect-options-ipv6.js index 623b2eff1ddded..b52be4d2fe7501 100644 --- a/test/parallel/test-net-connect-options-ipv6.js +++ b/test/parallel/test-net-connect-options-ipv6.js @@ -2,16 +2,12 @@ const common = require('../common'); const assert = require('assert'); const net = require('net'); -const dns = require('dns'); if (!common.hasIPv6) { console.log('1..0 # Skipped: no IPv6 support'); return; } -var serverGotEnd = false; -var clientGotEnd = false; - const hosts = common.localIPv6Hosts; var hostIdx = 0; var host = hosts[hostIdx]; @@ -19,9 +15,7 @@ var localhostTries = 10; const server = net.createServer({allowHalfOpen: true}, function(socket) { socket.resume(); - socket.on('end', function() { - serverGotEnd = true; - }); + socket.on('end', common.mustCall(function() {})); socket.end(); }); @@ -36,13 +30,12 @@ function tryConnect() { }, function() { console.error('client connect cb'); client.resume(); - client.on('end', function() { - clientGotEnd = true; + client.on('end', common.mustCall(function() { setTimeout(function() { assert(client.writable); client.end(); }, 10); - }); + })); client.on('close', function() { server.close(); }); @@ -62,10 +55,3 @@ function tryConnect() { throw err; }); } - -process.on('exit', onExit); -function onExit() { - console.error('exit', serverGotEnd, clientGotEnd); - assert(serverGotEnd); - assert(clientGotEnd); -} From f4d71dbf2024cc4f03561ab280a14bac3d8d9671 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Fri, 25 Dec 2015 08:14:09 -0800 Subject: [PATCH 2/2] fixup: do not remove listener because we are no longer adding it --- test/parallel/test-net-connect-options-ipv6.js | 1 - 1 file changed, 1 deletion(-) diff --git a/test/parallel/test-net-connect-options-ipv6.js b/test/parallel/test-net-connect-options-ipv6.js index b52be4d2fe7501..8b11612a1286f2 100644 --- a/test/parallel/test-net-connect-options-ipv6.js +++ b/test/parallel/test-net-connect-options-ipv6.js @@ -47,7 +47,6 @@ function tryConnect() { tryConnect(); else { console.log('1..0 # Skipped: no IPv6 localhost support'); - process.removeListener('exit', onExit); server.close(); } return;