File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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 ( ) => {
You can’t perform that action at this time.
0 commit comments