2424const common = require ( '../common' ) ;
2525const { addresses } = require ( '../common/internet' ) ;
2626const { internalBinding } = require ( 'internal/test/binding' ) ;
27+ const { getSystemErrorName } = require ( 'util' ) ;
2728const assert = require ( 'assert' ) ;
2829const dns = require ( 'dns' ) ;
2930const net = require ( 'net' ) ;
@@ -71,7 +72,10 @@ function checkWrap(req) {
7172TEST ( function test_reverse_bogus ( done ) {
7273 dnsPromises . reverse ( 'bogus ip' )
7374 . then ( common . mustNotCall ( ) )
74- . catch ( common . expectsError ( { errno : 'EINVAL' } ) ) ;
75+ . catch ( common . mustCall ( ( err ) => {
76+ assert . strictEqual ( err . code , 'EINVAL' ) ;
77+ assert . strictEqual ( getSystemErrorName ( err . errno ) , 'EINVAL' ) ;
78+ } ) ) ;
7579
7680 assert . throws ( ( ) => {
7781 dns . reverse ( 'bogus ip' , common . mustNotCall ( ) ) ;
@@ -161,11 +165,13 @@ TEST(async function test_resolveMx(done) {
161165TEST ( function test_resolveMx_failure ( done ) {
162166 dnsPromises . resolveMx ( addresses . INVALID_HOST )
163167 . then ( common . mustNotCall ( ) )
164- . catch ( common . expectsError ( { errno : 'ENOTFOUND' } ) ) ;
168+ . catch ( common . mustCall ( ( err ) => {
169+ assert . strictEqual ( err . code , 'ENOTFOUND' ) ;
170+ } ) ) ;
165171
166172 const req = dns . resolveMx ( addresses . INVALID_HOST , function ( err , result ) {
167173 assert . ok ( err instanceof Error ) ;
168- assert . strictEqual ( err . errno , 'ENOTFOUND' ) ;
174+ assert . strictEqual ( err . code , 'ENOTFOUND' ) ;
169175
170176 assert . strictEqual ( result , undefined ) ;
171177
@@ -199,11 +205,13 @@ TEST(async function test_resolveNs(done) {
199205TEST ( function test_resolveNs_failure ( done ) {
200206 dnsPromises . resolveNs ( addresses . INVALID_HOST )
201207 . then ( common . mustNotCall ( ) )
202- . catch ( common . expectsError ( { errno : 'ENOTFOUND' } ) ) ;
208+ . catch ( common . mustCall ( ( err ) => {
209+ assert . strictEqual ( err . code , 'ENOTFOUND' ) ;
210+ } ) ) ;
203211
204212 const req = dns . resolveNs ( addresses . INVALID_HOST , function ( err , result ) {
205213 assert . ok ( err instanceof Error ) ;
206- assert . strictEqual ( err . errno , 'ENOTFOUND' ) ;
214+ assert . strictEqual ( err . code , 'ENOTFOUND' ) ;
207215
208216 assert . strictEqual ( result , undefined ) ;
209217
@@ -241,11 +249,13 @@ TEST(async function test_resolveSrv(done) {
241249TEST ( function test_resolveSrv_failure ( done ) {
242250 dnsPromises . resolveSrv ( addresses . INVALID_HOST )
243251 . then ( common . mustNotCall ( ) )
244- . catch ( common . expectsError ( { errno : 'ENOTFOUND' } ) ) ;
252+ . catch ( common . mustCall ( ( err ) => {
253+ assert . strictEqual ( err . code , 'ENOTFOUND' ) ;
254+ } ) ) ;
245255
246256 const req = dns . resolveSrv ( addresses . INVALID_HOST , function ( err , result ) {
247257 assert . ok ( err instanceof Error ) ;
248- assert . strictEqual ( err . errno , 'ENOTFOUND' ) ;
258+ assert . strictEqual ( err . code , 'ENOTFOUND' ) ;
249259
250260 assert . strictEqual ( result , undefined ) ;
251261
@@ -279,11 +289,13 @@ TEST(async function test_resolvePtr(done) {
279289TEST ( function test_resolvePtr_failure ( done ) {
280290 dnsPromises . resolvePtr ( addresses . INVALID_HOST )
281291 . then ( common . mustNotCall ( ) )
282- . catch ( common . expectsError ( { errno : 'ENOTFOUND' } ) ) ;
292+ . catch ( common . mustCall ( ( err ) => {
293+ assert . strictEqual ( err . code , 'ENOTFOUND' ) ;
294+ } ) ) ;
283295
284296 const req = dns . resolvePtr ( addresses . INVALID_HOST , function ( err , result ) {
285297 assert . ok ( err instanceof Error ) ;
286- assert . strictEqual ( err . errno , 'ENOTFOUND' ) ;
298+ assert . strictEqual ( err . code , 'ENOTFOUND' ) ;
287299
288300 assert . strictEqual ( result , undefined ) ;
289301
@@ -322,11 +334,13 @@ TEST(async function test_resolveNaptr(done) {
322334TEST ( function test_resolveNaptr_failure ( done ) {
323335 dnsPromises . resolveNaptr ( addresses . INVALID_HOST )
324336 . then ( common . mustNotCall ( ) )
325- . catch ( common . expectsError ( { errno : 'ENOTFOUND' } ) ) ;
337+ . catch ( common . mustCall ( ( err ) => {
338+ assert . strictEqual ( err . code , 'ENOTFOUND' ) ;
339+ } ) ) ;
326340
327341 const req = dns . resolveNaptr ( addresses . INVALID_HOST , function ( err , result ) {
328342 assert . ok ( err instanceof Error ) ;
329- assert . strictEqual ( err . errno , 'ENOTFOUND' ) ;
343+ assert . strictEqual ( err . code , 'ENOTFOUND' ) ;
330344
331345 assert . strictEqual ( result , undefined ) ;
332346
@@ -369,11 +383,13 @@ TEST(async function test_resolveSoa(done) {
369383TEST ( function test_resolveSoa_failure ( done ) {
370384 dnsPromises . resolveSoa ( addresses . INVALID_HOST )
371385 . then ( common . mustNotCall ( ) )
372- . catch ( common . expectsError ( { errno : 'ENOTFOUND' } ) ) ;
386+ . catch ( common . mustCall ( ( err ) => {
387+ assert . strictEqual ( err . code , 'ENOTFOUND' ) ;
388+ } ) ) ;
373389
374390 const req = dns . resolveSoa ( addresses . INVALID_HOST , function ( err , result ) {
375391 assert . ok ( err instanceof Error ) ;
376- assert . strictEqual ( err . errno , 'ENOTFOUND' ) ;
392+ assert . strictEqual ( err . code , 'ENOTFOUND' ) ;
377393
378394 assert . strictEqual ( result , undefined ) ;
379395
@@ -407,11 +423,13 @@ TEST(async function test_resolveCname(done) {
407423TEST ( function test_resolveCname_failure ( done ) {
408424 dnsPromises . resolveCname ( addresses . INVALID_HOST )
409425 . then ( common . mustNotCall ( ) )
410- . catch ( common . expectsError ( { errno : 'ENOTFOUND' } ) ) ;
426+ . catch ( common . mustCall ( ( err ) => {
427+ assert . strictEqual ( err . code , 'ENOTFOUND' ) ;
428+ } ) ) ;
411429
412430 const req = dns . resolveCname ( addresses . INVALID_HOST , function ( err , result ) {
413431 assert . ok ( err instanceof Error ) ;
414- assert . strictEqual ( err . errno , 'ENOTFOUND' ) ;
432+ assert . strictEqual ( err . code , 'ENOTFOUND' ) ;
415433
416434 assert . strictEqual ( result , undefined ) ;
417435
@@ -443,11 +461,13 @@ TEST(async function test_resolveTxt(done) {
443461TEST ( function test_resolveTxt_failure ( done ) {
444462 dnsPromises . resolveTxt ( addresses . INVALID_HOST )
445463 . then ( common . mustNotCall ( ) )
446- . catch ( common . expectsError ( { errno : 'ENOTFOUND' } ) ) ;
464+ . catch ( common . mustCall ( ( err ) => {
465+ assert . strictEqual ( err . code , 'ENOTFOUND' ) ;
466+ } ) ) ;
447467
448468 const req = dns . resolveTxt ( addresses . INVALID_HOST , function ( err , result ) {
449469 assert . ok ( err instanceof Error ) ;
450- assert . strictEqual ( err . errno , 'ENOTFOUND' ) ;
470+ assert . strictEqual ( err . code , 'ENOTFOUND' ) ;
451471
452472 assert . strictEqual ( result , undefined ) ;
453473
@@ -461,12 +481,12 @@ TEST(function test_resolveTxt_failure(done) {
461481TEST ( function test_lookup_failure ( done ) {
462482 dnsPromises . lookup ( addresses . INVALID_HOST , 4 )
463483 . then ( common . mustNotCall ( ) )
464- . catch ( common . expectsError ( { errno : dns . NOTFOUND } ) ) ;
484+ . catch ( common . expectsError ( { code : dns . NOTFOUND } ) ) ;
465485
466486 const req = dns . lookup ( addresses . INVALID_HOST , 4 , ( err ) => {
467487 assert . ok ( err instanceof Error ) ;
468- assert . strictEqual ( err . errno , dns . NOTFOUND ) ;
469- assert . strictEqual ( err . errno , 'ENOTFOUND' ) ;
488+ assert . strictEqual ( err . code , dns . NOTFOUND ) ;
489+ assert . strictEqual ( err . code , 'ENOTFOUND' ) ;
470490 assert . ok ( ! / E N O E N T / . test ( err . message ) ) ;
471491 assert . ok ( err . message . includes ( addresses . INVALID_HOST ) ) ;
472492
0 commit comments