Skip to content

Commit bfae823

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. Fixes: #1527 PR-URL: #1531 Reviewed-By: Rod Vagg <[email protected]>
1 parent 5472139 commit bfae823

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

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

+12-3
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,32 @@ function check(addressType, cb) {
1111
cb && cb();
1212
});
1313

14-
var address = addressType === 4 ? '127.0.0.1' : '::1';
14+
var address = addressType === 4 ? common.localhostIPv4 : '::1';
1515
server.listen(common.PORT, address, function() {
1616
net.connect({
1717
port: common.PORT,
1818
host: 'localhost',
19+
family: addressType,
1920
lookup: lookup
2021
}).on('lookup', function(err, ip, type) {
2122
assert.equal(err, null);
22-
assert.equal(ip, address);
23+
assert.equal(address, ip);
2324
assert.equal(type, addressType);
2425
ok = true;
2526
});
2627
});
2728

2829
function lookup(host, dnsopts, cb) {
2930
dnsopts.family = addressType;
30-
dns.lookup(host, dnsopts, cb);
31+
if (addressType === 4) {
32+
process.nextTick(function() {
33+
cb(null, common.localhostIPv4, 4);
34+
});
35+
} else {
36+
process.nextTick(function() {
37+
cb(null, '::1', 6);
38+
});
39+
}
3140
}
3241
}
3342

0 commit comments

Comments
 (0)