Skip to content

Commit

Permalink
test: fix test-net-connect-reset-until-connected
Browse files Browse the repository at this point in the history
Fixes: #43446
PR-URL: #46781
Reviewed-By: theanarkh <theratliter@gmail.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
  • Loading branch information
batrla authored and BethGriggs committed Mar 27, 2023
1 parent 086bb2f commit d081032
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
4 changes: 0 additions & 4 deletions test/parallel/parallel.status
Expand Up @@ -34,8 +34,6 @@ test-crypto-dh-stateless: SKIP
test-crypto-keygen: SKIP

[$system==solaris] # Also applies to SmartOS
# https://github.com/nodejs/node/issues/43446
test-net-connect-reset-until-connected: PASS, FLAKY
# https://github.com/nodejs/node/issues/43457
test-domain-no-error-handler-abort-on-uncaught-0: PASS, FLAKY
test-domain-no-error-handler-abort-on-uncaught-1: PASS,FLAKY
Expand All @@ -55,8 +53,6 @@ test-domain-with-abort-on-uncaught-exception: PASS, FLAKY
test-fs-stat-bigint: PASS,FLAKY
# https://github.com/nodejs/node/issues/31280
test-worker-message-port-message-before-close: PASS,FLAKY
# https://github.com/nodejs/node/issues/43446
test-net-connect-reset-until-connected: PASS, FLAKY

[$system==aix]

Expand Down
11 changes: 10 additions & 1 deletion test/parallel/test-net-connect-reset-until-connected.js
Expand Up @@ -3,18 +3,27 @@
const common = require('../common');
const net = require('net');

function barrier(count, cb) {
return function() {
if (--count === 0)
cb();
};
}

const server = net.createServer();
server.listen(0, common.mustCall(function() {
const port = server.address().port;
const conn = net.createConnection(port);
const connok = barrier(2, () => conn.resetAndDestroy());
conn.on('close', common.mustCall());
server.on('connection', (socket) => {
connok();
socket.on('error', common.expectsError({
code: 'ECONNRESET',
message: 'read ECONNRESET',
name: 'Error'
}));
server.close();
});
conn.resetAndDestroy();
conn.on('connect', connok);
}));

0 comments on commit d081032

Please sign in to comment.