mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
test: allow EAI_FAIL in test-net-dns-error.js
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: https://github.com/nodejs/node/pull/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>
This commit is contained in:
parent
98f44296dc
commit
077f9dc603
@ -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);
|
||||
}));
|
||||
|
Loading…
Reference in New Issue
Block a user