mirror of
https://github.com/nodejs/node.git
synced 2025-05-21 08:57:07 +00:00

A number of test files use IIFEs to separate distinct tests from each other in the same file. The project has been moving toward using block scopes and let/const in favor of IIFEs. This commit moves IIFE tests to block scopes. Some additional cleanup such as use of strictEqual() and common.mustCall() is also included. PR-URL: https://github.com/nodejs/node/pull/7694 Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
60 lines
1.4 KiB
JavaScript
60 lines
1.4 KiB
JavaScript
'use strict';
|
|
var common = require('../common');
|
|
var assert = require('assert');
|
|
|
|
if (!common.hasCrypto) {
|
|
common.skip('missing crypto');
|
|
return;
|
|
}
|
|
var tls = require('tls');
|
|
|
|
var fs = require('fs');
|
|
var path = require('path');
|
|
|
|
// https://github.com/joyent/node/issues/1218
|
|
// uncatchable exception on TLS connection error
|
|
{
|
|
const cert = fs.readFileSync(path.join(common.fixturesDir, 'test_cert.pem'));
|
|
const key = fs.readFileSync(path.join(common.fixturesDir, 'test_key.pem'));
|
|
|
|
let errorEmitted = false;
|
|
|
|
process.on('exit', function() {
|
|
assert.ok(errorEmitted);
|
|
});
|
|
|
|
const options = {cert: cert, key: key, port: common.PORT};
|
|
const conn = tls.connect(options, function() {
|
|
assert.ok(false); // callback should never be executed
|
|
});
|
|
|
|
conn.on('error', function() {
|
|
errorEmitted = true;
|
|
});
|
|
}
|
|
|
|
// SSL_accept/SSL_connect error handling
|
|
{
|
|
const cert = fs.readFileSync(path.join(common.fixturesDir, 'test_cert.pem'));
|
|
const key = fs.readFileSync(path.join(common.fixturesDir, 'test_key.pem'));
|
|
|
|
let errorEmitted = false;
|
|
|
|
process.on('exit', function() {
|
|
assert.ok(errorEmitted);
|
|
});
|
|
|
|
const conn = tls.connect({
|
|
cert: cert,
|
|
key: key,
|
|
port: common.PORT,
|
|
ciphers: 'rick-128-roll'
|
|
}, function() {
|
|
assert.ok(false); // callback should never be executed
|
|
});
|
|
|
|
conn.on('error', function() {
|
|
errorEmitted = true;
|
|
});
|
|
}
|