Skip to content

Commit 6545d1a

Browse files
batrlaMylesBorins
authored andcommitted
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

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,16 @@ const assert = require('assert');
2626
constnet=require('net');
2727

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

3132
constsocket=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(errinstanceofError);
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)