Skip to content

Commit

Permalink
test: fix sequential test-net-connect-local-error
Browse files Browse the repository at this point in the history
Fixed sequential test-net-connect-local-error by swapping port
and localPort in net.connect options.

PR-URL: #13064
Fixes: #13055
Reviewed-By: Refael Ackermann <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Santiago Gimeno <[email protected]>
  • Loading branch information
Sebastian Plesciuc authored and jasnell committed May 23, 2017
1 parent 1acd4d2 commit e6c03c7
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions test/sequential/test-net-connect-local-error.js
Original file line number Diff line number Diff line change
Expand Up @@ -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})`
);
}));

0 comments on commit e6c03c7

Please sign in to comment.