import { describe, expect, it } from "vitest"; import { digestModelSourceBytes, digestModelSourceBytesAsync, } from "./model-source-digest"; describe("model source digest", () => { it("uses asynchronous WebCrypto without changing canonical SHA-256 identity", async () => { const bytes = new TextEncoder().encode("toolcraft model source"); await expect(digestModelSourceBytesAsync(bytes)).resolves.toBe( digestModelSourceBytes(bytes), ); }); it("hashes only the selected typed-array window", async () => { const storage = new Uint8Array([9, 1, 2, 3, 9]); const window = storage.subarray(1, 4); await expect(digestModelSourceBytesAsync(window)).resolves.toBe( digestModelSourceBytes(new Uint8Array([1, 2, 3])), ); }); });