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 27, 2015
1 parent 4abe2fa commit 466ba1e
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions test/parallel/test-net-dns-custom-lookup.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,32 @@ function check(addressType, cb) {
cb && cb();
});

var address = addressType === 4 ? '127.0.0.1' : '::1';
var address = addressType === 4 ? common.localhostIPv4 : '::1';
server.listen(common.PORT, address, function() {
net.connect({
port: common.PORT,
host: 'localhost',
family: addressType,
lookup: lookup
}).on('lookup', function(err, ip, type) {
assert.equal(err, null);
assert.equal(ip, address);
assert.notEqual(-1, address);
assert.equal(type, addressType);
ok = true;
});
});

function lookup(host, dnsopts, cb) {
dnsopts.family = addressType;
dns.lookup(host, dnsopts, cb);
if (addressType === 4) {
process.nextTick(function() {
cb(null, common.localhostIPv4, 4);
});
} else {
process.nextTick(function() {
cb(null, '::1', 6);
});
}
}
}

Expand Down

0 comments on commit 466ba1e

Please sign in to comment.