-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmapped.test.ts
More file actions
40 lines (34 loc) · 1.95 KB
/
mapped.test.ts
File metadata and controls
40 lines (34 loc) · 1.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import { describe, expect, it } from "vitest";
import { findMappedFunction, listMappedCommands, listMappedCommandsForRoot } from "./mapped";
import { getMappedWriteDefaults } from "./mapped-defaults";
import { BASE_AAVEGOTCHI_DIAMOND, BASE_FORGE_DIAMOND, BASE_GBM_DIAMOND, BASE_GLTR_STAKING } from "../subgraph/sources";
describe("mapped domain commands", () => {
it("resolves known mapping", () => {
expect(findMappedFunction(["lending", "create"])).toBe("addGotchiLending");
expect(findMappedFunction(["portal", "open"])).toBe("openPortals");
expect(findMappedFunction(["auction", "bid"])).toBe("commitBid");
expect(findMappedFunction(["staking", "withdraw-pool"])).toBe("withdrawFromPool");
});
it("lists mapped commands per root", () => {
const lending = listMappedCommandsForRoot("lending");
expect(lending).toContain("lending create");
expect(lending).toContain("lending agree");
});
it("lists mapped commands globally", () => {
const all = listMappedCommands();
expect(all).toContain("baazaar buy-now");
expect(all).toContain("token approve");
});
it("provides built-in ABI defaults for every mapped command", () => {
const all = listMappedCommands();
const missing = all.filter((command) => !getMappedWriteDefaults(command.split(" "))?.abi);
expect(missing).toEqual([]);
});
it("pins canonical contract addresses for high-confidence commands", () => {
expect(getMappedWriteDefaults(["lending", "create"])?.address).toBe(BASE_AAVEGOTCHI_DIAMOND);
expect(getMappedWriteDefaults(["auction", "bid"])?.address).toBe(BASE_GBM_DIAMOND);
expect(getMappedWriteDefaults(["forge", "craft"])?.address).toBe(BASE_FORGE_DIAMOND);
expect(getMappedWriteDefaults(["realm", "harvest", "batch"])?.address).toBe(BASE_GLTR_STAKING);
expect(getMappedWriteDefaults(["token", "approve"])?.address).toBeUndefined();
});
});