[Fix] Harden MTP codec, transport, and SDK security
This commit is contained in:
parent
188caf56cc
commit
a7e804c603
73 changed files with 11892 additions and 5756 deletions
20
test/wasm-init.mjs
Normal file
20
test/wasm-init.mjs
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
import assert from "node:assert/strict";
|
||||
import { test } from "node:test";
|
||||
import { createWasmInitializer } from "../dist/sdk/wasm-init.js";
|
||||
|
||||
test("WASM initialization can retry after a rejected attempt", async () => {
|
||||
let attempts = 0;
|
||||
const expected = { initialized: true };
|
||||
const init = createWasmInitializer(async () => {
|
||||
attempts += 1;
|
||||
if (attempts === 1) {
|
||||
throw new Error("initialization failed");
|
||||
}
|
||||
return expected;
|
||||
});
|
||||
|
||||
await assert.rejects(init(), /initialization failed/);
|
||||
assert.equal(await init(), expected);
|
||||
assert.equal(await init(), expected);
|
||||
assert.equal(attempts, 2);
|
||||
});
|
||||
Loading…
Reference in a new issue