test: fix test-net-connect-reset-until-connected

Fixes: https://github.com/nodejs/node/issues/43446
PR-URL: https://github.com/nodejs/node/pull/46781
Reviewed-By: theanarkh <theratliter@gmail.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
Vita Batrla authored and Danielle Adams committed 2023-04-10 20:55:01 -04:00
1 parent 364479644c
commit dfb566aec2
2 files changed
+10 -5

No files matched your search

-4
View File
@@ -31,8 +31,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
@@ -52,8 +50,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==ibmi]
# https://github.com/nodejs/node/pull/30819
@@ -3,12 +3,21 @@
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',
@@ -16,5 +25,5 @@ server.listen(0, common.mustCall(function() {
}));
server.close();
});
conn.resetAndDestroy();
conn.on('connect', connok);
}));