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 99cb989
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 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 @@ -12,14 +18,16 @@ function check(addressType, cb) {
});

var address = addressType === 4 ? '127.0.0.1' : '::1';
var host = addressType === 4 ? 'localhost' : 'ip6-localhost';
server.listen(common.PORT, address, function() {
net.connect({
port: common.PORT,
host: 'localhost',
hostname: host,
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 99cb989

Please sign in to comment.