mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
3429c90f42
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 <refack@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
26 lines
824 B
JavaScript
26 lines
824 B
JavaScript
'use strict';
|
|
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,
|
|
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.localPort, common.PORT + 1);
|
|
assert.strictEqual(err.localAddress, common.localhostIPv4);
|
|
assert.strictEqual(
|
|
err.message,
|
|
`connect ${err.code} ${err.address}:${err.port} ` +
|
|
`- Local (${err.localAddress}:${err.localPort})`
|
|
);
|
|
}));
|