aboutsummaryrefslogtreecommitdiff
path: root/test/parallel/test-net-dns-error.js
blob: eed59cddebb851e39a1a8e6013aaa626d876762a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
'use strict';
require('../common');
var assert = require('assert');

var net = require('net');

var expected_bad_connections = 1;
var actual_bad_connections = 0;

var host = '*'.repeat(256);

function do_not_call() {
  throw new Error('This function should not have been called.');
}

var socket = net.connect(42, host, do_not_call);
socket.on('error', function(err) {
  assert.equal(err.code, 'ENOTFOUND');
  actual_bad_connections++;
});
socket.on('lookup', function(err, ip, type) {
  assert(err instanceof Error);
  assert.equal(err.code, 'ENOTFOUND');
  assert.equal(ip, undefined);
  assert.equal(type, undefined);
});

process.on('exit', function() {
  assert.equal(actual_bad_connections, expected_bad_connections);
});