@@ -5,7 +5,7 @@ import { DEFAULT_CONFIG_STORE_VERSION, GLOBAL_CONFIG_STORE_KEYS } from "../src/c
55import { MockConfigStoreClient , MockHubPoolClient , MockSpokePoolClient } from "../src/clients/mocks" ;
66import { EMPTY_MESSAGE , ZERO_ADDRESS } from "../src/constants" ;
77import { DepositWithBlock , FillWithBlock , Log , SlowFillRequest , SlowFillRequestWithBlock } from "../src/interfaces" ;
8- import { getCurrentTime , isDefined , randomAddress } from "../src/utils" ;
8+ import { getCurrentTime , isDefined , randomAddress , toAddress , toBN } from "../src/utils" ;
99import {
1010 SignerWithAddress ,
1111 createSpyLogger ,
@@ -338,4 +338,100 @@ describe("SpokePoolClient: Event Filtering", function () {
338338 expect ( fillEvent . outputToken ) . to . equal ( expectedFill . args ! . outputToken ) ;
339339 } ) ;
340340 } ) ;
341+
342+ it ( "Correctly truncates events with bytes32 address fields: TokensBridged" , async function ( ) {
343+ for ( let i = 0 ; i < 10 ; ++ i ) {
344+ const l2TokenAddress = ethers . utils . hexZeroPad ( randomAddress ( ) , 32 ) ;
345+ originSpokePoolClient . setTokensBridged ( { l2TokenAddress, chainId : i , leafId : i + 1 } as TokensBridged ) ;
346+ await originSpokePoolClient . update ( [ "TokensBridged" ] ) ;
347+ const tokensBridged = originSpokePoolClient . getTokensBridged ( ) . at ( - 1 ) ;
348+ expect ( tokensBridged . l2TokenAddress ) . to . equal ( toAddress ( l2TokenAddress ) ) ;
349+ }
350+ } ) ;
351+
352+ it ( "Correctly truncates events with bytes32 address fields: FundsDeposited" , async function ( ) {
353+ for ( let _i = 0 ; _i < 10 ; ++ _i ) {
354+ const [ depositor , recipient , inputToken , outputToken , exclusiveRelayer ] = Array ( 5 )
355+ . fill ( 0 )
356+ . map ( ( _ ) => ethers . utils . hexZeroPad ( randomAddress ( ) , 32 ) ) ;
357+ originSpokePoolClient . depositV3 ( {
358+ depositor,
359+ recipient,
360+ inputToken,
361+ outputToken,
362+ exclusiveRelayer,
363+ } as DepositWithBlock ) ;
364+ await originSpokePoolClient . update ( [ "V3FundsDeposited" ] ) ;
365+ const deposit = originSpokePoolClient . getDeposits ( ) . at ( - 1 ) ;
366+ expect ( deposit . depositor ) . to . equal ( toAddress ( depositor ) ) ;
367+ expect ( deposit . recipient ) . to . equal ( toAddress ( recipient ) ) ;
368+ expect ( deposit . inputToken ) . to . equal ( toAddress ( inputToken ) ) ;
369+ expect ( deposit . outputToken ) . to . equal ( toAddress ( outputToken ) ) ;
370+ expect ( deposit . exclusiveRelayer ) . to . equal ( toAddress ( exclusiveRelayer ) ) ;
371+ }
372+ } ) ;
373+ it ( "Correctly truncates events with bytes32 address fields: RequestedSpeedUpDeposit" , async function ( ) {
374+ for ( let i = 0 ; i < 10 ; ++ i ) {
375+ const [ depositor , updatedRecipient ] = Array ( 2 )
376+ . fill ( 0 )
377+ . map ( ( _ ) => ethers . utils . hexZeroPad ( randomAddress ( ) , 32 ) ) ;
378+ originSpokePoolClient . speedUpV3Deposit ( { depositor, updatedRecipient, depositId : toBN ( i ) } as SpeedUp ) ;
379+ await originSpokePoolClient . update ( [ "RequestedSpeedUpV3Deposit" ] ) ;
380+ const speedUp = originSpokePoolClient . getSpeedUps ( ) [ toAddress ( depositor ) ] [ toBN ( i ) ] . at ( - 1 ) ;
381+ expect ( speedUp . depositor ) . to . equal ( toAddress ( depositor ) ) ;
382+ expect ( speedUp . updatedRecipient ) . to . equal ( toAddress ( updatedRecipient ) ) ;
383+ }
384+ } ) ;
385+ it ( "Correctly truncates events with bytes32 address fields: FilledRelay" , async function ( ) {
386+ for ( let i = 0 ; i < 10 ; ++ i ) {
387+ const [ depositor , recipient , inputToken , outputToken , exclusiveRelayer , relayer ] = Array ( 6 )
388+ . fill ( 0 )
389+ . map ( ( _ ) => ethers . utils . hexZeroPad ( randomAddress ( ) , 32 ) ) ;
390+ originSpokePoolClient . fillV3Relay ( {
391+ depositor,
392+ recipient,
393+ inputToken,
394+ outputToken,
395+ exclusiveRelayer,
396+ relayer,
397+ depositId : toBN ( i ) ,
398+ } as FillWithBlock ) ;
399+ await originSpokePoolClient . update ( [ "FilledV3Relay" ] ) ;
400+ const relay = originSpokePoolClient . getFills ( ) . at ( - 1 ) ;
401+ expect ( relay . depositor ) . to . equal ( toAddress ( depositor ) ) ;
402+ expect ( relay . recipient ) . to . equal ( toAddress ( recipient ) ) ;
403+ expect ( relay . inputToken ) . to . equal ( toAddress ( inputToken ) ) ;
404+ expect ( relay . outputToken ) . to . equal ( toAddress ( outputToken ) ) ;
405+ expect ( relay . exclusiveRelayer ) . to . equal ( toAddress ( exclusiveRelayer ) ) ;
406+ expect ( relay . relayer ) . to . equal ( toAddress ( relayer ) ) ;
407+ }
408+ } ) ;
409+ it ( "Correctly truncates events with bytes32 address fields: RequestedSlowFill" , async function ( ) {
410+ for ( let i = 0 ; i < 10 ; ++ i ) {
411+ const [ depositor , recipient , inputToken , outputToken , exclusiveRelayer ] = Array ( 5 )
412+ . fill ( 0 )
413+ . map ( ( _ ) => ethers . utils . hexZeroPad ( randomAddress ( ) , 32 ) ) ;
414+ originSpokePoolClient . requestV3SlowFill ( {
415+ depositor,
416+ recipient,
417+ inputToken,
418+ outputToken,
419+ exclusiveRelayer,
420+ depositId : toBN ( i ) ,
421+ originChainId : 1 ,
422+ inputAmount : toBN ( i ) ,
423+ outputAmount : toBN ( i ) ,
424+ message : "0x" ,
425+ fillDeadline : 0 ,
426+ exclusivityDeadline : 0 ,
427+ } as SlowFillRequestWithBlock ) ;
428+ await originSpokePoolClient . update ( [ "RequestedV3SlowFill" ] ) ;
429+ const slowFill = originSpokePoolClient . getSlowFillRequestsForOriginChain ( 1 ) . at ( - 1 ) ;
430+ expect ( slowFill . depositor ) . to . equal ( toAddress ( depositor ) ) ;
431+ expect ( slowFill . recipient ) . to . equal ( toAddress ( recipient ) ) ;
432+ expect ( slowFill . inputToken ) . to . equal ( toAddress ( inputToken ) ) ;
433+ expect ( slowFill . outputToken ) . to . equal ( toAddress ( outputToken ) ) ;
434+ expect ( slowFill . exclusiveRelayer ) . to . equal ( toAddress ( exclusiveRelayer ) ) ;
435+ }
436+ } ) ;
341437} ) ;
0 commit comments