diff --git a/test/parallel/test-net-dns-custom-lookup.js b/test/parallel/test-net-dns-custom-lookup.js index 3979bbf0b6d2c5..7ad802284898d1 100644 --- a/test/parallel/test-net-dns-custom-lookup.js +++ b/test/parallel/test-net-dns-custom-lookup.js @@ -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(); @@ -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; });