Skip to content

Commit

Permalink
test: use reserved invalid hostname for tests
Browse files Browse the repository at this point in the history
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 jasnell committed Sep 25, 2017
1 parent 2944ea6 commit 58b9495
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
4 changes: 2 additions & 2 deletions test/parallel/test-net-better-error-messages-port-hostname.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}));
7 changes: 5 additions & 2 deletions test/parallel/test-net-connect-immediate-finish.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}));

Expand Down

0 comments on commit 58b9495

Please sign in to comment.