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.

Fixes: nodejs#1527
PR-URL: nodejs#1531
Reviewed-By: Rod Vagg <[email protected]>
  • Loading branch information
evanlucas committed Apr 28, 2015
1 parent 5472139 commit bfae823
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.equal(address, ip);
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 bfae823

Please sign in to comment.