From b70703ef7945e058bfef70ea52736585b2fa2077 Mon Sep 17 00:00:00 2001 From: Evan Lucas Date: Sun, 26 Apr 2015 08:52:10 -0500 Subject: [PATCH] test: fix test-net-dns-custom-lookup test assertion 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. --- test/parallel/test-net-dns-custom-lookup.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/test/parallel/test-net-dns-custom-lookup.js b/test/parallel/test-net-dns-custom-lookup.js index 3979bbf0b6d2c5..19c3555513499c 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(); @@ -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; });