summaryrefslogtreecommitdiff
path: root/test/internet
diff options
context:
space:
mode:
authorRich Trott <rtrott@gmail.com>2020-05-12 06:39:00 -0700
committerRich Trott <rtrott@gmail.com>2020-05-15 05:48:48 -0700
commit23a61eb683bcfb147ca1040e36c70fe366452a77 (patch)
tree6dee6f3f50f0ba8c5a4d37f0b6e482a4f8339311 /test/internet
parent2d5d77306f6dff9110c1f77fefab25f973415770 (diff)
downloadnode-new-23a61eb683bcfb147ca1040e36c70fe366452a77.tar.gz
test: fix test-dns-idna2008
The DNS server will sometimes return an IPv6 address (as seen in nightly CI from time to time). Use `family` option to force IPv4. PR-URL: https://github.com/nodejs/node/pull/33367 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Diffstat (limited to 'test/internet')
-rw-r--r--test/internet/test-dns-idna2008.js44
1 files changed, 25 insertions, 19 deletions
diff --git a/test/internet/test-dns-idna2008.js b/test/internet/test-dns-idna2008.js
index 5a6a48b6fa..88c156303a 100644
--- a/test/internet/test-dns-idna2008.js
+++ b/test/internet/test-dns-idna2008.js
@@ -16,31 +16,37 @@ const { addresses } = require('../common/internet');
const fixture = {
hostname: 'straße.de',
expectedAddress: '81.169.145.78',
- dnsServer: addresses.DNS4_SERVER
+ dnsServer: addresses.DNS4_SERVER,
+ family: 4,
};
-// Explicitly use well behaved DNS servers that are known to be able to resolve
+// Explicitly use well-behaved DNS servers that are known to be able to resolve
// the query (which is a.k.a xn--strae-oqa.de).
dns.setServers([fixture.dnsServer]);
-dns.lookup(fixture.hostname, mustCall((err, address) => {
- if (err && err.errno === 'ESERVFAIL') {
- assert.ok(err.message.includes('queryA ESERVFAIL straße.de'));
- return;
- }
- assert.ifError(err);
- assert.strictEqual(address, fixture.expectedAddress);
-}));
+dns.lookup(
+ fixture.hostname,
+ { family: fixture.family },
+ mustCall((err, address) => {
+ if (err && err.errno === 'ESERVFAIL') {
+ assert.ok(err.message.includes('queryA ESERVFAIL straße.de'));
+ return;
+ }
+ assert.ifError(err);
+ assert.strictEqual(address, fixture.expectedAddress);
+ })
+);
-dns.promises.lookup(fixture.hostname).then(({ address }) => {
- assert.strictEqual(address, fixture.expectedAddress);
-}, (err) => {
- if (err && err.errno === 'ESERVFAIL') {
- assert.ok(err.message.includes('queryA ESERVFAIL straße.de'));
- } else {
- throw err;
- }
-}).finally(mustCall());
+dns.promises.lookup(fixture.hostname, { family: fixture.family })
+ .then(({ address }) => {
+ assert.strictEqual(address, fixture.expectedAddress);
+ }, (err) => {
+ if (err && err.errno === 'ESERVFAIL') {
+ assert.ok(err.message.includes('queryA ESERVFAIL straße.de'));
+ } else {
+ throw err;
+ }
+ }).finally(mustCall());
dns.resolve4(fixture.hostname, mustCall((err, addresses) => {
if (err && err.errno === 'ESERVFAIL') {