huskies: merge 949

This commit is contained in:
dave
2026-05-13 07:10:00 +00:00
parent d87722f6c8
commit 4a0fbcaa95
15 changed files with 1454 additions and 231 deletions
+29
View File
@@ -0,0 +1,29 @@
/**
* Snapshot test: the frontend `CONTRACT_FIXTURES` table must match the
* Rust-side snapshot. When the Rust contract changes, the snapshot file
* regenerates (via `UPDATE_RPC_CONTRACT_SNAPSHOT=1 cargo test`) and this
* test catches any TS shapes that have drifted.
*/
import { describe, expect, it } from "vitest";
import { CONTRACT_FIXTURES } from "./rpcContract";
import snapshot from "./rpcContract.snapshot.json";
describe("rpcContract", () => {
it("CONTRACT_FIXTURES matches the Rust-generated snapshot", () => {
// Convert TS fixtures into the same shape the Rust snapshot serialises
// to: a method-keyed object of `{ params, result }`.
const fromTs = Object.fromEntries(
Object.entries(CONTRACT_FIXTURES).map(([method, payloads]) => [
method,
{ params: payloads.params, result: payloads.result },
]),
);
expect(fromTs).toEqual(snapshot);
});
it("declares the same method names as the snapshot", () => {
const tsMethods = Object.keys(CONTRACT_FIXTURES).sort();
const rustMethods = Object.keys(snapshot).sort();
expect(tsMethods).toEqual(rustMethods);
});
});