Files
united-workforce/packages/workflow/__tests__/hash.test.ts
T
xiaoju cf17dedac3 refactor: organize workflow/src into 6 module folders
Move 34 flat modules into cas/, registry/, bundle/, extract/, engine/, util/.
Move gc.ts to engine/ (was in cas/) to avoid cas→engine reverse dependency.
Dependency direction: util ← cas ← extract ← engine, util ← registry ← bundle.
No logic changes — only file locations and import paths.

Refs #102
2026-05-08 01:22:01 +00:00

26 lines
945 B
TypeScript

import { describe, expect, test } from "bun:test";
import { hashWorkflowBundleBytes } from "../src/cas/hash.js";
import { decodeCrockfordToUint64 } from "../src/util/base32.js";
describe("hashWorkflowBundleBytes", () => {
test("matches XXH64 reference for empty input", () => {
const encoder = new TextEncoder();
const digest = hashWorkflowBundleBytes(encoder.encode(""));
const decoded = decodeCrockfordToUint64(digest);
expect(decoded.ok).toBe(true);
if (decoded.ok) {
expect(decoded.value).toBe(0xef46_db37_51d8_e999n);
}
});
test("stable for identical content", () => {
const encoder = new TextEncoder();
const data = encoder.encode(
`export const descriptor = { description: "x", roles: {} };
export const run = async function* (input) { return { returnCode: 0, summary: input.prompt }; }
`,
);
expect(hashWorkflowBundleBytes(data)).toBe(hashWorkflowBundleBytes(data));
});
});