From 8ab73d79972de21db6eaf890c58d1da3921b8a66 Mon Sep 17 00:00:00 2001 From: Sebastian Plesciuc Date: Mon, 15 May 2017 20:19:43 +0300 Subject: [PATCH] test: fixed flaky test-net-connect-local-error Fixed test-net-connect-local-error by moving the test from parallel to sequential. Fixes: https://github.com/nodejs/node/issues/12950 --- .../test-net-connect-local-error.js | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) rename test/{parallel => sequential}/test-net-connect-local-error.js (53%) diff --git a/test/parallel/test-net-connect-local-error.js b/test/sequential/test-net-connect-local-error.js similarity index 53% rename from test/parallel/test-net-connect-local-error.js rename to test/sequential/test-net-connect-local-error.js index e656b6cb2ac0ab..9a8fd5bdee28f9 100644 --- a/test/parallel/test-net-connect-local-error.js +++ b/test/sequential/test-net-connect-local-error.js @@ -3,25 +3,28 @@ const common = require('../common'); const assert = require('assert'); const net = require('net'); -const server = net.createServer(); -server.listen(0); -const port = server.address().port; const client = net.connect({ - port: port + 1, - localPort: port, + port: common.PORT + 1, + localPort: common.PORT, localAddress: common.localhostIPv4 }); client.on('error', common.mustCall(function onError(err) { + assert.strictEqual(err.syscall, 'connect'); + assert.strictEqual(err.code, 'ECONNREFUSED'); assert.strictEqual( err.localPort, - port, - `${err.localPort} !== ${port} in ${err}` + common.PORT, + `${err.localPort} !== ${common.PORT} in ${err}` ); assert.strictEqual( err.localAddress, common.localhostIPv4, `${err.localAddress} !== ${common.localhostIPv4} in ${err}` ); -})); -server.close(); + assert.strictEqual( + err.message, + `connect ECONNREFUSED ${err.address}:${err.port} ` + + `- Local (${err.localAddress}:${err.localPort})` + ); +})); \ No newline at end of file