Skip to content

Commit 39723f9

Browse files
shrugsclaude
andcommitted
test: derive dan's labelHash and 63-char input from the label constant
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 71beec2 commit 39723f9

1 file changed

Lines changed: 8 additions & 9 deletions

File tree

apps/ensindexer/src/lib/graphnode-helpers.test.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -78,26 +78,25 @@ describe("labelByLabelHash", () => {
7878
// hash — a hash the healed label "dan" actually hashes to, so the client's heal-integrity check
7979
// accepts it. A label whose hash doesn't start with '0' (e.g. "vitalik" → 0xaf2caa…) couldn't
8080
// exercise the prepend-'0' path without the re-padded hash diverging from the label's hash.
81+
const DAN_LABEL = asLiteralLabel("dan");
82+
const DAN_LABELHASH = labelhashLiteralLabel(DAN_LABEL); // 0x0d2095…
83+
// drop the leading '0' to produce the 63-hex-char input the client must re-pad
84+
const labelHash63 = `0x${DAN_LABELHASH.slice(3)}` as LabelHash;
85+
8186
(fetch as any).mockResolvedValue({
8287
ok: true,
8388
json: () =>
8489
Promise.resolve({
8590
status: "success",
86-
label: "dan",
91+
label: DAN_LABEL,
8792
}),
8893
});
8994

90-
expect(
91-
await labelByLabelHash(
92-
"0xd2095e5cac990209cb47ca08e0614adcffe0315af614f414ab60c6230bdc988" as LabelHash, // 63 hex chars
93-
),
94-
).toEqual("dan");
95+
expect(await labelByLabelHash(labelHash63)).toEqual(DAN_LABEL);
9596

9697
const [[calledUrl]] = (fetch as any).mock.calls;
9798
// Verify the client prepended a '0' — the normalized 64-char hash is used in the request
98-
expect(calledUrl.toString()).toContain(
99-
"0x0d2095e5cac990209cb47ca08e0614adcffe0315af614f414ab60c6230bdc988",
100-
);
99+
expect(calledUrl.toString()).toContain(DAN_LABELHASH);
101100
});
102101

103102
it("propagates a server 400 error as a thrown exception", async () => {

0 commit comments

Comments
 (0)