mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
f29762f4dd
Enable linting for the test directory. A number of changes was made so all tests conform the current rules used by lib and src directories. The only exception for tests is that unreachable (dead) code is allowed. test-fs-non-number-arguments-throw had to be excluded from the changes because of a weird issue on Windows CI. PR-URL: https://github.com/nodejs/io.js/pull/1721 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
57 lines
1.2 KiB
JavaScript
57 lines
1.2 KiB
JavaScript
'use strict';
|
|
// Create an ssl server. First connection, validate that not resume.
|
|
// Cache session and close connection. Use session on second connection.
|
|
// ASSERT resumption.
|
|
|
|
var common = require('../common');
|
|
var assert = require('assert');
|
|
|
|
if (!common.hasCrypto) {
|
|
console.log('1..0 # Skipped: missing crypto');
|
|
process.exit();
|
|
}
|
|
var tls = require('tls');
|
|
|
|
var fs = require('fs');
|
|
|
|
var options = {
|
|
key: fs.readFileSync(common.fixturesDir + '/keys/agent2-key.pem'),
|
|
cert: fs.readFileSync(common.fixturesDir + '/keys/agent2-cert.pem')
|
|
};
|
|
|
|
var big = new Buffer(2 * 1024 * 1024);
|
|
var connections = 0;
|
|
var bytesRead = 0;
|
|
|
|
big.fill('Y');
|
|
|
|
// create server
|
|
var server = tls.createServer(options, function(socket) {
|
|
socket.end(big);
|
|
socket.destroySoon();
|
|
connections++;
|
|
});
|
|
|
|
// start listening
|
|
server.listen(common.PORT, function() {
|
|
var client = tls.connect({
|
|
port: common.PORT,
|
|
rejectUnauthorized: false
|
|
}, function() {
|
|
client.on('readable', function() {
|
|
var d = client.read();
|
|
if (d)
|
|
bytesRead += d.length;
|
|
});
|
|
|
|
client.on('end', function() {
|
|
server.close();
|
|
});
|
|
});
|
|
});
|
|
|
|
process.on('exit', function() {
|
|
assert.equal(1, connections);
|
|
assert.equal(big.length, bytesRead);
|
|
});
|