@@ -42,32 +42,22 @@ describe('buildNoteHashReadRequestHints', () => {
4242
4343 const makeNoteHash = ( value : number , counter = 1 ) => new NoteHash ( new Fr ( value ) , counter ) . scope ( 0 , contractAddress ) ;
4444
45- const readPendingNoteHash = ( {
46- noteHashIndex,
47- readRequestIndex = numReadRequests ,
48- hintIndex = numPendingReads ,
49- } : {
50- noteHashIndex : number ;
51- readRequestIndex ?: number ;
52- hintIndex ?: number ;
53- } ) => {
45+ const readPendingNoteHash = ( noteHashIndex : number ) => {
46+ const readRequestIndex = numReadRequests ;
47+ const hintIndex = numPendingReads ;
5448 noteHashReadRequests [ readRequestIndex ] = makeReadRequest ( innerNoteHash ( noteHashIndex ) ) ;
5549 expectedHints . readRequestStatuses [ readRequestIndex ] = ReadRequestStatus . pending ( hintIndex ) ;
5650 expectedHints . pendingReadHints [ hintIndex ] = new PendingReadHint ( readRequestIndex , noteHashIndex ) ;
5751 numReadRequests ++ ;
5852 numPendingReads ++ ;
5953 } ;
6054
61- const readSettledNoteHash = ( {
62- readRequestIndex = numReadRequests ,
63- hintIndex = numSettledReads ,
64- } : {
65- readRequestIndex ?: number ;
66- hintIndex ?: number ;
67- } = { } ) => {
68- const value = settledNoteHashes [ hintIndex ] ;
69- noteHashLeafIndexMap . set ( value . toBigInt ( ) , settledLeafIndexes [ hintIndex ] ) ;
70- noteHashReadRequests [ readRequestIndex ] = new ReadRequest ( value , 1 ) . scope ( contractAddress ) ;
55+ const readSettledNoteHash = ( noteHashIndex : number ) => {
56+ const readRequestIndex = numReadRequests ;
57+ const hintIndex = numSettledReads ;
58+ const value = settledNoteHashes [ noteHashIndex ] ;
59+ noteHashLeafIndexMap . set ( value . toBigInt ( ) , settledLeafIndexes [ noteHashIndex ] ) ;
60+ noteHashReadRequests [ readRequestIndex ] = makeReadRequest ( settledNoteHashInnerValues [ noteHashIndex ] ) ;
7161 expectedHints . readRequestStatuses [ readRequestIndex ] = ReadRequestStatus . settled ( hintIndex ) ;
7262 expectedHints . settledReadHints [ hintIndex ] = new SettledReadHint ( readRequestIndex , { } as any , value ) ;
7363 numReadRequests ++ ;
@@ -93,32 +83,32 @@ describe('buildNoteHashReadRequestHints', () => {
9383 } ) ;
9484
9585 it ( 'builds hints for pending note hash read requests' , async ( ) => {
96- readPendingNoteHash ( { noteHashIndex : 2 } ) ;
97- readPendingNoteHash ( { noteHashIndex : 1 } ) ;
86+ readPendingNoteHash ( 2 ) ;
87+ readPendingNoteHash ( 1 ) ;
9888 const hints = await buildHints ( ) ;
9989 expect ( hints ) . toEqual ( expectedHints ) ;
10090 } ) ;
10191
10292 it ( 'builds hints for settled note hash read requests' , async ( ) => {
103- readSettledNoteHash ( ) ;
104- readSettledNoteHash ( ) ;
93+ readSettledNoteHash ( 0 ) ;
94+ readSettledNoteHash ( 1 ) ;
10595 const hints = await buildHints ( ) ;
10696 expect ( hints ) . toEqual ( expectedHints ) ;
10797 } ) ;
10898
10999 it ( 'builds hints for mixed pending and settled note hash read requests' , async ( ) => {
110- readPendingNoteHash ( { noteHashIndex : 2 } ) ;
111- readSettledNoteHash ( ) ;
112- readSettledNoteHash ( ) ;
113- readPendingNoteHash ( { noteHashIndex : 1 } ) ;
114- readPendingNoteHash ( { noteHashIndex : 1 } ) ;
115- readSettledNoteHash ( ) ;
100+ readPendingNoteHash ( 2 ) ;
101+ readSettledNoteHash ( 2 ) ;
102+ readSettledNoteHash ( 0 ) ;
103+ readPendingNoteHash ( 1 ) ;
104+ readPendingNoteHash ( 1 ) ;
105+ readSettledNoteHash ( 2 ) ;
116106 const hints = await buildHints ( ) ;
117107 expect ( hints ) . toEqual ( expectedHints ) ;
118108 } ) ;
119109
120110 it ( 'throws if cannot find a match in pending set and in the tree' , async ( ) => {
121- readPendingNoteHash ( { noteHashIndex : 2 } ) ;
111+ readPendingNoteHash ( 2 ) ;
122112 // Tweak the value of the read request.
123113 noteHashReadRequests [ 0 ] . readRequest . value = new Fr ( 123 ) ;
124114 await expect ( ( ) => buildHints ( ) ) . rejects . toThrow ( 'Read request is reading an unknown note hash.' ) ;
0 commit comments