Skip to content

Commit

Permalink
test: fix test-net-* error code check for getaddrinfo(3)
Browse files Browse the repository at this point in the history
Replace '...' as invalid hostname with '***', which will give a more
consisten error message on different systems. The hostname '...' returns
EAI_AGAIN on musl libc and EAI_NONAME on most other systems.

By changing the testcase we get same restult on all known platforms.

PR-URL: #5099
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Rod Vagg <[email protected]>
  • Loading branch information
ncopa authored and Myles Borins committed Jun 27, 2016
1 parent a08a017 commit 0414d88
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions test/parallel/test-net-better-error-messages-port-hostname.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ var common = require('../common');
var net = require('net');
var assert = require('assert');

var c = net.createConnection(common.PORT, '...');
var c = net.createConnection(common.PORT, '***');

c.on('connect', common.fail);

c.on('error', common.mustCall(function(e) {
assert.equal(e.code, 'ENOTFOUND');
assert.equal(e.port, common.PORT);
assert.equal(e.hostname, '...');
assert.equal(e.hostname, '***');
}));
4 changes: 2 additions & 2 deletions test/parallel/test-net-connect-immediate-finish.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ const common = require('../common');
const assert = require('assert');
const net = require('net');

const client = net.connect({host: '...', port: common.PORT});
const client = net.connect({host: '***', port: common.PORT});

client.once('error', common.mustCall(function(err) {
assert(err);
assert.strictEqual(err.code, err.errno);
assert.strictEqual(err.code, 'ENOTFOUND');
assert.strictEqual(err.host, err.hostname);
assert.strictEqual(err.host, '...');
assert.strictEqual(err.host, '***');
assert.strictEqual(err.syscall, 'getaddrinfo');
}));

Expand Down

0 comments on commit 0414d88

Please sign in to comment.