Skip to content

Commit

Permalink
test: fixed flaky test-net-connect-local-error
Browse files Browse the repository at this point in the history
Fixed test-net-connect-local-error by moving the test from
parallel to sequential.

PR-URL: #12964
Fixes: #12950
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
  • Loading branch information
Sebastian Plesciuc authored and MylesBorins committed Jul 11, 2017
1 parent 3891759 commit 50bb452
Showing 1 changed file with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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}`
);
assert.strictEqual(
err.message,
`connect ECONNREFUSED ${err.address}:${err.port} ` +
`- Local (${err.localAddress}:${err.localPort})`
);
}));
server.close();

0 comments on commit 50bb452

Please sign in to comment.