Skip to content

Commit 0c2edd2

Browse files
Sebastian Plesciucrefack
Sebastian Plesciuc
authored andcommitted
test: fixed flaky test-net-connect-local-error
Fixed test-net-connect-local-error by moving the test from parallel to sequential. PR-URL: #12964 Fixes: #12950 Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Rich Trott <[email protected]>
1 parent 0083011 commit 0c2edd2

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

test/parallel/test-net-connect-local-error.js test/sequential/test-net-connect-local-error.js

+11-8
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,28 @@ const common = require('../common');
33
const assert = require('assert');
44
const net = require('net');
55

6-
const server = net.createServer();
7-
server.listen(0);
8-
const port = server.address().port;
96
const client = net.connect({
10-
port: port + 1,
11-
localPort: port,
7+
port: common.PORT + 1,
8+
localPort: common.PORT,
129
localAddress: common.localhostIPv4
1310
});
1411

1512
client.on('error', common.mustCall(function onError(err) {
13+
assert.strictEqual(err.syscall, 'connect');
14+
assert.strictEqual(err.code, 'ECONNREFUSED');
1615
assert.strictEqual(
1716
err.localPort,
18-
port,
19-
`${err.localPort} !== ${port} in ${err}`
17+
common.PORT,
18+
`${err.localPort} !== ${common.PORT} in ${err}`
2019
);
2120
assert.strictEqual(
2221
err.localAddress,
2322
common.localhostIPv4,
2423
`${err.localAddress} !== ${common.localhostIPv4} in ${err}`
2524
);
25+
assert.strictEqual(
26+
err.message,
27+
`connect ECONNREFUSED ${err.address}:${err.port} ` +
28+
`- Local (${err.localAddress}:${err.localPort})`
29+
);
2630
}));
27-
server.close();

0 commit comments

Comments
 (0)