Skip to content

Commit

Permalink
test: fix test-net-dns-custom-lookup test assertion
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
evanlucas committed Apr 26, 2015
1 parent 4abe2fa commit b70703e
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions test/parallel/test-net-dns-custom-lookup.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ var net = require('net');
var dns = require('dns');
var ok = false;

var addrCandidates = [ common.localhostIPv4 ];
if (common.hasIPv6) {
addrCandidates.push('::ffff:127.0.0.1');
addrCandidates.push('::1');
}

function check(addressType, cb) {
var server = net.createServer(function(client) {
client.end();
Expand All @@ -15,11 +21,12 @@ function check(addressType, cb) {
server.listen(common.PORT, address, function() {
net.connect({
port: common.PORT,
host: 'localhost',
hostname: 'localhost',
family: addressType,
lookup: lookup
}).on('lookup', function(err, ip, type) {
assert.equal(err, null);
assert.equal(ip, address);
assert.notEqual(-1, addrCandidates.indexOf(ip), ip + ' exists');
assert.equal(type, addressType);
ok = true;
});
Expand Down

0 comments on commit b70703e

Please sign in to comment.