node/test/async-hooks/test-async-local-storage-tlssocket.js
Antoine du Hamel cf46746b8a
test: add trailing commas in async-hooks tests (#45549)
PR-URL: https://github.com/nodejs/node/pull/45549
Reviewed-By: Daeyeon Jeong <daeyeon.dev@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
2022-11-21 18:43:47 +01:00

37 lines
991 B
JavaScript

'use strict';
const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');
// Regression tests for https://github.com/nodejs/node/issues/40693
const assert = require('assert');
const fixtures = require('../common/fixtures');
const tls = require('tls');
const { AsyncLocalStorage } = require('async_hooks');
const options = {
cert: fixtures.readKey('rsa_cert.crt'),
key: fixtures.readKey('rsa_private.pem'),
rejectUnauthorized: false,
};
tls
.createServer(options, (socket) => {
socket.write('Hello, world!');
socket.pipe(socket);
})
.listen(0, function() {
const asyncLocalStorage = new AsyncLocalStorage();
const store = { val: 'abcd' };
asyncLocalStorage.run(store, () => {
const client = tls.connect({ port: this.address().port, ...options });
client.on('data', () => {
assert.deepStrictEqual(asyncLocalStorage.getStore(), store);
client.end();
this.close();
});
});
});