Permalink
Browse files

test: use reserved invalid hostname for tests

PR-URL: #14781
Refs: https://tools.ietf.org/html/rfc2606#section-2
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
  • Loading branch information...
icarter09 authored and tniessen committed Aug 12, 2017
1 parent 4f1eddf commit 0309619aa74206baee301946177de47cc4f61ed9
@@ -4,12 +4,12 @@ const net = require('net');
const assert = require('assert');
// Using port 0 as hostname used is already invalid.
const c = net.createConnection(0, '***');
const c = net.createConnection(0, 'this.hostname.is.invalid');
c.on('connect', common.mustNotCall());
c.on('error', common.mustCall(function(e) {
assert.strictEqual(e.code, 'ENOTFOUND');
assert.strictEqual(e.port, 0);
assert.strictEqual(e.hostname, '***');
assert.strictEqual(e.hostname, 'this.hostname.is.invalid');
}));
@@ -24,14 +24,17 @@ const common = require('../common');
const assert = require('assert');
const net = require('net');
const client = net.connect({ host: '***', port: common.PORT });
const client = net.connect({
host: 'this.hostname.is.invalid',
port: common.PORT
});
client.once('error', common.mustCall((err) => {
assert(err);
assert.strictEqual(err.code, err.errno);
assert.strictEqual(err.code, 'ENOTFOUND');
assert.strictEqual(err.host, err.hostname);
assert.strictEqual(err.host, '***');
assert.strictEqual(err.host, 'this.hostname.is.invalid');
assert.strictEqual(err.syscall, 'getaddrinfo');
}));

0 comments on commit 0309619

Please sign in to comment.