From d081032a6034f43014084c2fd0b0c3c095f4ea75 Mon Sep 17 00:00:00 2001 From: Vita Batrla <34657903+batrla@users.noreply.github.com> Date: Sat, 25 Feb 2023 19:53:11 +0100 Subject: [PATCH] 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 Reviewed-By: Richard Lau Reviewed-By: Luigi Pinca --- test/parallel/parallel.status | 4 ---- .../test-net-connect-reset-until-connected.js | 11 ++++++++++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/test/parallel/parallel.status b/test/parallel/parallel.status index 4bcb1e77edbb7c..89f6e830ddbf76 100644 --- a/test/parallel/parallel.status +++ b/test/parallel/parallel.status @@ -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 @@ -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] diff --git a/test/parallel/test-net-connect-reset-until-connected.js b/test/parallel/test-net-connect-reset-until-connected.js index e40ec05f6ce1e9..9c2493eaaf0598 100644 --- a/test/parallel/test-net-connect-reset-until-connected.js +++ b/test/parallel/test-net-connect-reset-until-connected.js @@ -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); }));