mirror of
https://github.com/nodejs/node.git
synced 2024-11-30 07:27:22 +01:00
2d2986ae72
* Make common.skip() exit. Also add common.printSkipMessage() for partial skips. * Don't make needless things before skip PR-URL: https://github.com/nodejs/node/pull/14021 Fixes: https://github.com/nodejs/node/issues/14016 Reviewed-By: Refael Ackermann <refack@gmail.com>
56 lines
1.4 KiB
JavaScript
56 lines
1.4 KiB
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
if (!common.hasCrypto)
|
|
common.skip('missing crypto');
|
|
|
|
const initHooks = require('./init-hooks');
|
|
const verifyGraph = require('./verify-graph');
|
|
|
|
const tls = require('tls');
|
|
const Connection = process.binding('crypto').Connection;
|
|
const hooks = initHooks();
|
|
hooks.enable();
|
|
|
|
function createServerConnection(
|
|
onhandshakestart,
|
|
certificate = null,
|
|
isServer = true,
|
|
servername = 'some server',
|
|
rejectUnauthorized
|
|
) {
|
|
if (certificate == null) certificate = tls.createSecureContext();
|
|
const ssl = new Connection(
|
|
certificate.context, isServer, servername, rejectUnauthorized
|
|
);
|
|
if (isServer) {
|
|
ssl.onhandshakestart = onhandshakestart;
|
|
ssl.lastHandshakeTime = 0;
|
|
}
|
|
return ssl;
|
|
}
|
|
|
|
// creating first server connection and start it
|
|
const sc1 = createServerConnection(common.mustCall(onfirstHandShake));
|
|
sc1.start();
|
|
|
|
function onfirstHandShake() {
|
|
// Create second connection inside handshake of first to show
|
|
// that the triggerAsyncId of the second will be set to id of the first
|
|
const sc2 = createServerConnection(common.mustCall(onsecondHandShake));
|
|
sc2.start();
|
|
}
|
|
function onsecondHandShake() { }
|
|
|
|
process.on('exit', onexit);
|
|
|
|
function onexit() {
|
|
hooks.disable();
|
|
verifyGraph(
|
|
hooks,
|
|
[ { type: 'CONNECTION', id: 'connection:1', triggerAsyncId: null },
|
|
{ type: 'CONNECTION', id: 'connection:2',
|
|
triggerAsyncId: 'connection:1' } ]
|
|
);
|
|
}
|