summaryrefslogtreecommitdiff
path: root/test/parallel/test-tls-wrap-econnreset-localaddress.js
blob: 9df145ac374ab73d97aa05698edb2b91e23c3e9c (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
'use strict';

const common = require('../common');
if (!common.hasCrypto)
  common.skip('missing crypto');

const assert = require('assert');
const net = require('net');
const tls = require('tls');

const server = net.createServer((c) => {
  c.end();
}).listen(common.mustCall(() => {
  const port = server.address().port;

  tls.connect({
    port: port,
    localAddress: common.localhostIPv4
  }, common.localhostIPv4)
    .once('error', common.mustCall((e) => {
      assert.strictEqual(e.code, 'ECONNRESET');
      assert.strictEqual(e.path, undefined);
      assert.strictEqual(e.host, undefined);
      assert.strictEqual(e.port, port);
      assert.strictEqual(e.localAddress, common.localhostIPv4);
      server.close();
    }));
}));