From 29009aec96b916b2fdfa09121cdefd214ea3e8f2 Mon Sep 17 00:00:00 2001 From: Leko Date: Sat, 20 Jan 2018 00:26:50 +0900 Subject: [PATCH] test: try to connect after server was closed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/18257 Reviewed-By: Joyee Cheung Reviewed-By: Michaƫl Zasso Reviewed-By: Anatoli Papirovski Reviewed-By: James M Snell Reviewed-By: Ruben Bridgewater --- .../test-net-connect-handle-econnrefused.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/test/parallel/test-net-connect-handle-econnrefused.js b/test/parallel/test-net-connect-handle-econnrefused.js index 569aded7bf5def..3c7310b4752d72 100644 --- a/test/parallel/test-net-connect-handle-econnrefused.js +++ b/test/parallel/test-net-connect-handle-econnrefused.js @@ -27,11 +27,10 @@ const assert = require('assert'); const server = net.createServer(); server.listen(0); const port = server.address().port; -const c = net.createConnection(port); - -c.on('connect', common.mustNotCall()); - -c.on('error', common.mustCall((e) => { - assert.strictEqual('ECONNREFUSED', e.code); +server.close(common.mustCall(() => { + const c = net.createConnection(port); + c.on('connect', common.mustNotCall()); + c.on('error', common.mustCall((e) => { + assert.strictEqual('ECONNREFUSED', e.code); + })); })); -server.close();