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(port, common.localhostIPv4) 18 .once('error', common.mustCall((e) => { 19 assert.strictEqual(e.code, 'ECONNRESET'); 20 assert.strictEqual(e.path, undefined); 21 assert.strictEqual(e.host, common.localhostIPv4); 22 assert.strictEqual(e.port, port); 23 assert.strictEqual(e.localAddress, undefined); 24 server.close(); 25 errored = true; 26 })) 27 .on('close', common.mustCall(() => { 28 assert.strictEqual(errored, true); 29 })); 30})); 31