From 3429c90f42c00ba3657f7c8d288843c5062a4bb5 Mon Sep 17 00:00:00 2001 From: Sebastian Plesciuc Date: Mon, 22 May 2017 03:45:00 -0400 Subject: [PATCH] test: fix sequential test-net-connect-local-error Fixed sequential test-net-connect-local-error by swapping port and localPort in net.connect options. PR-URL: https://github.com/nodejs/node/pull/13064 Fixes: https://github.com/nodejs/node/issues/13055 Reviewed-By: Refael Ackermann Reviewed-By: Colin Ihrig Reviewed-By: Santiago Gimeno --- .../test-net-connect-local-error.js | 23 ++++++++----------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/test/sequential/test-net-connect-local-error.js b/test/sequential/test-net-connect-local-error.js index 531a721a88..205ff872cd 100644 --- a/test/sequential/test-net-connect-local-error.js +++ b/test/sequential/test-net-connect-local-error.js @@ -3,28 +3,23 @@ const common = require('../common'); const assert = require('assert'); const net = require('net'); +// EADDRINUSE is expected to occur on FreeBSD +// Ref: https://github.com/nodejs/node/issues/13055 +const expectedErrorCodes = ['ECONNREFUSED', 'EADDRINUSE']; const client = net.connect({ - port: common.PORT + 1, - localPort: common.PORT, + port: common.PORT, + localPort: common.PORT + 1, localAddress: common.localhostIPv4 }); client.on('error', common.mustCall(function onError(err) { + assert.ok(expectedErrorCodes.includes(err.code)); assert.strictEqual(err.syscall, 'connect'); - assert.strictEqual(err.code, 'ECONNREFUSED'); - assert.strictEqual( - err.localPort, - common.PORT, - `${err.localPort} !== ${common.PORT} in ${err}` - ); - assert.strictEqual( - err.localAddress, - common.localhostIPv4, - `${err.localAddress} !== ${common.localhostIPv4} in ${err}` - ); + assert.strictEqual(err.localPort, common.PORT + 1); + assert.strictEqual(err.localAddress, common.localhostIPv4); assert.strictEqual( err.message, - `connect ECONNREFUSED ${err.address}:${err.port} ` + + `connect ${err.code} ${err.address}:${err.port} ` + `- Local (${err.localAddress}:${err.localPort})` ); }));