2015-05-19 13:00:06 +02:00
|
|
|
'use strict';
|
2013-05-24 23:02:34 +02:00
|
|
|
var common = require('../common');
|
2015-03-04 02:11:21 +01:00
|
|
|
var assert = require('assert');
|
|
|
|
|
|
|
|
if (!common.hasCrypto) {
|
|
|
|
console.log('1..0 # Skipped: missing crypto');
|
2015-07-07 17:25:55 +02:00
|
|
|
return;
|
2015-03-04 02:11:21 +01:00
|
|
|
}
|
2013-05-24 23:02:34 +02:00
|
|
|
var tls = require('tls');
|
2015-03-04 02:11:21 +01:00
|
|
|
|
2013-05-24 23:02:34 +02:00
|
|
|
var net = require('net');
|
|
|
|
var fs = require('fs');
|
|
|
|
|
|
|
|
var options = {
|
|
|
|
key: fs.readFileSync(common.fixturesDir + '/test_key.pem'),
|
|
|
|
cert: fs.readFileSync(common.fixturesDir + '/test_cert.pem')
|
|
|
|
};
|
|
|
|
|
2013-07-01 23:29:15 +02:00
|
|
|
var bonkers = new Buffer(1024 * 1024);
|
|
|
|
bonkers.fill(42);
|
|
|
|
|
2013-05-24 23:02:34 +02:00
|
|
|
var server = tls.createServer(options, function(c) {
|
|
|
|
|
|
|
|
}).listen(common.PORT, function() {
|
|
|
|
var client = net.connect(common.PORT, function() {
|
2013-07-01 23:29:15 +02:00
|
|
|
client.write(bonkers);
|
2013-05-24 23:02:34 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
var once = false;
|
2013-07-01 23:29:15 +02:00
|
|
|
|
2013-07-10 09:48:55 +02:00
|
|
|
var writeAgain = setTimeout(function() {
|
|
|
|
client.write(bonkers);
|
|
|
|
});
|
2013-07-01 23:29:15 +02:00
|
|
|
|
|
|
|
client.on('error', function(err) {
|
2013-05-24 23:02:34 +02:00
|
|
|
if (!once) {
|
2013-07-10 09:48:55 +02:00
|
|
|
clearTimeout(writeAgain);
|
2013-05-24 23:02:34 +02:00
|
|
|
once = true;
|
|
|
|
client.destroy();
|
|
|
|
server.close();
|
|
|
|
}
|
|
|
|
});
|
2013-07-01 23:29:15 +02:00
|
|
|
|
2015-05-19 13:00:06 +02:00
|
|
|
client.on('close', function(hadError) {
|
2013-07-10 09:48:55 +02:00
|
|
|
assert.strictEqual(hadError, true, 'Client never errored');
|
|
|
|
});
|
2013-05-24 23:02:34 +02:00
|
|
|
});
|