Files
bun.sh/test/js/node/async_hooks/async-context/async-context-crypto-generateKeyPair.js
2025-07-02 17:45:00 -07:00

21 lines
572 B
JavaScript

const { AsyncLocalStorage } = require("async_hooks");
const crypto = require("crypto");
const asyncLocalStorage = new AsyncLocalStorage();
asyncLocalStorage.run({ test: "crypto.generateKeyPair" }, () => {
crypto.generateKeyPair(
"rsa",
{
modulusLength: 512, // Small for faster test
},
(err, publicKey, privateKey) => {
if (asyncLocalStorage.getStore()?.test !== "crypto.generateKeyPair") {
console.error("FAIL: crypto.generateKeyPair callback lost context");
process.exit(1);
}
process.exit(0);
},
);
});