Skip to content

Commit

Permalink
test: don't connect to :: (use localhost instead)
Browse files Browse the repository at this point in the history
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: #7291
PR-URL: #10854
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michal Zasso <targos@protonmail.com>
  • Loading branch information
gibfahn authored and italoacasas committed Jan 30, 2017
1 parent 3642f35 commit c60d87b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
2 changes: 1 addition & 1 deletion test/gc/test-net-timeout.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 1 addition & 3 deletions test/parallel/test-http-status-reason-invalid-chars.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand Down Expand Up @@ -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) => {
Expand Down

0 comments on commit c60d87b

Please sign in to comment.