Skip to content

Commit

Permalink
test: allow EAI_FAIL in test-net-dns-error.js
Browse files Browse the repository at this point in the history
Test test-net-dns-error.js causes assertion failure on SunOS,
test expects ENOTFOUND, but OS returns EAI_FAIL.

Maximum length of a host name is 63 characters.
Test test-net-dns-error.js makes a connection attempt to
invalid host name (longer than maximum). Such
connection attempt on SunOS returns permanent failure
(EAI_FAIL) as invalid hostname won't be ever resolved.

PR-URL: #31780
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
  • Loading branch information
Vita Batrla authored and MylesBorins committed Mar 9, 2020
1 parent cc27846 commit 6545d1a
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions test/parallel/test-net-dns-error.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,16 @@ const assert = require('assert');
const net = require('net');

const host = '*'.repeat(64);
const errCode = common.isOpenBSD ? 'EAI_FAIL' : 'ENOTFOUND';
// Resolving hostname > 63 characters may return EAI_FAIL (permanent failure).
const errCodes = ['ENOTFOUND', 'EAI_FAIL'];

const socket = net.connect(42, host, common.mustNotCall());
socket.on('error', common.mustCall(function(err) {
assert.strictEqual(err.code, errCode);
assert(errCodes.includes(err.code), err);
}));
socket.on('lookup', common.mustCall(function(err, ip, type) {
assert(err instanceof Error);
assert.strictEqual(err.code, errCode);
assert(errCodes.includes(err.code), err);
assert.strictEqual(ip, undefined);
assert.strictEqual(type, undefined);
}));

0 comments on commit 6545d1a

Please sign in to comment.