2016-11-12 22:08:59 +01:00
|
|
|
'use strict';
|
|
|
|
const common = require('../common');
|
|
|
|
|
2017-07-01 01:29:09 +02:00
|
|
|
if (!common.hasCrypto)
|
2016-11-12 22:08:59 +01:00
|
|
|
common.skip('missing crypto');
|
|
|
|
|
|
|
|
const assert = require('assert');
|
|
|
|
const net = require('net');
|
|
|
|
const tls = require('tls');
|
|
|
|
|
|
|
|
const server = net.createServer(common.mustCall((c) => {
|
|
|
|
c.destroy();
|
|
|
|
})).listen(0, common.mustCall(() => {
|
|
|
|
const c = tls.connect({ port: server.address().port });
|
|
|
|
c.on('error', () => {
|
|
|
|
// Otherwise `.write()` callback won't be invoked.
|
2017-05-06 14:20:52 +02:00
|
|
|
c._undestroy();
|
2016-11-12 22:08:59 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
c.write('hello', common.mustCall((err) => {
|
2016-11-17 21:32:27 +01:00
|
|
|
assert.strictEqual(err.code, 'ECANCELED');
|
2016-11-12 22:08:59 +01:00
|
|
|
server.close();
|
|
|
|
}));
|
|
|
|
}));
|