Skip to content

Commit 6545d1a

Browse files
Vita BatrlaMylesBorins
Vita Batrla
authored andcommittedMar 9, 2020
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: #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>
1 parent cc27846 commit 6545d1a

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed
 

‎test/parallel/test-net-dns-error.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,16 @@ const assert = require('assert');
2626
const net = require('net');
2727

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

3132
const socket = net.connect(42, host, common.mustNotCall());
3233
socket.on('error', common.mustCall(function(err) {
33-
assert.strictEqual(err.code, errCode);
34+
assert(errCodes.includes(err.code), err);
3435
}));
3536
socket.on('lookup', common.mustCall(function(err, ip, type) {
3637
assert(err instanceof Error);
37-
assert.strictEqual(err.code, errCode);
38+
assert(errCodes.includes(err.code), err);
3839
assert.strictEqual(ip, undefined);
3940
assert.strictEqual(type, undefined);
4041
}));

0 commit comments

Comments
 (0)
Please sign in to comment.