forked from Dshield-xyz/Dshield
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreport.test.ts
More file actions
52 lines (48 loc) · 1.66 KB
/
Copy pathreport.test.ts
File metadata and controls
52 lines (48 loc) · 1.66 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
41
42
43
44
45
46
47
48
49
50
51
52
import { describe, it, expect } from "vitest";
import { formatReportText, type ComplianceReport } from "./report";
const base: ComplianceReport = {
network: "Testnet",
poolId: "CABC",
commitment: "0xdeadbeef",
nullifierHash: "0x00aa",
integrityOk: true,
depositConfirmed: true,
leafIndex: 9,
withdrawn: true,
depositTx: { hash: "abc123", at: "2026-06-26T00:00:00Z" },
withdrawTx: { hash: "def456", at: "2026-06-26T01:00:00Z" },
generatedAt: 0,
};
describe("formatReportText", () => {
it("includes the key on-chain facts", () => {
const t = formatReportText(base);
expect(t).toContain("DShield Compliance Report");
expect(t).toContain("leaf #9");
expect(t).toContain("Withdrawn");
expect(t).toContain(base.commitment);
expect(t).toContain("abc123");
});
it("never leaks an amount, address, or the spendable note", () => {
const t = formatReportText(base).toLowerCase();
expect(t).not.toContain("usdc");
expect(t).not.toContain("amount");
// The exported report must not carry the bearer-spendable note secret
// (serialized notes are prefixed "dshield-v1-") — sharing the report
// with a third party (e.g. an auditor) would otherwise let them drain
// the note.
expect(t).not.toContain("dshield-v1-");
});
it("renders the unconfirmed / unspent / no-tx case", () => {
const t = formatReportText({
...base,
depositConfirmed: false,
leafIndex: null,
withdrawn: false,
depositTx: null,
withdrawTx: null,
});
expect(t).toContain("Not found on-chain");
expect(t).toContain("In pool (unspent)");
expect(t).toContain("Deposit tx n/a");
});
});