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 <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
  • Loading branch information
Vita Batrla authored and codebytere committed Mar 17, 2020
1 parent 3ce4db2 commit e827b8e
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 e827b8e

Please sign in to comment.