• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2
3const common = require('../common');
4if (!common.hasCrypto)
5  common.skip('missing crypto');
6
7const assert = require('assert');
8const net = require('net');
9const tls = require('tls');
10
11const server = net.createServer((c) => {
12  c.end();
13}).listen(common.mustCall(() => {
14  const port = server.address().port;
15
16  let errored = false;
17  tls.connect({
18    port: port,
19    family: 4,
20    localAddress: common.localhostIPv4
21  }, common.localhostIPv4)
22    .once('error', common.mustCall((e) => {
23      assert.strictEqual(e.code, 'ECONNRESET');
24      assert.strictEqual(e.path, undefined);
25      assert.strictEqual(e.host, undefined);
26      assert.strictEqual(e.port, port);
27      assert.strictEqual(e.localAddress, common.localhostIPv4);
28      server.close();
29      errored = true;
30    }))
31    .on('close', common.mustCall(() => {
32      assert.strictEqual(errored, true);
33    }));
34}));
35