@@ -312,7 +312,7 @@ describe('BaseCrossChecker', () => {
312
312
expect ( mockProvider . provider . getLogs ) . toHaveBeenCalledWith ( {
313
313
fromBlock : 1000 ,
314
314
toBlock : 2000 ,
315
- address : '0xcontract1' ,
315
+ address : [ '0xcontract1' ] ,
316
316
topics : [ '0xtopic1' ] ,
317
317
} )
318
318
expect ( onMissingLogSpy ) . toHaveBeenCalledTimes ( 2 )
@@ -324,7 +324,7 @@ describe('BaseCrossChecker', () => {
324
324
const options : CrossCheckRangeParam = {
325
325
fromBlock : 1000 ,
326
326
toBlock : 2000 ,
327
- address : '0xcontract1' ,
327
+ address : [ '0xcontract1' ] ,
328
328
topics : [ '0xtopic1' ] ,
329
329
onMissingLog : onMissingLogSpy ,
330
330
}
@@ -348,7 +348,7 @@ describe('BaseCrossChecker', () => {
348
348
expect ( mockProvider . provider . getLogs ) . toHaveBeenCalledWith ( {
349
349
fromBlock : 1000 ,
350
350
toBlock : 2000 ,
351
- address : '0xcontract1' ,
351
+ address : [ '0xcontract1' ] ,
352
352
topics : [ '0xtopic1' ] ,
353
353
} )
354
354
} )
@@ -368,5 +368,75 @@ describe('BaseCrossChecker', () => {
368
368
369
369
expect ( onMissingLogSpy ) . toHaveBeenCalledTimes ( 3 )
370
370
} )
371
+
372
+ it ( 'should handle addressGroupLimit' , async ( ) => {
373
+ mockProvider . provider . getLogs . mockResolvedValue ( mockLogs )
374
+
375
+ const options : CrossCheckRangeParam = {
376
+ fromBlock : 1000 ,
377
+ toBlock : 2000 ,
378
+ address : [ '0xcontract1' , '0xcontract2' ] ,
379
+ addressGroupLimit : 1 ,
380
+ onMissingLog : onMissingLogSpy ,
381
+ topics : [ ] ,
382
+ }
383
+
384
+ await ( baseChecker as any ) . _crossCheck ( options )
385
+
386
+ expect ( mockProvider . provider . getLogs ) . toHaveBeenCalledTimes ( 2 )
387
+ } )
388
+
389
+ it ( 'should handle addressGroupLimit with single address' , async ( ) => {
390
+ mockProvider . provider . getLogs . mockResolvedValue ( mockLogs )
391
+
392
+ const options : CrossCheckRangeParam = {
393
+ fromBlock : 1000 ,
394
+ toBlock : 2000 ,
395
+ address : '0xcontract1' ,
396
+ addressGroupLimit : 1 ,
397
+ onMissingLog : onMissingLogSpy ,
398
+ topics : [ ] ,
399
+ }
400
+
401
+ await ( baseChecker as any ) . _crossCheck ( options )
402
+
403
+ expect ( mockProvider . provider . getLogs ) . toHaveBeenCalledTimes ( 1 )
404
+
405
+ expect ( mockProvider . provider . getLogs ) . toHaveBeenCalledWith ( {
406
+ fromBlock : 1000 ,
407
+ toBlock : 2000 ,
408
+ address : [ '0xcontract1' ] ,
409
+ topics : [ ] ,
410
+ } )
411
+ } )
412
+
413
+ it . only ( 'should handle retryOptions' , async ( ) => {
414
+ mockProvider . provider . getLogs . mockRejectedValue ( Error ( 'provider not ready' ) )
415
+
416
+ const options : CrossCheckRangeParam = {
417
+ fromBlock : 1000 ,
418
+ toBlock : 2000 ,
419
+ address : '0xcontract1' ,
420
+ topics : [ '0xtopic1' ] ,
421
+ onMissingLog : onMissingLogSpy ,
422
+ retryOptions : {
423
+ timeout : 1000 ,
424
+ retries : 1 ,
425
+ } ,
426
+ }
427
+
428
+ const defaultCallTimes = 1
429
+
430
+ try {
431
+ await ( baseChecker as any ) . _crossCheck ( options )
432
+ }
433
+ catch ( error ) {
434
+ expect ( error ) . toBeInstanceOf ( Error )
435
+ expect ( ( error as Error ) . message ) . toBe ( 'provider not ready' )
436
+ }
437
+
438
+ expect ( mockProvider . provider . getLogs ) . toHaveBeenCalledTimes ( defaultCallTimes + options . retryOptions ! . retries ! )
439
+ expect ( onMissingLogSpy ) . toHaveBeenCalledTimes ( 0 )
440
+ } )
371
441
} )
372
442
} )
0 commit comments