From 9cdceac782e0327951702cd3cd68771cf88c132e Mon Sep 17 00:00:00 2001 From: Sakthipriyan Vairamani Date: Sun, 8 Nov 2015 16:31:51 +0530 Subject: [PATCH] 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: https://github.com/nodejs/node/pull/3711 Reviewed-By: Ben Noordhuis Reviewed-By: Evan Lucas Reviewed-By: James M Snell --- .../test-net-connect-immediate-finish.js | 28 ++++++++----------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/test/parallel/test-net-connect-immediate-finish.js b/test/parallel/test-net-connect-immediate-finish.js index 086cf910422372..a5403732ec1d0d 100644 --- a/test/parallel/test-net-connect-immediate-finish.js +++ b/test/parallel/test-net-connect-immediate-finish.js @@ -1,21 +1,17 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); -var net = require('net'); +const common = require('../common'); +const assert = require('assert'); +const net = require('net'); -var gotError = false; +const client = net.connect({host: '...', port: common.PORT}); -var client = net.connect({ - host: 'no.way.you.will.resolve.this', - port: common.PORT -}); - -client.once('error', function(err) { - gotError = true; -}); +client.once('error', common.mustCall(function(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.syscall, 'getaddrinfo'); +})); client.end(); - -process.on('exit', function() { - assert(gotError); -});