From 66e0f79668e3633fe20b4ffb3afb60a6a6a736e1 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Mon, 11 Jan 2016 22:19:40 -0800 Subject: [PATCH] test: fix flaky test-net-socket-local-address The close event can fire twice if close is called twice. Move checks to exit event for process instead. Ref: https://github.com/nodejs/node/pull/4476 --- test/parallel/test-net-socket-local-address.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/parallel/test-net-socket-local-address.js b/test/parallel/test-net-socket-local-address.js index 7e90bd2f79ba47..28c27891af7951 100644 --- a/test/parallel/test-net-socket-local-address.js +++ b/test/parallel/test-net-socket-local-address.js @@ -20,12 +20,6 @@ const server = net.createServer(function(socket) { const client = new net.Socket(); -server.on('close', common.mustCall(function() { - assert.deepEqual(clientLocalPorts, serverRemotePorts, - 'client and server should agree on the ports used'); - assert.equal(2, conns); -})); - server.listen(common.PORT, common.localhostIPv4, testConnect); function testConnect() { @@ -44,3 +38,9 @@ function testConnect() { }); conns++; } + +process.on('exit', function() { + assert.deepEqual(clientLocalPorts, serverRemotePorts, + 'client and server should agree on the ports used'); + assert.equal(2, conns); +});