From 13553c133287141c92d088b148f4689e63859c09 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Thu, 22 May 2014 13:00:55 +0200 Subject: [PATCH] test: fix up pummel/test-net-pingpong Fix up a bad assumption in pummel/test-net-pingpong, namely that binding to 'localhost' or '' means that incoming connections will have an IPv4 address. Signed-off-by: Timothy J Fontaine --- test/pummel/test-net-pingpong.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/test/pummel/test-net-pingpong.js b/test/pummel/test-net-pingpong.js index c66544439d7..aab03c2872e 100644 --- a/test/pummel/test-net-pingpong.js +++ b/test/pummel/test-net-pingpong.js @@ -36,12 +36,14 @@ function pingPongTest(port, host, on_complete) { var server = net.createServer({ allowHalfOpen: true }, function(socket) { assert.equal(true, socket.remoteAddress !== null); assert.equal(true, socket.remoteAddress !== undefined); - if (host === '127.0.0.1' || host === 'localhost' || !host) { - assert.equal(socket.remoteAddress, '127.0.0.1'); + var address = socket.remoteAddress; + if (host === '127.0.0.1') { + assert.equal(address, '127.0.0.1'); + } else if (host == null || host === 'localhost') { + assert(address === '127.0.0.1' || address === '::ffff:127.0.0.1'); } else { - console.log('host = ' + host + - ', remoteAddress = ' + socket.remoteAddress); - assert.equal(socket.remoteAddress, '::1'); + console.log('host = ' + host + ', remoteAddress = ' + address); + assert.equal(address, '::1'); } socket.setEncoding('utf8');