11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ci 31cb0ef41Sopenharmony_ciconst common = require('../common'); 41cb0ef41Sopenharmony_ciif (!common.hasCrypto) 51cb0ef41Sopenharmony_ci common.skip('missing crypto'); 61cb0ef41Sopenharmony_ci 71cb0ef41Sopenharmony_ci// Regression tests for https://github.com/nodejs/node/issues/40693 81cb0ef41Sopenharmony_ci 91cb0ef41Sopenharmony_ciconst assert = require('assert'); 101cb0ef41Sopenharmony_ciconst fixtures = require('../common/fixtures'); 111cb0ef41Sopenharmony_ciconst tls = require('tls'); 121cb0ef41Sopenharmony_ciconst { AsyncLocalStorage } = require('async_hooks'); 131cb0ef41Sopenharmony_ci 141cb0ef41Sopenharmony_ciconst options = { 151cb0ef41Sopenharmony_ci cert: fixtures.readKey('rsa_cert.crt'), 161cb0ef41Sopenharmony_ci key: fixtures.readKey('rsa_private.pem'), 171cb0ef41Sopenharmony_ci rejectUnauthorized: false, 181cb0ef41Sopenharmony_ci}; 191cb0ef41Sopenharmony_ci 201cb0ef41Sopenharmony_citls 211cb0ef41Sopenharmony_ci .createServer(options, (socket) => { 221cb0ef41Sopenharmony_ci socket.write('Hello, world!'); 231cb0ef41Sopenharmony_ci socket.pipe(socket); 241cb0ef41Sopenharmony_ci }) 251cb0ef41Sopenharmony_ci .listen(0, function() { 261cb0ef41Sopenharmony_ci const asyncLocalStorage = new AsyncLocalStorage(); 271cb0ef41Sopenharmony_ci const store = { val: 'abcd' }; 281cb0ef41Sopenharmony_ci asyncLocalStorage.run(store, () => { 291cb0ef41Sopenharmony_ci const client = tls.connect({ port: this.address().port, ...options }); 301cb0ef41Sopenharmony_ci client.on('data', () => { 311cb0ef41Sopenharmony_ci assert.deepStrictEqual(asyncLocalStorage.getStore(), store); 321cb0ef41Sopenharmony_ci client.end(); 331cb0ef41Sopenharmony_ci this.close(); 341cb0ef41Sopenharmony_ci }); 351cb0ef41Sopenharmony_ci }); 361cb0ef41Sopenharmony_ci }); 37