From cd17314da283641cd886fd43b030a1dbf147d094 Mon Sep 17 00:00:00 2001 From: treysis Date: Sat, 4 Sep 2021 16:19:51 +0200 Subject: [PATCH] dns: fix test suite part 2 PR-URL: https://github.com/nodejs/node/pull/39987 Fixes: https://github.com/nodejs/node/issues/31566 Refs: https://github.com/nodejs/node/issues/6307 Refs: https://github.com/nodejs/node/pull/20710 Refs: https://github.com/nodejs/node/pull/38099 Reviewed-By: Antoine du Hamel Reviewed-By: Matteo Collina Reviewed-By: James M Snell Reviewed-By: Michael Dawson --- test/parallel/test-http-localaddress.js | 1 + test/parallel/test-http-upgrade-client.js | 2 +- test/parallel/test-http2-connect-options.js | 2 +- test/parallel/test-https-localaddress.js | 1 + test/parallel/test-net-dns-lookup.js | 2 +- test/parallel/test-net-remote-address-port.js | 4 ++-- test/parallel/test-tcp-wrap-listen.js | 2 +- ...-timers-socket-timeout-removes-other-socket-unref-timer.js | 2 +- test/parallel/test-tls-client-getephemeralkeyinfo.js | 2 +- test/parallel/test-tls-client-mindhsize.js | 2 +- test/parallel/test-tls-wrap-econnreset-localaddress.js | 1 + test/pummel/test-http-upload-timeout.js | 2 +- test/pummel/test-net-pingpong.js | 3 ++- test/sequential/test-inspector-open.js | 2 +- 14 files changed, 16 insertions(+), 12 deletions(-) diff --git a/test/parallel/test-http-localaddress.js b/test/parallel/test-http-localaddress.js index e237c3bff1ac84..a0e4bb80a3f8c2 100644 --- a/test/parallel/test-http-localaddress.js +++ b/test/parallel/test-http-localaddress.js @@ -42,6 +42,7 @@ const server = http.createServer((req, res) => { server.listen(0, '127.0.0.1', () => { const options = { host: 'localhost', port: server.address().port, + family: 4, path: '/', method: 'GET', localAddress: '127.0.0.2' }; diff --git a/test/parallel/test-http-upgrade-client.js b/test/parallel/test-http-upgrade-client.js index ea6972a18c7d49..e86979fffd0d1c 100644 --- a/test/parallel/test-http-upgrade-client.js +++ b/test/parallel/test-http-upgrade-client.js @@ -49,7 +49,7 @@ const server = net.createServer(function(c) { }); }); -server.listen(0, '127.0.0.1', common.mustCall(function() { +server.listen(0, common.mustCall(function() { const port = this.address().port; const headers = [ { diff --git a/test/parallel/test-http2-connect-options.js b/test/parallel/test-http2-connect-options.js index 0c7ec807b84d38..233ced016974e2 100644 --- a/test/parallel/test-http2-connect-options.js +++ b/test/parallel/test-http2-connect-options.js @@ -22,7 +22,7 @@ const server = http2.createServer((req, res) => { }); server.listen(0, '127.0.0.1', common.mustCall(() => { - const options = { localAddress: '127.0.0.2' }; + const options = { localAddress: '127.0.0.2', family: 4 }; const client = http2.connect( 'http://localhost:' + server.address().port, diff --git a/test/parallel/test-https-localaddress.js b/test/parallel/test-https-localaddress.js index 0ac8414b2d4b35..0de0974dc69b04 100644 --- a/test/parallel/test-https-localaddress.js +++ b/test/parallel/test-https-localaddress.js @@ -52,6 +52,7 @@ server.listen(0, '127.0.0.1', function() { const options = { host: 'localhost', port: this.address().port, + family: 4, path: '/', method: 'GET', localAddress: '127.0.0.2', diff --git a/test/parallel/test-net-dns-lookup.js b/test/parallel/test-net-dns-lookup.js index 53052de716ee9e..5a40ce5c598bb2 100644 --- a/test/parallel/test-net-dns-lookup.js +++ b/test/parallel/test-net-dns-lookup.js @@ -29,7 +29,7 @@ const server = net.createServer(function(client) { server.close(); }); -server.listen(0, '127.0.0.1', common.mustCall(function() { +server.listen(0, common.mustCall(function() { net.connect(this.address().port, 'localhost') .on('lookup', common.mustCall(function(err, ip, type, host) { assert.strictEqual(err, null); diff --git a/test/parallel/test-net-remote-address-port.js b/test/parallel/test-net-remote-address-port.js index 094206f85df34d..4ef686a3de7659 100644 --- a/test/parallel/test-net-remote-address-port.js +++ b/test/parallel/test-net-remote-address-port.js @@ -48,8 +48,8 @@ const server = net.createServer(common.mustCall(function(socket) { socket.resume(); }, 2)); -server.listen(0, 'localhost', function() { - const client = net.createConnection(this.address().port, 'localhost'); +server.listen(0, function() { + const client = net.createConnection(this.address().port, '127.0.0.1'); const client2 = net.createConnection(this.address().port); client.on('connect', function() { assert.ok(remoteAddrCandidates.includes(client.remoteAddress)); diff --git a/test/parallel/test-tcp-wrap-listen.js b/test/parallel/test-tcp-wrap-listen.js index 72981b683ccea3..29051481c72583 100644 --- a/test/parallel/test-tcp-wrap-listen.js +++ b/test/parallel/test-tcp-wrap-listen.js @@ -14,7 +14,7 @@ const { const server = new TCP(TCPConstants.SOCKET); -const r = server.bind('0.0.0.0', 0); +const r = server.bind(0); assert.strictEqual(r, 0); let port = {}; server.getsockname(port); diff --git a/test/parallel/test-timers-socket-timeout-removes-other-socket-unref-timer.js b/test/parallel/test-timers-socket-timeout-removes-other-socket-unref-timer.js index ccecfe4c63a6a1..01d2367bdb5717 100644 --- a/test/parallel/test-timers-socket-timeout-removes-other-socket-unref-timer.js +++ b/test/parallel/test-timers-socket-timeout-removes-other-socket-unref-timer.js @@ -28,7 +28,7 @@ const server = net.createServer(function onClient(client) { } }); -server.listen(0, common.localhostIPv4, common.mustCall(() => { +server.listen(0, common.mustCall(() => { const countdown = new Countdown(2, () => server.close()); { diff --git a/test/parallel/test-tls-client-getephemeralkeyinfo.js b/test/parallel/test-tls-client-getephemeralkeyinfo.js index 73ac215102ddbb..82f41cfe7e06bd 100644 --- a/test/parallel/test-tls-client-getephemeralkeyinfo.js +++ b/test/parallel/test-tls-client-getephemeralkeyinfo.js @@ -37,7 +37,7 @@ function test(size, type, name, cipher) { server.on('close', common.mustSucceed()); - server.listen(0, '127.0.0.1', common.mustCall(() => { + server.listen(0, common.mustCall(() => { const client = tls.connect({ port: server.address().port, rejectUnauthorized: false diff --git a/test/parallel/test-tls-client-mindhsize.js b/test/parallel/test-tls-client-mindhsize.js index a6fbc67bd88361..1ccf49fa9292eb 100644 --- a/test/parallel/test-tls-client-mindhsize.js +++ b/test/parallel/test-tls-client-mindhsize.js @@ -34,7 +34,7 @@ function test(size, err, next) { if (next) next(); }); - server.listen(0, '127.0.0.1', function() { + server.listen(0, function() { // Client set minimum DH parameter size to 2048 bits so that // it fails when it make a connection to the tls server where // dhparams is 1024 bits diff --git a/test/parallel/test-tls-wrap-econnreset-localaddress.js b/test/parallel/test-tls-wrap-econnreset-localaddress.js index 30d3a8873fa8f0..b51ddb29ba8b55 100644 --- a/test/parallel/test-tls-wrap-econnreset-localaddress.js +++ b/test/parallel/test-tls-wrap-econnreset-localaddress.js @@ -16,6 +16,7 @@ const server = net.createServer((c) => { let errored = false; tls.connect({ port: port, + family: 4, localAddress: common.localhostIPv4 }, common.localhostIPv4) .once('error', common.mustCall((e) => { diff --git a/test/pummel/test-http-upload-timeout.js b/test/pummel/test-http-upload-timeout.js index c3ec3ad19d5d37..a9932306127753 100644 --- a/test/pummel/test-http-upload-timeout.js +++ b/test/pummel/test-http-upload-timeout.js @@ -44,7 +44,7 @@ server.on('request', function(req, res) { req.resume(); }); -server.listen(0, '127.0.0.1', function() { +server.listen(0, function() { for (let i = 0; i < 10; i++) { connections++; diff --git a/test/pummel/test-net-pingpong.js b/test/pummel/test-net-pingpong.js index 0b2947ade41a1c..ac65e32af3c67b 100644 --- a/test/pummel/test-net-pingpong.js +++ b/test/pummel/test-net-pingpong.js @@ -38,7 +38,8 @@ function pingPongTest(host, on_complete) { if (host === '127.0.0.1') { assert.strictEqual(address, '127.0.0.1'); } else if (host == null || host === 'localhost') { - assert(address === '127.0.0.1' || address === '::ffff:127.0.0.1'); + assert(address === '127.0.0.1' || address === '::ffff:127.0.0.1' + || address === '::1'); } else { console.log(`host = ${host}, remoteAddress = ${address}`); assert.strictEqual(address, '::1'); diff --git a/test/sequential/test-inspector-open.js b/test/sequential/test-inspector-open.js index 190a99e7282e52..847f0ab6926f67 100644 --- a/test/sequential/test-inspector-open.js +++ b/test/sequential/test-inspector-open.js @@ -80,7 +80,7 @@ function reopenAfterClose(msg) { } function ping(port, callback) { - net.connect(port) + net.connect({ port, family: 4 }) .on('connect', function() { close(this); }) .on('error', function(err) { close(this, err); });