From c60d87b1ad79565f0aefa7736699faf09c437424 Mon Sep 17 00:00:00 2001 From: Gibson Fahnestock Date: Tue, 17 Jan 2017 10:30:43 +0000 Subject: [PATCH] test: don't connect to :: (use localhost instead) If a test does http.listen(0) or net.listen(0), http.listen(0).address().address returns '::'. Some machines will resolve this to localhost, but not all. Every machine should have localhost defined in /etc/hosts (or equivalent), so it should always resolve. Fixes: https://github.com/nodejs/node/issues/7291 PR-URL: https://github.com/nodejs/node/pull/10854 Reviewed-By: Luigi Pinca Reviewed-By: James M Snell Reviewed-By: Michal Zasso --- test/gc/test-net-timeout.js | 2 +- test/parallel/test-http-status-reason-invalid-chars.js | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/test/gc/test-net-timeout.js b/test/gc/test-net-timeout.js index 2d9bc134a30347..9bc19a04256108 100644 --- a/test/gc/test-net-timeout.js +++ b/test/gc/test-net-timeout.js @@ -36,7 +36,7 @@ function getall() { if (count >= todo) return; - const req = net.connect(server.address().port, server.address().address); + const req = net.connect(server.address().port); req.resume(); req.setTimeout(10, function() { req.destroy(); diff --git a/test/parallel/test-http-status-reason-invalid-chars.js b/test/parallel/test-http-status-reason-invalid-chars.js index 9950eeeee9cdd2..75ccb2c2430c53 100644 --- a/test/parallel/test-http-status-reason-invalid-chars.js +++ b/test/parallel/test-http-status-reason-invalid-chars.js @@ -3,7 +3,6 @@ const common = require('../common'); const assert = require('assert'); const http = require('http'); -const net = require('net'); function explicit(req, res) { assert.throws(() => { @@ -34,8 +33,7 @@ const server = http.createServer((req, res) => { implicit(req, res); } }).listen(0, common.mustCall(() => { - const addr = server.address().address; - const hostname = net.isIPv6(addr) ? `[${addr}1]` : addr; + const hostname = 'localhost'; const url = `http://${hostname}:${server.address().port}`; let left = 2; const check = common.mustCall((res) => {