From 3c225fb408ec2864209904a14d620f2cd028ef38 Mon Sep 17 00:00:00 2001 From: Vita Batrla Date: Thu, 13 Feb 2020 19:17:42 +0100 Subject: [PATCH 1/2] test: test-net-dns-error.js fails on SunOS 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. --- test/parallel/test-net-dns-error.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/parallel/test-net-dns-error.js b/test/parallel/test-net-dns-error.js index bb90eafc3d95da..02c6f3cd39a366 100644 --- a/test/parallel/test-net-dns-error.js +++ b/test/parallel/test-net-dns-error.js @@ -26,7 +26,8 @@ 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 errCode = common.isOpenBSD || common.isSunOS ? 'EAI_FAIL' : 'ENOTFOUND'; const socket = net.connect(42, host, common.mustNotCall()); socket.on('error', common.mustCall(function(err) { From 2f247d97da9c28a205f91320f98d523271621049 Mon Sep 17 00:00:00 2001 From: Vita Batrla Date: Wed, 19 Feb 2020 09:21:41 +0100 Subject: [PATCH 2/2] test: allow EAI_FAIL in test-net-dns-error.js --- test/parallel/test-net-dns-error.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/parallel/test-net-dns-error.js b/test/parallel/test-net-dns-error.js index 02c6f3cd39a366..7232ef10ebb455 100644 --- a/test/parallel/test-net-dns-error.js +++ b/test/parallel/test-net-dns-error.js @@ -27,15 +27,15 @@ const net = require('net'); const host = '*'.repeat(64); // Resolving hostname > 63 characters may return EAI_FAIL (permanent failure). -const errCode = common.isOpenBSD || common.isSunOS ? 'EAI_FAIL' : 'ENOTFOUND'; +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); }));