• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2
3const common = require('../common');
4
5const assert = require('assert');
6const dnsPromises = require('dns').promises;
7
8dnsPromises.lookupService('127.0.0.1', 22).then(common.mustCall((result) => {
9  assert.strictEqual(result.service, 'ssh');
10  assert.strictEqual(typeof result.hostname, 'string');
11  assert.notStrictEqual(result.hostname.length, 0);
12}));
13
14// Use an IP from the RFC 5737 test range to cause an error.
15// Refs: https://tools.ietf.org/html/rfc5737
16assert.rejects(
17  () => dnsPromises.lookupService('192.0.2.1', 22),
18  { code: /^(?:ENOTFOUND|EAI_AGAIN)$/ }
19);
20