2018-08-25 01:03:09 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
require('../common');
|
2018-09-19 16:33:52 +00:00
|
|
|
const common = require('../common');
|
|
|
|
const dns = require('dns');
|
|
|
|
const dnsPromises = dns.promises;
|
2018-08-25 01:03:09 +00:00
|
|
|
const { addresses } = require('../common/internet');
|
|
|
|
const assert = require('assert');
|
|
|
|
|
|
|
|
assert.rejects(
|
2021-04-18 15:25:02 +00:00
|
|
|
dnsPromises.lookup(addresses.NOT_FOUND, {
|
2018-08-25 01:03:09 +00:00
|
|
|
hints: 0,
|
|
|
|
family: 0,
|
2023-02-01 09:46:06 +00:00
|
|
|
all: false,
|
2018-08-25 01:03:09 +00:00
|
|
|
}),
|
|
|
|
{
|
|
|
|
code: 'ENOTFOUND',
|
2023-02-01 09:46:06 +00:00
|
|
|
message: `getaddrinfo ENOTFOUND ${addresses.NOT_FOUND}`,
|
|
|
|
},
|
2018-08-25 01:03:09 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
assert.rejects(
|
2021-04-18 15:25:02 +00:00
|
|
|
dnsPromises.lookup(addresses.NOT_FOUND, {
|
2018-08-25 01:03:09 +00:00
|
|
|
hints: 0,
|
|
|
|
family: 0,
|
2023-02-01 09:46:06 +00:00
|
|
|
all: true,
|
2018-08-25 01:03:09 +00:00
|
|
|
}),
|
|
|
|
{
|
|
|
|
code: 'ENOTFOUND',
|
2023-02-01 09:46:06 +00:00
|
|
|
message: `getaddrinfo ENOTFOUND ${addresses.NOT_FOUND}`,
|
|
|
|
},
|
2018-08-25 01:03:09 +00:00
|
|
|
);
|
2018-09-19 16:33:52 +00:00
|
|
|
|
2021-04-18 15:25:02 +00:00
|
|
|
dns.lookup(addresses.NOT_FOUND, {
|
2018-09-19 16:33:52 +00:00
|
|
|
hints: 0,
|
|
|
|
family: 0,
|
2023-02-01 09:46:06 +00:00
|
|
|
all: true,
|
2018-09-19 16:33:52 +00:00
|
|
|
}, common.mustCall((error) => {
|
|
|
|
assert.strictEqual(error.code, 'ENOTFOUND');
|
|
|
|
assert.strictEqual(
|
|
|
|
error.message,
|
2023-02-01 09:46:06 +00:00
|
|
|
`getaddrinfo ENOTFOUND ${addresses.NOT_FOUND}`,
|
2018-09-19 16:33:52 +00:00
|
|
|
);
|
|
|
|
assert.strictEqual(error.syscall, 'getaddrinfo');
|
2021-04-18 15:25:02 +00:00
|
|
|
assert.strictEqual(error.hostname, addresses.NOT_FOUND);
|
2018-09-19 16:33:52 +00:00
|
|
|
}));
|
2021-08-17 18:08:46 +00:00
|
|
|
|
2022-01-07 11:00:10 +00:00
|
|
|
assert.throws(
|
|
|
|
() => dnsPromises.lookup(addresses.NOT_FOUND, {
|
2022-05-10 09:10:03 +00:00
|
|
|
family: 'ipv4',
|
2023-02-01 09:46:06 +00:00
|
|
|
all: 'all',
|
2021-08-17 18:08:46 +00:00
|
|
|
}),
|
2023-02-01 09:46:06 +00:00
|
|
|
{ code: 'ERR_INVALID_ARG_VALUE' },
|
2021-08-17 18:08:46 +00:00
|
|
|
);
|