mirror of
https://github.com/nodejs/node.git
synced 2026-11-21 12:59:16 -05:00
test: ensure assertions are reachable in test/internet
PR-URL: https://github.com/nodejs/node/pull/60513 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
This commit is contained in:
1 parent
f85c73979b
commit
bdf0f2a7d4
16 files changed
+250
-271
No files matched your search
@@ -165,6 +165,7 @@ export default [
|
||||
'embedding',
|
||||
'fixtures',
|
||||
'fuzzers',
|
||||
'internet',
|
||||
'js-native-api',
|
||||
'known_issues',
|
||||
'message',
|
||||
|
||||
@@ -84,7 +84,7 @@ if (process.argv[2] !== 'child') {
|
||||
worker.messagesReceived = [];
|
||||
|
||||
// Handle the death of workers
|
||||
worker.on('exit', (code, signal) => {
|
||||
worker.on('exit', common.mustCall((code, signal) => {
|
||||
// Don't consider this the true death if the worker
|
||||
// has finished successfully
|
||||
// or if the exit code is 0
|
||||
@@ -108,9 +108,9 @@ if (process.argv[2] !== 'child') {
|
||||
|
||||
process.exit(1);
|
||||
}
|
||||
});
|
||||
}));
|
||||
|
||||
worker.on('message', (msg) => {
|
||||
worker.on('message', common.mustCallAtLeast((msg) => {
|
||||
if (msg.listening) {
|
||||
listening += 1;
|
||||
|
||||
@@ -134,7 +134,7 @@ if (process.argv[2] !== 'child') {
|
||||
'required number of ' +
|
||||
'messages. Will now compare.');
|
||||
|
||||
Object.keys(workers).forEach((pid) => {
|
||||
for (const pid of Object.keys(workers)) {
|
||||
const worker = workers[pid];
|
||||
|
||||
let count = 0;
|
||||
@@ -153,14 +153,14 @@ if (process.argv[2] !== 'child') {
|
||||
count);
|
||||
|
||||
assert.strictEqual(count, messages.length);
|
||||
});
|
||||
}
|
||||
|
||||
clearTimeout(timer);
|
||||
console.error('[PARENT] Success');
|
||||
killSubprocesses(workers);
|
||||
}
|
||||
}
|
||||
});
|
||||
}));
|
||||
})(x);
|
||||
}
|
||||
|
||||
@@ -196,14 +196,13 @@ if (process.argv[2] !== 'child') {
|
||||
buf.length,
|
||||
common.PORT,
|
||||
LOCAL_BROADCAST_HOST,
|
||||
(err) => {
|
||||
assert.ifError(err);
|
||||
common.mustSucceed(() => {
|
||||
console.error('[PARENT] sent %s to %s:%s',
|
||||
util.inspect(buf.toString()),
|
||||
LOCAL_BROADCAST_HOST, common.PORT);
|
||||
|
||||
process.nextTick(sendSocket.sendNext);
|
||||
},
|
||||
}),
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ function launchChildProcess() {
|
||||
}
|
||||
});
|
||||
|
||||
worker.on('message', function(msg) {
|
||||
worker.on('message', common.mustCallAtLeast((msg) => {
|
||||
if (msg.listening) {
|
||||
listening += 1;
|
||||
|
||||
@@ -94,7 +94,7 @@ function launchChildProcess() {
|
||||
console.error('[PARENT] All workers have received the ' +
|
||||
'required number of messages. Will now compare.');
|
||||
|
||||
Object.keys(workers).forEach(function(pid) {
|
||||
for (const pid of Object.keys(workers)) {
|
||||
const worker = workers[pid];
|
||||
|
||||
let count = 0;
|
||||
@@ -112,14 +112,14 @@ function launchChildProcess() {
|
||||
worker.pid, count);
|
||||
|
||||
assert.strictEqual(count, messages.length);
|
||||
});
|
||||
}
|
||||
|
||||
clearTimeout(timer);
|
||||
console.error('[PARENT] Success');
|
||||
killSubprocesses(workers);
|
||||
}
|
||||
}
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
function killSubprocesses(subprocesses) {
|
||||
@@ -182,13 +182,12 @@ if (process.argv[2] !== 'child') {
|
||||
buf.length,
|
||||
common.PORT,
|
||||
LOCAL_BROADCAST_HOST,
|
||||
function(err) {
|
||||
assert.ifError(err);
|
||||
common.mustSucceed(() => {
|
||||
console.error('[PARENT] sent "%s" to %s:%s',
|
||||
buf.toString(),
|
||||
LOCAL_BROADCAST_HOST, common.PORT);
|
||||
process.nextTick(sendSocket.sendNext);
|
||||
},
|
||||
}),
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -144,7 +144,7 @@ if (process.argv[2] !== 'child') {
|
||||
}
|
||||
});
|
||||
|
||||
worker.on('message', (msg) => {
|
||||
worker.on('message', common.mustCallAtLeast((msg) => {
|
||||
if (msg.listening) {
|
||||
listening += 1;
|
||||
|
||||
@@ -168,7 +168,7 @@ if (process.argv[2] !== 'child') {
|
||||
'required number of ' +
|
||||
'messages. Will now compare.');
|
||||
|
||||
Object.keys(workers).forEach((pid) => {
|
||||
for (const pid of Object.keys(workers)) {
|
||||
const worker = workers[pid];
|
||||
|
||||
let count = 0;
|
||||
@@ -189,14 +189,14 @@ if (process.argv[2] !== 'child') {
|
||||
assert.strictEqual(count, worker.messagesNeeded.length,
|
||||
'A worker received ' +
|
||||
'an invalid multicast message');
|
||||
});
|
||||
}
|
||||
|
||||
clearTimeout(timer);
|
||||
console.error('[PARENT] Success');
|
||||
killSubprocesses(workers);
|
||||
}
|
||||
}
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
const sendSocket = dgram.createSocket({
|
||||
@@ -234,14 +234,13 @@ if (process.argv[2] !== 'child') {
|
||||
buf.length,
|
||||
PORTS[msg.mcast],
|
||||
msg.mcast,
|
||||
(err) => {
|
||||
assert.ifError(err);
|
||||
common.mustSucceed(() => {
|
||||
console.error('[PARENT] sent %s to %s:%s',
|
||||
util.inspect(buf.toString()),
|
||||
msg.mcast, PORTS[msg.mcast]);
|
||||
|
||||
process.nextTick(sendSocket.sendNext);
|
||||
},
|
||||
}),
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ function launchChildProcess() {
|
||||
}
|
||||
});
|
||||
|
||||
worker.on('message', function(msg) {
|
||||
worker.on('message', common.mustCallAtLeast((msg) => {
|
||||
if (msg.listening) {
|
||||
listening += 1;
|
||||
|
||||
@@ -88,7 +88,7 @@ function launchChildProcess() {
|
||||
console.error('[PARENT] All workers have received the ' +
|
||||
'required number of messages. Will now compare.');
|
||||
|
||||
Object.keys(workers).forEach(function(pid) {
|
||||
for (const pid of Object.keys(workers)) {
|
||||
const worker = workers[pid];
|
||||
|
||||
let count = 0;
|
||||
@@ -106,14 +106,14 @@ function launchChildProcess() {
|
||||
worker.pid, count);
|
||||
|
||||
assert.strictEqual(count, messages.length);
|
||||
});
|
||||
}
|
||||
|
||||
clearTimeout(timer);
|
||||
console.error('[PARENT] Success');
|
||||
killChildren(workers);
|
||||
}
|
||||
}
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
function killChildren(children) {
|
||||
@@ -176,13 +176,12 @@ if (process.argv[2] !== 'child') {
|
||||
buf.length,
|
||||
common.PORT,
|
||||
GROUP_ADDRESS,
|
||||
function(err) {
|
||||
assert.ifError(err);
|
||||
common.mustSucceed((err) => {
|
||||
console.error('[PARENT] sent "%s" to %s:%s',
|
||||
buf.toString(),
|
||||
GROUP_ADDRESS, common.PORT);
|
||||
process.nextTick(sendSocket.sendNext);
|
||||
},
|
||||
}),
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ function launchChildProcess() {
|
||||
}
|
||||
});
|
||||
|
||||
worker.on('message', function(msg) {
|
||||
worker.on('message', common.mustCallAtLeast((msg) => {
|
||||
if (msg.listening) {
|
||||
listening += 1;
|
||||
|
||||
@@ -88,7 +88,7 @@ function launchChildProcess() {
|
||||
console.error('[PARENT] All workers have received the ' +
|
||||
'required number of messages. Will now compare.');
|
||||
|
||||
Object.keys(workers).forEach(function(pid) {
|
||||
for (const pid of Object.keys(workers)) {
|
||||
const worker = workers[pid];
|
||||
|
||||
let count = 0;
|
||||
@@ -106,14 +106,14 @@ function launchChildProcess() {
|
||||
worker.pid, count);
|
||||
|
||||
assert.strictEqual(count, messages.length);
|
||||
});
|
||||
}
|
||||
|
||||
clearTimeout(timer);
|
||||
console.error('[PARENT] Success');
|
||||
killChildren(workers);
|
||||
}
|
||||
}
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
function killChildren(children) {
|
||||
@@ -176,13 +176,12 @@ if (process.argv[2] !== 'child') {
|
||||
buf.length,
|
||||
common.PORT,
|
||||
GROUP_ADDRESS,
|
||||
function(err) {
|
||||
assert.ifError(err);
|
||||
common.mustSucceed(() => {
|
||||
console.error('[PARENT] sent "%s" to %s:%s',
|
||||
buf.toString(),
|
||||
GROUP_ADDRESS, common.PORT);
|
||||
process.nextTick(sendSocket.sendNext);
|
||||
},
|
||||
}),
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ function checkWrap(req) {
|
||||
assert.ok(typeof req === 'object');
|
||||
}
|
||||
|
||||
/* eslint-disable node-core/must-call-assert */
|
||||
const checkers = {
|
||||
checkA(r) {
|
||||
assert.ok(isIPv4(r.address));
|
||||
@@ -80,13 +81,14 @@ const checkers = {
|
||||
assert.strictEqual(r.type, 'SRV');
|
||||
},
|
||||
};
|
||||
/* eslint-enable node-core/must-call-assert */
|
||||
|
||||
function TEST(f) {
|
||||
function test(f) {
|
||||
function next() {
|
||||
const f = queue.shift();
|
||||
if (f) {
|
||||
running = true;
|
||||
f(done);
|
||||
f(done).then(common.mustCall());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,7 +117,7 @@ function processResult(res) {
|
||||
return types;
|
||||
}
|
||||
|
||||
TEST(async function test_sip2sip_for_naptr(done) {
|
||||
test(async function test_sip2sip_for_naptr(done) {
|
||||
function validateResult(res) {
|
||||
const types = processResult(res);
|
||||
assert.ok(types.A && types.NS && types.NAPTR && types.SOA,
|
||||
@@ -135,7 +137,7 @@ TEST(async function test_sip2sip_for_naptr(done) {
|
||||
checkWrap(req);
|
||||
});
|
||||
|
||||
TEST(async function test_google_for_cname_and_srv(done) {
|
||||
test(async function test_google_for_cname_and_srv(done) {
|
||||
function validateResult(res) {
|
||||
const types = processResult(res);
|
||||
assert.ok(types.SRV);
|
||||
@@ -154,7 +156,7 @@ TEST(async function test_google_for_cname_and_srv(done) {
|
||||
checkWrap(req);
|
||||
});
|
||||
|
||||
TEST(async function test_ptr(done) {
|
||||
test(async function test_ptr(done) {
|
||||
function validateResult(res) {
|
||||
const types = processResult(res);
|
||||
assert.ok(types.PTR);
|
||||
|
||||
@@ -5,7 +5,7 @@ const assert = require('assert');
|
||||
const dns = require('dns');
|
||||
const domain = require('domain');
|
||||
|
||||
const methods = [
|
||||
[
|
||||
'resolve4',
|
||||
'resolve6',
|
||||
'resolveCname',
|
||||
@@ -17,13 +17,11 @@ const methods = [
|
||||
'resolvePtr',
|
||||
'resolveNaptr',
|
||||
'resolveSoa',
|
||||
];
|
||||
|
||||
methods.forEach(function(method) {
|
||||
].forEach(function(method) {
|
||||
const d = domain.create();
|
||||
d.run(function() {
|
||||
d.run(common.mustCall(() => {
|
||||
dns[method](addresses.INET_HOST, common.mustCall(() => {
|
||||
assert.strictEqual(process.domain, d, `${method} retains domain`);
|
||||
}));
|
||||
});
|
||||
}));
|
||||
});
|
||||
@@ -13,13 +13,13 @@ const dnsPromises = dns.promises;
|
||||
let running = false;
|
||||
const queue = [];
|
||||
|
||||
function TEST(f) {
|
||||
function test(f) {
|
||||
function next() {
|
||||
const f = queue.shift();
|
||||
if (f) {
|
||||
running = true;
|
||||
console.log(f.name);
|
||||
f(done);
|
||||
f(done)?.then(common.mustCall());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ function checkWrap(req) {
|
||||
assert.ok(typeof req === 'object');
|
||||
}
|
||||
|
||||
TEST(async function test_resolve4(done) {
|
||||
test(async function test_resolve4(done) {
|
||||
function validateResult(res) {
|
||||
assert.ok(res.length > 0);
|
||||
|
||||
@@ -60,7 +60,7 @@ TEST(async function test_resolve4(done) {
|
||||
checkWrap(req);
|
||||
});
|
||||
|
||||
TEST(async function test_reverse_ipv4(done) {
|
||||
test(async function test_reverse_ipv4(done) {
|
||||
function validateResult(res) {
|
||||
assert.ok(res.length > 0);
|
||||
|
||||
@@ -82,7 +82,7 @@ TEST(async function test_reverse_ipv4(done) {
|
||||
checkWrap(req);
|
||||
});
|
||||
|
||||
TEST(async function test_lookup_ipv4_explicit(done) {
|
||||
test(async function test_lookup_ipv4_explicit(done) {
|
||||
function validateResult(res) {
|
||||
assert.ok(net.isIPv4(res.address));
|
||||
assert.strictEqual(res.family, 4);
|
||||
@@ -100,7 +100,7 @@ TEST(async function test_lookup_ipv4_explicit(done) {
|
||||
checkWrap(req);
|
||||
});
|
||||
|
||||
TEST(async function test_lookup_ipv4_implicit(done) {
|
||||
test(async function test_lookup_ipv4_implicit(done) {
|
||||
function validateResult(res) {
|
||||
assert.ok(net.isIPv4(res.address));
|
||||
assert.strictEqual(res.family, 4);
|
||||
@@ -118,7 +118,7 @@ TEST(async function test_lookup_ipv4_implicit(done) {
|
||||
checkWrap(req);
|
||||
});
|
||||
|
||||
TEST(async function test_lookup_ipv4_explicit_object(done) {
|
||||
test(async function test_lookup_ipv4_explicit_object(done) {
|
||||
function validateResult(res) {
|
||||
assert.ok(net.isIPv4(res.address));
|
||||
assert.strictEqual(res.family, 4);
|
||||
@@ -136,7 +136,7 @@ TEST(async function test_lookup_ipv4_explicit_object(done) {
|
||||
checkWrap(req);
|
||||
});
|
||||
|
||||
TEST(async function test_lookup_ipv4_hint_addrconfig(done) {
|
||||
test(async function test_lookup_ipv4_hint_addrconfig(done) {
|
||||
function validateResult(res) {
|
||||
assert.ok(net.isIPv4(res.address));
|
||||
assert.strictEqual(res.family, 4);
|
||||
@@ -156,7 +156,7 @@ TEST(async function test_lookup_ipv4_hint_addrconfig(done) {
|
||||
checkWrap(req);
|
||||
});
|
||||
|
||||
TEST(async function test_lookup_ip_ipv4(done) {
|
||||
test(async function test_lookup_ip_ipv4(done) {
|
||||
function validateResult(res) {
|
||||
assert.strictEqual(res.address, '127.0.0.1');
|
||||
assert.strictEqual(res.family, 4);
|
||||
@@ -173,7 +173,7 @@ TEST(async function test_lookup_ip_ipv4(done) {
|
||||
checkWrap(req);
|
||||
});
|
||||
|
||||
TEST(async function test_lookup_localhost_ipv4(done) {
|
||||
test(async function test_lookup_localhost_ipv4(done) {
|
||||
function validateResult(res) {
|
||||
assert.strictEqual(res.address, '127.0.0.1');
|
||||
assert.strictEqual(res.family, 4);
|
||||
@@ -190,7 +190,7 @@ TEST(async function test_lookup_localhost_ipv4(done) {
|
||||
checkWrap(req);
|
||||
});
|
||||
|
||||
TEST(async function test_lookup_all_ipv4(done) {
|
||||
test(async function test_lookup_all_ipv4(done) {
|
||||
function validateResult(res) {
|
||||
assert.ok(Array.isArray(res));
|
||||
assert.ok(res.length > 0);
|
||||
@@ -218,7 +218,7 @@ TEST(async function test_lookup_all_ipv4(done) {
|
||||
checkWrap(req);
|
||||
});
|
||||
|
||||
TEST(async function test_lookupservice_ip_ipv4(done) {
|
||||
test(async function test_lookupservice_ip_ipv4(done) {
|
||||
function validateResult(res) {
|
||||
assert.strictEqual(typeof res.hostname, 'string');
|
||||
assert(res.hostname);
|
||||
@@ -238,12 +238,12 @@ TEST(async function test_lookupservice_ip_ipv4(done) {
|
||||
checkWrap(req);
|
||||
});
|
||||
|
||||
TEST(function test_lookupservice_ip_ipv4_promise(done) {
|
||||
test(function test_lookupservice_ip_ipv4_promise(done) {
|
||||
util.promisify(dns.lookupService)('127.0.0.1', 80)
|
||||
.then(common.mustCall(({ hostname, service }) => {
|
||||
.then(({ hostname, service }) => {
|
||||
assert.strictEqual(typeof hostname, 'string');
|
||||
assert(hostname.length > 0);
|
||||
assert(['http', 'www', '80'].includes(service));
|
||||
done();
|
||||
}));
|
||||
}).then(common.mustCall());
|
||||
});
|
||||
@@ -13,13 +13,13 @@ const isIPv6 = net.isIPv6;
|
||||
let running = false;
|
||||
const queue = [];
|
||||
|
||||
function TEST(f) {
|
||||
function test(f) {
|
||||
function next() {
|
||||
const f = queue.shift();
|
||||
if (f) {
|
||||
running = true;
|
||||
console.log(f.name);
|
||||
f(done);
|
||||
f(done)?.then(common.mustCall());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ function checkWrap(req) {
|
||||
assert.ok(typeof req === 'object');
|
||||
}
|
||||
|
||||
TEST(async function test_resolve6(done) {
|
||||
test(async function test_resolve6(done) {
|
||||
function validateResult(res) {
|
||||
assert.ok(res.length > 0);
|
||||
|
||||
@@ -60,7 +60,7 @@ TEST(async function test_resolve6(done) {
|
||||
checkWrap(req);
|
||||
});
|
||||
|
||||
TEST(async function test_reverse_ipv6(done) {
|
||||
test(async function test_reverse_ipv6(done) {
|
||||
function validateResult(res) {
|
||||
assert.ok(res.length > 0);
|
||||
|
||||
@@ -81,7 +81,7 @@ TEST(async function test_reverse_ipv6(done) {
|
||||
checkWrap(req);
|
||||
});
|
||||
|
||||
TEST(async function test_lookup_ipv6_explicit(done) {
|
||||
test(async function test_lookup_ipv6_explicit(done) {
|
||||
function validateResult(res) {
|
||||
assert.ok(isIPv6(res.address));
|
||||
assert.strictEqual(res.family, 6);
|
||||
@@ -101,7 +101,7 @@ TEST(async function test_lookup_ipv6_explicit(done) {
|
||||
});
|
||||
|
||||
// This ends up just being too problematic to test
|
||||
// TEST(function test_lookup_ipv6_implicit(done) {
|
||||
// test(function test_lookup_ipv6_implicit(done) {
|
||||
// var req = dns.lookup(addresses.INET6_HOST, function(err, ip, family) {
|
||||
// assert.ifError(err);
|
||||
// assert.ok(net.isIPv6(ip));
|
||||
@@ -113,7 +113,7 @@ TEST(async function test_lookup_ipv6_explicit(done) {
|
||||
// checkWrap(req);
|
||||
// });
|
||||
|
||||
TEST(async function test_lookup_ipv6_explicit_object(done) {
|
||||
test(async function test_lookup_ipv6_explicit_object(done) {
|
||||
function validateResult(res) {
|
||||
assert.ok(isIPv6(res.address));
|
||||
assert.strictEqual(res.family, 6);
|
||||
@@ -131,7 +131,7 @@ TEST(async function test_lookup_ipv6_explicit_object(done) {
|
||||
checkWrap(req);
|
||||
});
|
||||
|
||||
TEST(function test_lookup_ipv6_hint(done) {
|
||||
test(function test_lookup_ipv6_hint(done) {
|
||||
const req = dns.lookup(addresses.INET6_HOST, {
|
||||
family: 6,
|
||||
hints: dns.V4MAPPED,
|
||||
@@ -159,7 +159,7 @@ TEST(function test_lookup_ipv6_hint(done) {
|
||||
checkWrap(req);
|
||||
});
|
||||
|
||||
TEST(async function test_lookup_ip_ipv6(done) {
|
||||
test(async function test_lookup_ip_ipv6(done) {
|
||||
function validateResult(res) {
|
||||
assert.ok(isIPv6(res.address));
|
||||
assert.strictEqual(res.family, 6);
|
||||
@@ -177,7 +177,7 @@ TEST(async function test_lookup_ip_ipv6(done) {
|
||||
checkWrap(req);
|
||||
});
|
||||
|
||||
TEST(async function test_lookup_all_ipv6(done) {
|
||||
test(async function test_lookup_all_ipv6(done) {
|
||||
function validateResult(res) {
|
||||
assert.ok(Array.isArray(res));
|
||||
assert.ok(res.length > 0);
|
||||
@@ -206,7 +206,7 @@ TEST(async function test_lookup_all_ipv6(done) {
|
||||
checkWrap(req);
|
||||
});
|
||||
|
||||
TEST(function test_lookupservice_ip_ipv6(done) {
|
||||
test(function test_lookupservice_ip_ipv6(done) {
|
||||
const req = dns.lookupService(
|
||||
'::1', 80,
|
||||
common.mustCall((err, host, service) => {
|
||||
@@ -227,7 +227,7 @@ TEST(function test_lookupservice_ip_ipv6(done) {
|
||||
});
|
||||
|
||||
// Disabled because it appears to be not working on Linux.
|
||||
// TEST(function test_lookup_localhost_ipv6(done) {
|
||||
// test(function test_lookup_localhost_ipv6(done) {
|
||||
// var req = dns.lookup('localhost', 6, function(err, ip, family) {
|
||||
// assert.ifError(err);
|
||||
// assert.ok(net.isIPv6(ip));
|
||||
|
||||
@@ -9,7 +9,7 @@ const dnsPromises = dns.promises;
|
||||
assert.strictEqual(result.length, 0);
|
||||
})().then(common.mustCall());
|
||||
|
||||
dns.resolveTxt('www.microsoft.com', function(err, records) {
|
||||
dns.resolveTxt('www.microsoft.com', common.mustCall((err, records) => {
|
||||
assert.strictEqual(err, null);
|
||||
assert.strictEqual(records.length, 0);
|
||||
});
|
||||
}));
|
||||
+163
-180
@@ -39,13 +39,13 @@ let running = false;
|
||||
const queue = [];
|
||||
|
||||
|
||||
function TEST(f) {
|
||||
function test(f) {
|
||||
function next() {
|
||||
const f = queue.shift();
|
||||
if (f) {
|
||||
running = true;
|
||||
console.log(f.name);
|
||||
f(done);
|
||||
f(done)?.then(common.mustCall());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,13 +69,15 @@ function checkWrap(req) {
|
||||
}
|
||||
|
||||
|
||||
TEST(function test_reverse_bogus(done) {
|
||||
dnsPromises.reverse('bogus ip')
|
||||
.then(common.mustNotCall())
|
||||
.catch(common.mustCall((err) => {
|
||||
test(function test_reverse_bogus(done) {
|
||||
assert.rejects(
|
||||
dnsPromises.reverse('bogus ip'),
|
||||
(err) => {
|
||||
assert.strictEqual(err.code, 'EINVAL');
|
||||
assert.strictEqual(getSystemErrorName(err.errno), 'EINVAL');
|
||||
}));
|
||||
return true;
|
||||
},
|
||||
).then(common.mustCall());
|
||||
|
||||
assert.throws(() => {
|
||||
dns.reverse('bogus ip', common.mustNotCall());
|
||||
@@ -83,7 +85,7 @@ TEST(function test_reverse_bogus(done) {
|
||||
done();
|
||||
});
|
||||
|
||||
TEST(async function test_resolve4_ttl(done) {
|
||||
test(async function test_resolve4_ttl(done) {
|
||||
function validateResult(result) {
|
||||
assert.ok(result.length > 0);
|
||||
|
||||
@@ -102,16 +104,15 @@ TEST(async function test_resolve4_ttl(done) {
|
||||
|
||||
const req = dns.resolve4(addresses.INET4_HOST, {
|
||||
ttl: true,
|
||||
}, function(err, result) {
|
||||
assert.ifError(err);
|
||||
}, common.mustSucceed((result) => {
|
||||
validateResult(result);
|
||||
done();
|
||||
});
|
||||
}));
|
||||
|
||||
checkWrap(req);
|
||||
});
|
||||
|
||||
TEST(async function test_resolve6_ttl(done) {
|
||||
test(async function test_resolve6_ttl(done) {
|
||||
function validateResult(result) {
|
||||
assert.ok(result.length > 0);
|
||||
|
||||
@@ -130,16 +131,15 @@ TEST(async function test_resolve6_ttl(done) {
|
||||
|
||||
const req = dns.resolve6(addresses.INET6_HOST, {
|
||||
ttl: true,
|
||||
}, function(err, result) {
|
||||
assert.ifError(err);
|
||||
}, common.mustSucceed((result) => {
|
||||
validateResult(result);
|
||||
done();
|
||||
});
|
||||
}));
|
||||
|
||||
checkWrap(req);
|
||||
});
|
||||
|
||||
TEST(async function test_resolveMx(done) {
|
||||
test(async function test_resolveMx(done) {
|
||||
function validateResult(result) {
|
||||
assert.ok(result.length > 0);
|
||||
|
||||
@@ -153,35 +153,33 @@ TEST(async function test_resolveMx(done) {
|
||||
|
||||
validateResult(await dnsPromises.resolveMx(addresses.MX_HOST));
|
||||
|
||||
const req = dns.resolveMx(addresses.MX_HOST, function(err, result) {
|
||||
assert.ifError(err);
|
||||
const req = dns.resolveMx(addresses.MX_HOST, common.mustSucceed((result) => {
|
||||
validateResult(result);
|
||||
done();
|
||||
});
|
||||
}));
|
||||
|
||||
checkWrap(req);
|
||||
});
|
||||
|
||||
TEST(function test_resolveMx_failure(done) {
|
||||
dnsPromises.resolveMx(addresses.NOT_FOUND)
|
||||
.then(common.mustNotCall())
|
||||
.catch(common.mustCall((err) => {
|
||||
assert.strictEqual(err.code, 'ENOTFOUND');
|
||||
}));
|
||||
test(function test_resolveMx_failure(done) {
|
||||
assert.rejects(
|
||||
dnsPromises.resolveMx(addresses.NOT_FOUND),
|
||||
{ code: 'ENOTFOUND' },
|
||||
).then(common.mustCall());
|
||||
|
||||
const req = dns.resolveMx(addresses.NOT_FOUND, function(err, result) {
|
||||
const req = dns.resolveMx(addresses.NOT_FOUND, common.mustCall((err, result) => {
|
||||
assert.ok(err instanceof Error);
|
||||
assert.strictEqual(err.code, 'ENOTFOUND');
|
||||
|
||||
assert.strictEqual(result, undefined);
|
||||
|
||||
done();
|
||||
});
|
||||
}));
|
||||
|
||||
checkWrap(req);
|
||||
});
|
||||
|
||||
TEST(async function test_resolveNs(done) {
|
||||
test(async function test_resolveNs(done) {
|
||||
function validateResult(result) {
|
||||
assert.ok(result.length > 0);
|
||||
|
||||
@@ -193,35 +191,33 @@ TEST(async function test_resolveNs(done) {
|
||||
|
||||
validateResult(await dnsPromises.resolveNs(addresses.NS_HOST));
|
||||
|
||||
const req = dns.resolveNs(addresses.NS_HOST, function(err, names) {
|
||||
assert.ifError(err);
|
||||
const req = dns.resolveNs(addresses.NS_HOST, common.mustSucceed((names) => {
|
||||
validateResult(names);
|
||||
done();
|
||||
});
|
||||
}));
|
||||
|
||||
checkWrap(req);
|
||||
});
|
||||
|
||||
TEST(function test_resolveNs_failure(done) {
|
||||
dnsPromises.resolveNs(addresses.NOT_FOUND)
|
||||
.then(common.mustNotCall())
|
||||
.catch(common.mustCall((err) => {
|
||||
assert.strictEqual(err.code, 'ENOTFOUND');
|
||||
}));
|
||||
test(function test_resolveNs_failure(done) {
|
||||
assert.rejects(
|
||||
dnsPromises.resolveNs(addresses.NOT_FOUND),
|
||||
{ code: 'ENOTFOUND' },
|
||||
).then(common.mustCall());
|
||||
|
||||
const req = dns.resolveNs(addresses.NOT_FOUND, function(err, result) {
|
||||
const req = dns.resolveNs(addresses.NOT_FOUND, common.mustCall((err, result) => {
|
||||
assert.ok(err instanceof Error);
|
||||
assert.strictEqual(err.code, 'ENOTFOUND');
|
||||
|
||||
assert.strictEqual(result, undefined);
|
||||
|
||||
done();
|
||||
});
|
||||
}));
|
||||
|
||||
checkWrap(req);
|
||||
});
|
||||
|
||||
TEST(async function test_resolveSrv(done) {
|
||||
test(async function test_resolveSrv(done) {
|
||||
function validateResult(result) {
|
||||
assert.ok(result.length > 0);
|
||||
|
||||
@@ -237,35 +233,33 @@ TEST(async function test_resolveSrv(done) {
|
||||
|
||||
validateResult(await dnsPromises.resolveSrv(addresses.SRV_HOST));
|
||||
|
||||
const req = dns.resolveSrv(addresses.SRV_HOST, function(err, result) {
|
||||
assert.ifError(err);
|
||||
const req = dns.resolveSrv(addresses.SRV_HOST, common.mustSucceed((result) => {
|
||||
validateResult(result);
|
||||
done();
|
||||
});
|
||||
}));
|
||||
|
||||
checkWrap(req);
|
||||
});
|
||||
|
||||
TEST(function test_resolveSrv_failure(done) {
|
||||
dnsPromises.resolveSrv(addresses.NOT_FOUND)
|
||||
.then(common.mustNotCall())
|
||||
.catch(common.mustCall((err) => {
|
||||
assert.strictEqual(err.code, 'ENOTFOUND');
|
||||
}));
|
||||
test(function test_resolveSrv_failure(done) {
|
||||
assert.rejects(
|
||||
dnsPromises.resolveSrv(addresses.NOT_FOUND),
|
||||
{ code: 'ENOTFOUND' },
|
||||
).then(common.mustCall());
|
||||
|
||||
const req = dns.resolveSrv(addresses.NOT_FOUND, function(err, result) {
|
||||
const req = dns.resolveSrv(addresses.NOT_FOUND, common.mustCall((err, result) => {
|
||||
assert.ok(err instanceof Error);
|
||||
assert.strictEqual(err.code, 'ENOTFOUND');
|
||||
|
||||
assert.strictEqual(result, undefined);
|
||||
|
||||
done();
|
||||
});
|
||||
}));
|
||||
|
||||
checkWrap(req);
|
||||
});
|
||||
|
||||
TEST(async function test_resolvePtr(done) {
|
||||
test(async function test_resolvePtr(done) {
|
||||
function validateResult(result) {
|
||||
assert.ok(result.length > 0);
|
||||
|
||||
@@ -277,35 +271,33 @@ TEST(async function test_resolvePtr(done) {
|
||||
|
||||
validateResult(await dnsPromises.resolvePtr(addresses.PTR_HOST));
|
||||
|
||||
const req = dns.resolvePtr(addresses.PTR_HOST, function(err, result) {
|
||||
assert.ifError(err);
|
||||
const req = dns.resolvePtr(addresses.PTR_HOST, common.mustSucceed((result) => {
|
||||
validateResult(result);
|
||||
done();
|
||||
});
|
||||
}));
|
||||
|
||||
checkWrap(req);
|
||||
});
|
||||
|
||||
TEST(function test_resolvePtr_failure(done) {
|
||||
dnsPromises.resolvePtr(addresses.NOT_FOUND)
|
||||
.then(common.mustNotCall())
|
||||
.catch(common.mustCall((err) => {
|
||||
assert.strictEqual(err.code, 'ENOTFOUND');
|
||||
}));
|
||||
test(function test_resolvePtr_failure(done) {
|
||||
assert.rejects(
|
||||
dnsPromises.resolvePtr(addresses.NOT_FOUND),
|
||||
{ code: 'ENOTFOUND' },
|
||||
).then(common.mustCall());
|
||||
|
||||
const req = dns.resolvePtr(addresses.NOT_FOUND, function(err, result) {
|
||||
const req = dns.resolvePtr(addresses.NOT_FOUND, common.mustCall((err, result) => {
|
||||
assert.ok(err instanceof Error);
|
||||
assert.strictEqual(err.code, 'ENOTFOUND');
|
||||
|
||||
assert.strictEqual(result, undefined);
|
||||
|
||||
done();
|
||||
});
|
||||
}));
|
||||
|
||||
checkWrap(req);
|
||||
});
|
||||
|
||||
TEST(async function test_resolveNaptr(done) {
|
||||
test(async function test_resolveNaptr(done) {
|
||||
function validateResult(result) {
|
||||
assert.ok(result.length > 0);
|
||||
|
||||
@@ -322,35 +314,33 @@ TEST(async function test_resolveNaptr(done) {
|
||||
|
||||
validateResult(await dnsPromises.resolveNaptr(addresses.NAPTR_HOST));
|
||||
|
||||
const req = dns.resolveNaptr(addresses.NAPTR_HOST, function(err, result) {
|
||||
assert.ifError(err);
|
||||
const req = dns.resolveNaptr(addresses.NAPTR_HOST, common.mustSucceed((result) => {
|
||||
validateResult(result);
|
||||
done();
|
||||
});
|
||||
}));
|
||||
|
||||
checkWrap(req);
|
||||
});
|
||||
|
||||
TEST(function test_resolveNaptr_failure(done) {
|
||||
dnsPromises.resolveNaptr(addresses.NOT_FOUND)
|
||||
.then(common.mustNotCall())
|
||||
.catch(common.mustCall((err) => {
|
||||
assert.strictEqual(err.code, 'ENOTFOUND');
|
||||
}));
|
||||
test(function test_resolveNaptr_failure(done) {
|
||||
assert.rejects(
|
||||
dnsPromises.resolveNaptr(addresses.NOT_FOUND),
|
||||
{ code: 'ENOTFOUND' },
|
||||
).then(common.mustCall());
|
||||
|
||||
const req = dns.resolveNaptr(addresses.NOT_FOUND, function(err, result) {
|
||||
const req = dns.resolveNaptr(addresses.NOT_FOUND, common.mustCall((err, result) => {
|
||||
assert.ok(err instanceof Error);
|
||||
assert.strictEqual(err.code, 'ENOTFOUND');
|
||||
|
||||
assert.strictEqual(result, undefined);
|
||||
|
||||
done();
|
||||
});
|
||||
}));
|
||||
|
||||
checkWrap(req);
|
||||
});
|
||||
|
||||
TEST(async function test_resolveSoa(done) {
|
||||
test(async function test_resolveSoa(done) {
|
||||
function validateResult(result) {
|
||||
assert.strictEqual(typeof result, 'object');
|
||||
assert.strictEqual(typeof result.nsname, 'string');
|
||||
@@ -371,35 +361,33 @@ TEST(async function test_resolveSoa(done) {
|
||||
|
||||
validateResult(await dnsPromises.resolveSoa(addresses.SOA_HOST));
|
||||
|
||||
const req = dns.resolveSoa(addresses.SOA_HOST, function(err, result) {
|
||||
assert.ifError(err);
|
||||
const req = dns.resolveSoa(addresses.SOA_HOST, common.mustSucceed((result) => {
|
||||
validateResult(result);
|
||||
done();
|
||||
});
|
||||
}));
|
||||
|
||||
checkWrap(req);
|
||||
});
|
||||
|
||||
TEST(function test_resolveSoa_failure(done) {
|
||||
dnsPromises.resolveSoa(addresses.NOT_FOUND)
|
||||
.then(common.mustNotCall())
|
||||
.catch(common.mustCall((err) => {
|
||||
assert.strictEqual(err.code, 'ENOTFOUND');
|
||||
}));
|
||||
test(function test_resolveSoa_failure(done) {
|
||||
assert.rejects(
|
||||
dnsPromises.resolveSoa(addresses.NOT_FOUND),
|
||||
{ code: 'ENOTFOUND' },
|
||||
).then(common.mustCall());
|
||||
|
||||
const req = dns.resolveSoa(addresses.NOT_FOUND, function(err, result) {
|
||||
const req = dns.resolveSoa(addresses.NOT_FOUND, common.mustCall((err, result) => {
|
||||
assert.ok(err instanceof Error);
|
||||
assert.strictEqual(err.code, 'ENOTFOUND');
|
||||
|
||||
assert.strictEqual(result, undefined);
|
||||
|
||||
done();
|
||||
});
|
||||
}));
|
||||
|
||||
checkWrap(req);
|
||||
});
|
||||
|
||||
TEST(async function test_resolveCaa(done) {
|
||||
test(async function test_resolveCaa(done) {
|
||||
function validateResult(result) {
|
||||
assert.ok(Array.isArray(result),
|
||||
`expected array, got ${util.inspect(result)}`);
|
||||
@@ -411,35 +399,33 @@ TEST(async function test_resolveCaa(done) {
|
||||
|
||||
validateResult(await dnsPromises.resolveCaa(addresses.CAA_HOST));
|
||||
|
||||
const req = dns.resolveCaa(addresses.CAA_HOST, function(err, records) {
|
||||
assert.ifError(err);
|
||||
const req = dns.resolveCaa(addresses.CAA_HOST, common.mustSucceed((records) => {
|
||||
validateResult(records);
|
||||
done();
|
||||
});
|
||||
}));
|
||||
|
||||
checkWrap(req);
|
||||
});
|
||||
|
||||
TEST(function test_resolveCaa_failure(done) {
|
||||
dnsPromises.resolveTxt(addresses.NOT_FOUND)
|
||||
.then(common.mustNotCall())
|
||||
.catch(common.mustCall((err) => {
|
||||
assert.strictEqual(err.code, 'ENOTFOUND');
|
||||
}));
|
||||
test(function test_resolveCaa_failure(done) {
|
||||
assert.rejects(
|
||||
dnsPromises.resolveTxt(addresses.NOT_FOUND),
|
||||
{ code: 'ENOTFOUND' },
|
||||
).then(common.mustCall());
|
||||
|
||||
const req = dns.resolveCaa(addresses.NOT_FOUND, function(err, result) {
|
||||
const req = dns.resolveCaa(addresses.NOT_FOUND, common.mustCall((err, result) => {
|
||||
assert.ok(err instanceof Error);
|
||||
assert.strictEqual(err.code, 'ENOTFOUND');
|
||||
|
||||
assert.strictEqual(result, undefined);
|
||||
|
||||
done();
|
||||
});
|
||||
}));
|
||||
|
||||
checkWrap(req);
|
||||
});
|
||||
|
||||
TEST(async function test_resolveCname(done) {
|
||||
test(async function test_resolveCname(done) {
|
||||
function validateResult(result) {
|
||||
assert.ok(result.length > 0);
|
||||
|
||||
@@ -451,35 +437,33 @@ TEST(async function test_resolveCname(done) {
|
||||
|
||||
validateResult(await dnsPromises.resolveCname(addresses.CNAME_HOST));
|
||||
|
||||
const req = dns.resolveCname(addresses.CNAME_HOST, function(err, names) {
|
||||
assert.ifError(err);
|
||||
const req = dns.resolveCname(addresses.CNAME_HOST, common.mustSucceed((names) => {
|
||||
validateResult(names);
|
||||
done();
|
||||
});
|
||||
}));
|
||||
|
||||
checkWrap(req);
|
||||
});
|
||||
|
||||
TEST(function test_resolveCname_failure(done) {
|
||||
dnsPromises.resolveCname(addresses.NOT_FOUND)
|
||||
.then(common.mustNotCall())
|
||||
.catch(common.mustCall((err) => {
|
||||
assert.strictEqual(err.code, 'ENOTFOUND');
|
||||
}));
|
||||
test(function test_resolveCname_failure(done) {
|
||||
assert.rejects(
|
||||
dnsPromises.resolveCname(addresses.NOT_FOUND),
|
||||
{ code: 'ENOTFOUND' },
|
||||
).then(common.mustCall());
|
||||
|
||||
const req = dns.resolveCname(addresses.NOT_FOUND, function(err, result) {
|
||||
const req = dns.resolveCname(addresses.NOT_FOUND, common.mustCall((err, result) => {
|
||||
assert.ok(err instanceof Error);
|
||||
assert.strictEqual(err.code, 'ENOTFOUND');
|
||||
|
||||
assert.strictEqual(result, undefined);
|
||||
|
||||
done();
|
||||
});
|
||||
}));
|
||||
|
||||
checkWrap(req);
|
||||
});
|
||||
|
||||
TEST(async function test_resolveTlsa(done) {
|
||||
test(async function test_resolveTlsa(done) {
|
||||
function validateResult(result) {
|
||||
assert.ok(Array.isArray(result));
|
||||
assert.ok(result.length >= 1);
|
||||
@@ -493,35 +477,33 @@ TEST(async function test_resolveTlsa(done) {
|
||||
|
||||
validateResult(await dnsPromises.resolveTlsa(addresses.TLSA_HOST));
|
||||
|
||||
const req = dns.resolveTlsa(addresses.TLSA_HOST, function(err, records) {
|
||||
assert.ifError(err);
|
||||
const req = dns.resolveTlsa(addresses.TLSA_HOST, common.mustSucceed((records) => {
|
||||
validateResult(records);
|
||||
done();
|
||||
});
|
||||
}));
|
||||
|
||||
checkWrap(req);
|
||||
});
|
||||
|
||||
TEST(function test_resolveTlsa_failure(done) {
|
||||
dnsPromises.resolveTlsa(addresses.NOT_FOUND)
|
||||
.then(common.mustNotCall())
|
||||
.catch(common.mustCall((err) => {
|
||||
assert.strictEqual(err.code, 'ENOTFOUND');
|
||||
}));
|
||||
test(function test_resolveTlsa_failure(done) {
|
||||
assert.rejects(
|
||||
dnsPromises.resolveTlsa(addresses.NOT_FOUND),
|
||||
{ code: 'ENOTFOUND' },
|
||||
).then(common.mustCall());
|
||||
|
||||
const req = dns.resolveTlsa(addresses.NOT_FOUND, function(err, result) {
|
||||
const req = dns.resolveTlsa(addresses.NOT_FOUND, common.mustCall((err, result) => {
|
||||
assert.ok(err instanceof Error);
|
||||
assert.strictEqual(err.code, 'ENOTFOUND');
|
||||
|
||||
assert.strictEqual(result, undefined);
|
||||
|
||||
done();
|
||||
});
|
||||
}));
|
||||
|
||||
checkWrap(req);
|
||||
});
|
||||
|
||||
TEST(async function test_resolveTxt(done) {
|
||||
test(async function test_resolveTxt(done) {
|
||||
function validateResult(result) {
|
||||
assert.ok(result.length > 0);
|
||||
assert.ok(result.every((elem) => Array.isArray(elem) && elem.length === 1));
|
||||
@@ -530,41 +512,40 @@ TEST(async function test_resolveTxt(done) {
|
||||
|
||||
validateResult(await dnsPromises.resolveTxt(addresses.TXT_HOST));
|
||||
|
||||
const req = dns.resolveTxt(addresses.TXT_HOST, function(err, records) {
|
||||
assert.ifError(err);
|
||||
const req = dns.resolveTxt(addresses.TXT_HOST, common.mustSucceed((records) => {
|
||||
validateResult(records);
|
||||
done();
|
||||
});
|
||||
}));
|
||||
|
||||
checkWrap(req);
|
||||
});
|
||||
|
||||
TEST(function test_resolveTxt_failure(done) {
|
||||
dnsPromises.resolveTxt(addresses.NOT_FOUND)
|
||||
.then(common.mustNotCall())
|
||||
.catch(common.mustCall((err) => {
|
||||
assert.strictEqual(err.code, 'ENOTFOUND');
|
||||
}));
|
||||
test(function test_resolveTxt_failure(done) {
|
||||
assert.rejects(
|
||||
dnsPromises.resolveTxt(addresses.NOT_FOUND),
|
||||
{ code: 'ENOTFOUND' },
|
||||
).then(common.mustCall());
|
||||
|
||||
const req = dns.resolveTxt(addresses.NOT_FOUND, function(err, result) {
|
||||
const req = dns.resolveTxt(addresses.NOT_FOUND, common.mustCall((err, result) => {
|
||||
assert.ok(err instanceof Error);
|
||||
assert.strictEqual(err.code, 'ENOTFOUND');
|
||||
|
||||
assert.strictEqual(result, undefined);
|
||||
|
||||
done();
|
||||
});
|
||||
}));
|
||||
|
||||
checkWrap(req);
|
||||
});
|
||||
|
||||
|
||||
TEST(function test_lookup_failure(done) {
|
||||
dnsPromises.lookup(addresses.NOT_FOUND, 4)
|
||||
.then(common.mustNotCall())
|
||||
.catch(common.expectsError({ code: dns.NOTFOUND }));
|
||||
test(function test_lookup_failure(done) {
|
||||
assert.rejects(
|
||||
dnsPromises.lookup(addresses.NOT_FOUND, 4),
|
||||
{ code: dns.NOTFOUND },
|
||||
).then(common.mustCall());
|
||||
|
||||
const req = dns.lookup(addresses.NOT_FOUND, 4, (err) => {
|
||||
const req = dns.lookup(addresses.NOT_FOUND, 4, common.mustCall((err) => {
|
||||
assert.ok(err instanceof Error);
|
||||
assert.strictEqual(err.code, dns.NOTFOUND);
|
||||
assert.strictEqual(err.code, 'ENOTFOUND');
|
||||
@@ -572,13 +553,13 @@ TEST(function test_lookup_failure(done) {
|
||||
assert.ok(err.message.includes(addresses.NOT_FOUND));
|
||||
|
||||
done();
|
||||
});
|
||||
}));
|
||||
|
||||
checkWrap(req);
|
||||
});
|
||||
|
||||
|
||||
TEST(async function test_lookup_ip_all(done) {
|
||||
test(async function test_lookup_ip_all(done) {
|
||||
function validateResult(result) {
|
||||
assert.ok(Array.isArray(result));
|
||||
assert.ok(result.length > 0);
|
||||
@@ -591,19 +572,18 @@ TEST(async function test_lookup_ip_all(done) {
|
||||
const req = dns.lookup(
|
||||
'127.0.0.1',
|
||||
{ all: true },
|
||||
function(err, ips, family) {
|
||||
assert.ifError(err);
|
||||
common.mustSucceed((ips, family) => {
|
||||
assert.strictEqual(family, undefined);
|
||||
validateResult(ips);
|
||||
done();
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
checkWrap(req);
|
||||
});
|
||||
|
||||
|
||||
TEST(function test_lookup_ip_all_promise(done) {
|
||||
test(function test_lookup_ip_all_promise(done) {
|
||||
const req = util.promisify(dns.lookup)('127.0.0.1', { all: true })
|
||||
.then(function(ips) {
|
||||
assert.ok(Array.isArray(ips));
|
||||
@@ -618,7 +598,7 @@ TEST(function test_lookup_ip_all_promise(done) {
|
||||
});
|
||||
|
||||
|
||||
TEST(function test_lookup_ip_promise(done) {
|
||||
test(function test_lookup_ip_promise(done) {
|
||||
util.promisify(dns.lookup)('127.0.0.1')
|
||||
.then(function({ address, family }) {
|
||||
assert.strictEqual(address, '127.0.0.1');
|
||||
@@ -629,22 +609,23 @@ TEST(function test_lookup_ip_promise(done) {
|
||||
});
|
||||
|
||||
|
||||
TEST(async function test_lookup_null_all(done) {
|
||||
test(async function test_lookup_null_all(done) {
|
||||
assert.deepStrictEqual(await dnsPromises.lookup(null, { all: true }), []);
|
||||
|
||||
const req = dns.lookup(null, { all: true }, (err, ips) => {
|
||||
assert.ifError(err);
|
||||
const req = dns.lookup(null, {
|
||||
all: true,
|
||||
}, common.mustSucceed((ips) => {
|
||||
assert.ok(Array.isArray(ips));
|
||||
assert.strictEqual(ips.length, 0);
|
||||
|
||||
done();
|
||||
});
|
||||
}));
|
||||
|
||||
checkWrap(req);
|
||||
});
|
||||
|
||||
|
||||
TEST(async function test_lookup_all_mixed(done) {
|
||||
test(async function test_lookup_all_mixed(done) {
|
||||
function validateResult(result) {
|
||||
assert.ok(Array.isArray(result));
|
||||
assert.ok(result.length > 0);
|
||||
@@ -663,78 +644,80 @@ TEST(async function test_lookup_all_mixed(done) {
|
||||
|
||||
const req = dns.lookup(addresses.INET_HOST, {
|
||||
all: true,
|
||||
}, function(err, ips) {
|
||||
assert.ifError(err);
|
||||
}, common.mustSucceed((ips) => {
|
||||
validateResult(ips);
|
||||
done();
|
||||
});
|
||||
}));
|
||||
|
||||
checkWrap(req);
|
||||
});
|
||||
|
||||
|
||||
TEST(function test_lookupservice_invalid(done) {
|
||||
dnsPromises.lookupService('1.2.3.4', 80)
|
||||
.then(common.mustNotCall())
|
||||
.catch(common.expectsError({ code: 'ENOTFOUND' }));
|
||||
test(function test_lookupservice_invalid(done) {
|
||||
assert.rejects(
|
||||
dnsPromises.lookupService('1.2.3.4', 80),
|
||||
{ code: 'ENOTFOUND' },
|
||||
).then(common.mustCall());
|
||||
|
||||
const req = dns.lookupService('1.2.3.4', 80, (err) => {
|
||||
const req = dns.lookupService('1.2.3.4', 80, common.mustCall((err) => {
|
||||
assert(err instanceof Error);
|
||||
assert.strictEqual(err.code, 'ENOTFOUND');
|
||||
assert.match(err.message, /1\.2\.3\.4/);
|
||||
|
||||
done();
|
||||
});
|
||||
}));
|
||||
|
||||
checkWrap(req);
|
||||
});
|
||||
|
||||
|
||||
TEST(function test_reverse_failure(done) {
|
||||
dnsPromises.reverse('203.0.113.0')
|
||||
.then(common.mustNotCall())
|
||||
.catch(common.expectsError({
|
||||
test(function test_reverse_failure(done) {
|
||||
assert.rejects(
|
||||
dnsPromises.reverse('203.0.113.0'),
|
||||
{
|
||||
code: 'ENOTFOUND',
|
||||
hostname: '203.0.113.0',
|
||||
}));
|
||||
},
|
||||
).then(common.mustCall());
|
||||
|
||||
// 203.0.113.0/24 are addresses reserved for (RFC) documentation use only
|
||||
const req = dns.reverse('203.0.113.0', function(err) {
|
||||
const req = dns.reverse('203.0.113.0', common.mustCall((err) => {
|
||||
assert(err instanceof Error);
|
||||
assert.strictEqual(err.code, 'ENOTFOUND'); // Silly error code...
|
||||
assert.strictEqual(err.hostname, '203.0.113.0');
|
||||
assert.match(err.message, /203\.0\.113\.0/);
|
||||
|
||||
done();
|
||||
});
|
||||
}));
|
||||
|
||||
checkWrap(req);
|
||||
});
|
||||
|
||||
|
||||
TEST(function test_lookup_failure(done) {
|
||||
dnsPromises.lookup(addresses.NOT_FOUND)
|
||||
.then(common.mustNotCall())
|
||||
.catch(common.expectsError({
|
||||
test(function test_lookup_failure(done) {
|
||||
assert.rejects(
|
||||
dnsPromises.lookup(addresses.NOT_FOUND),
|
||||
{
|
||||
code: 'ENOTFOUND',
|
||||
hostname: addresses.NOT_FOUND,
|
||||
}));
|
||||
},
|
||||
).then(common.mustCall());
|
||||
|
||||
const req = dns.lookup(addresses.NOT_FOUND, (err) => {
|
||||
const req = dns.lookup(addresses.NOT_FOUND, common.mustCall((err) => {
|
||||
assert(err instanceof Error);
|
||||
assert.strictEqual(err.code, 'ENOTFOUND'); // Silly error code...
|
||||
assert.strictEqual(err.hostname, addresses.NOT_FOUND);
|
||||
assert.ok(err.message.includes(addresses.NOT_FOUND));
|
||||
|
||||
done();
|
||||
});
|
||||
}));
|
||||
|
||||
checkWrap(req);
|
||||
});
|
||||
|
||||
|
||||
TEST(function test_resolve_failure(done) {
|
||||
const req = dns.resolve4(addresses.NOT_FOUND, (err) => {
|
||||
test(function test_resolve_failure(done) {
|
||||
const req = dns.resolve4(addresses.NOT_FOUND, common.mustCall((err) => {
|
||||
assert(err instanceof Error);
|
||||
|
||||
switch (err.code) {
|
||||
@@ -750,7 +733,7 @@ TEST(function test_resolve_failure(done) {
|
||||
assert.ok(err.message.includes(addresses.NOT_FOUND));
|
||||
|
||||
done();
|
||||
});
|
||||
}));
|
||||
|
||||
checkWrap(req);
|
||||
});
|
||||
@@ -765,14 +748,14 @@ const req = new cares.GetAddrInfoReqWrap();
|
||||
cares.getaddrinfo(req, addresses.INET4_HOST, 4,
|
||||
/* hints */ 0, /* order */ cares.DNS_ORDER_VERBATIM);
|
||||
|
||||
req.oncomplete = function(err, domains) {
|
||||
req.oncomplete = common.mustCallAtLeast((err, domains) => {
|
||||
assert.strictEqual(err, 0);
|
||||
console.log(`${addresses.INET4_HOST} = ${domains}`);
|
||||
assert.ok(Array.isArray(domains));
|
||||
assert.ok(domains.length >= 1);
|
||||
assert.strictEqual(typeof domains[0], 'string');
|
||||
getaddrinfoCallbackCalled = true;
|
||||
};
|
||||
});
|
||||
|
||||
process.on('exit', function() {
|
||||
console.log(`${completed} tests completed`);
|
||||
|
||||
@@ -13,8 +13,8 @@ request(
|
||||
`https://${addresses.INET_HOST}/en`,
|
||||
// Purposely set this to a low value because we want all connection but the last to fail
|
||||
{ autoSelectFamily: true, autoSelectFamilyAttemptTimeout: 10 },
|
||||
(res) => {
|
||||
common.mustCall((res) => {
|
||||
assert.strictEqual(res.statusCode, 200);
|
||||
res.resume();
|
||||
},
|
||||
}),
|
||||
).end();
|
||||
@@ -18,7 +18,7 @@ server.on(
|
||||
}),
|
||||
);
|
||||
|
||||
server.listen(0, () => {
|
||||
server.listen(0, common.mustCallAtLeast(() => {
|
||||
const req = https.request({
|
||||
hostname: '127.0.0.1',
|
||||
port: server.address().port,
|
||||
@@ -28,4 +28,4 @@ server.listen(0, () => {
|
||||
common.mustCall(() => server.close()),
|
||||
);
|
||||
req.end();
|
||||
});
|
||||
}));
|
||||
@@ -28,15 +28,15 @@ const { createConnection } = require('net');
|
||||
autoSelectFamilyAttemptTimeout: 10,
|
||||
});
|
||||
|
||||
connection.on('connectionAttempt', (address, port, family) => {
|
||||
connection.on('connectionAttempt', common.mustCallAtLeast((address, port, family) => {
|
||||
assert.strictEqual(address, INET4_IP);
|
||||
assert.strictEqual(port, 10);
|
||||
assert.strictEqual(family, 4);
|
||||
|
||||
pass();
|
||||
});
|
||||
}, 0));
|
||||
|
||||
connection.on('connectionAttemptFailed', (address, port, family, error) => {
|
||||
connection.on('connectionAttemptFailed', common.mustCallAtLeast((address, port, family, error) => {
|
||||
assert.strictEqual(address, INET4_IP);
|
||||
assert.strictEqual(port, 10);
|
||||
assert.strictEqual(family, 4);
|
||||
@@ -47,7 +47,7 @@ const { createConnection } = require('net');
|
||||
);
|
||||
|
||||
pass();
|
||||
});
|
||||
}, 0));
|
||||
|
||||
connection.on('ready', () => {
|
||||
pass();
|
||||
@@ -85,7 +85,7 @@ const { createConnection } = require('net');
|
||||
{ address: INET4_IP, port: 10, family: 4 },
|
||||
];
|
||||
|
||||
connection.on('connectionAttempt', (address, port, family) => {
|
||||
connection.on('connectionAttempt', common.mustCallAtLeast((address, port, family) => {
|
||||
const expected = addresses.shift();
|
||||
|
||||
assert.strictEqual(address, expected.address);
|
||||
@@ -93,9 +93,9 @@ const { createConnection } = require('net');
|
||||
assert.strictEqual(family, expected.family);
|
||||
|
||||
pass();
|
||||
});
|
||||
}, 0));
|
||||
|
||||
connection.on('connectionAttemptFailed', (address, port, family, error) => {
|
||||
connection.on('connectionAttemptFailed', common.mustCallAtLeast((address, port, family, error) => {
|
||||
const expected = addresses.shift();
|
||||
|
||||
assert.strictEqual(address, expected.address);
|
||||
@@ -108,7 +108,7 @@ const { createConnection } = require('net');
|
||||
);
|
||||
|
||||
pass();
|
||||
});
|
||||
}, 0));
|
||||
|
||||
connection.on('ready', () => {
|
||||
pass();
|
||||
|
||||
@@ -34,13 +34,13 @@ const { createConnection } = require('net');
|
||||
|
||||
const pass = common.mustCall();
|
||||
|
||||
connection.on('connectionAttemptTimeout', (address, port, family) => {
|
||||
connection.on('connectionAttemptTimeout', common.mustCallAtLeast((address, port, family) => {
|
||||
assert.strictEqual(address, INET4_IP);
|
||||
assert.strictEqual(port, 443);
|
||||
assert.strictEqual(family, 4);
|
||||
connection.destroy();
|
||||
pass();
|
||||
});
|
||||
}, 0));
|
||||
|
||||
connection.on('ready', () => {
|
||||
pass();
|
||||
|
||||
Reference in new issue
Block a user