Skip to content

Commit 9cdceac

Browse files
thefourtheyeFishrock123
authored andcommitted
test: use really invalid hostname
On my slow Ubuntu 14.04 machine, this fails to resolve the host name used (`no.way.you.will.resolve.this`) and it times out in local testing. This patch uses an invalid name (`...`) and does stricter validation of the error returned. PR-URL: #3711 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Evan Lucas <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 2498e29 commit 9cdceac

File tree

1 file changed

+12
-16
lines changed

1 file changed

+12
-16
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,17 @@
11
'use strict';
2-
var common = require('../common');
3-
var assert = require('assert');
4-
var net = require('net');
2+
const common = require('../common');
3+
const assert = require('assert');
4+
const net = require('net');
55

6-
var gotError = false;
6+
const client = net.connect({host: '...', port: common.PORT});
77

8-
var client = net.connect({
9-
host: 'no.way.you.will.resolve.this',
10-
port: common.PORT
11-
});
12-
13-
client.once('error', function(err) {
14-
gotError = true;
15-
});
8+
client.once('error', common.mustCall(function(err) {
9+
assert(err);
10+
assert.strictEqual(err.code, err.errno);
11+
assert.strictEqual(err.code, 'ENOTFOUND');
12+
assert.strictEqual(err.host, err.hostname);
13+
assert.strictEqual(err.host, '...');
14+
assert.strictEqual(err.syscall, 'getaddrinfo');
15+
}));
1616

1717
client.end();
18-
19-
process.on('exit', function() {
20-
assert(gotError);
21-
});

0 commit comments

Comments
 (0)