Skip to content

Commit 99cb989

Browse files
committed
test: fix test-net-dns-custom-lookup test assertion
The assertion made an assumption that the IPv6 address would always be `::1`. Since the address can be different on different platforms, it has been changed to allow multiple addresses.
1 parent 4abe2fa commit 99cb989

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

test/parallel/test-net-dns-custom-lookup.js

+10-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ var net = require('net');
44
var dns = require('dns');
55
var ok = false;
66

7+
var addrCandidates = [ common.localhostIPv4 ];
8+
if (common.hasIPv6) {
9+
addrCandidates.push('::ffff:127.0.0.1');
10+
addrCandidates.push('::1');
11+
}
12+
713
function check(addressType, cb) {
814
var server = net.createServer(function(client) {
915
client.end();
@@ -12,14 +18,16 @@ function check(addressType, cb) {
1218
});
1319

1420
var address = addressType === 4 ? '127.0.0.1' : '::1';
21+
var host = addressType === 4 ? 'localhost' : 'ip6-localhost';
1522
server.listen(common.PORT, address, function() {
1623
net.connect({
1724
port: common.PORT,
18-
host: 'localhost',
25+
hostname: host,
26+
family: addressType,
1927
lookup: lookup
2028
}).on('lookup', function(err, ip, type) {
2129
assert.equal(err, null);
22-
assert.equal(ip, address);
30+
assert.notEqual(-1, addrCandidates.indexOf(ip), ip + ' exists');
2331
assert.equal(type, addressType);
2432
ok = true;
2533
});

0 commit comments

Comments
 (0)