Skip to content

Commit

Permalink
test: fix up pummel/test-net-pingpong
Browse files Browse the repository at this point in the history
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 <tjfontaine@gmail.com>
  • Loading branch information
bnoordhuis authored and tjfontaine committed May 22, 2014
1 parent a367f62 commit 13553c1
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions test/pummel/test-net-pingpong.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down

0 comments on commit 13553c1

Please sign in to comment.