11import { anchorageGraphQLService } from "../../src" ;
22import { JsonRpcProvider } from "@ethersproject/providers" ;
33
4- describe ( 'Anchorage: Integration Test' , function ( ) {
5- it ( 'should find: WithdrawalInitialized Events' , async ( ) => {
6- const res = await anchorageGraphQLService
7- . findWithdrawalsInitiated (
8- "0x3256bd6fc8b5fa48db95914d0df314465f3f7879" ,
9- 288 )
4+ const l2NetworkMap = [
5+ {
6+ fromAddress : "0x3256bd6fc8b5fa48db95914d0df314465f3f7879" ,
7+ chainId : 288 ,
8+ networkName : 'Boba ETH' ,
9+ isBnb : false ,
10+ withdrawalHash : "0x15fd4589111a601b83ce513c508ceb0fb6dbafa5b4f5b42f24bc793eebc67e72" ,
11+ blocks : [ "3210114" ]
12+ } ,
13+ {
14+ fromAddress : "0x78b4507e3303caa40d20c23316e2f5795857ab85" ,
15+ chainId : 56288 ,
16+ networkName : 'Boba BNB' ,
17+ isBnb : true ,
18+ blocks : [ ] ,
19+ withdrawalHash : ''
20+ } ,
21+ {
22+ fromAddress : "0x81654daa2e297a140ca01f12367a4d9c9fc2bf51" ,
23+ chainId : 28882 ,
24+ networkName : 'Boba Sepolia' ,
25+ isBnb : false ,
26+ withdrawalHash : "0xf641739d3dbb873ec526178b01d6162143a981488d0333f314b19533e1e1864b" ,
27+ blocks : [ "3876531" ]
28+ } ,
29+ {
30+ fromAddress : "0x9703d3b2521f3de2d56831f3df9490cbb1487428" ,
31+ chainId : 9728 ,
32+ networkName : 'Boba BNB Testnet' ,
33+ isBnb : true ,
34+ withdrawalHash : "0x02769bf89904174f8a4bf3da22b7c8dad6dccd5683ac4350874317f69be25b18" ,
35+ blocks : [ "715312" ]
36+ } ,
37+ ]
1038
11- // console.log(res);
12- expect ( res [ 0 ] . __typename ) . toEqual ( 'WithdrawalInitiated' )
13- expect ( res [ 0 ] . transactionHash_ ) . toBeDefined ( ) ;
14- expect ( res [ 0 ] . block_number ) . toBeDefined ( ) ;
15- expect ( res [ 0 ] . timestamp_ ) . toBeDefined ( ) ;
16- } ) ;
17- it ( 'should find: WithdrawalsInitiatedBnb Events' , async ( ) => {
18- const res = await anchorageGraphQLService
19- . findWithdrawalsInitiatedBnb (
20- "0x77151218e325b201addd457a5940d823b3daa2cd" ,
21- 9728 )
22- expect ( res [ 0 ] . __typename ) . toEqual ( 'ETHBridgeInitiated' )
23- expect ( res [ 0 ] . transactionHash_ ) . not . toBeDefined ( ) ;
24- expect ( res [ 0 ] . block_number ) . toBeDefined ( ) ;
25- expect ( res [ 0 ] . timestamp_ ) . toBeDefined ( ) ;
26- } ) ;
39+ const l1NetworkMap = [
40+ {
41+ fromAddress : "0x3256bd6fc8b5fa48db95914d0df314465f3f7879" ,
42+ chainId : 1 ,
43+ networkName : 'ETH Mainnet'
44+ } ,
45+ {
46+ fromAddress : "0x9703d3b2521f3de2d56831f3df9490cbb1487428" ,
47+ chainId : 11155111 ,
48+ networkName : 'Sepolia'
49+ } ,
50+ {
51+ fromAddress : "0x9703d3b2521f3de2d56831f3df9490cbb1487428" ,
52+ chainId : 97 ,
53+ networkName : 'BNB Testnet'
54+ } ,
55+ ]
56+
57+ describe ( 'Anchorage: Integration Test' , function ( ) {
2758 it ( 'should find: WithdrawalProven Events' , async ( ) => {
2859 const res = await anchorageGraphQLService
2960 . findWithdrawalsProven (
@@ -55,28 +86,6 @@ describe('Anchorage: Integration Test', function () {
5586 expect ( res [ 0 ] . transactionHash_ ) . toEqual ( "0x00182e7e904c2a1947c372c21cd1e0efde36badfa249552869861c588c5facf9" )
5687 expect ( res [ 0 ] . timestamp_ ) . toEqual ( "1717425069" )
5788 } ) ;
58- it ( 'should find: MessagePassed Events via Block range' , async ( ) => {
59- const res = await anchorageGraphQLService . findWithdrawalMessagesPassed (
60- [
61- "3210114" ,
62- "3210116"
63- ] , 288 )
64-
65- expect ( res [ 0 ] . __typename ) . toEqual ( "MessagePassed" ) ;
66- expect ( res [ 0 ] . transactionHash_ ) . toEqual ( "0x00182e7e904c2a1947c372c21cd1e0efde36badfa249552869861c588c5facf9" )
67- expect ( res [ 0 ] . timestamp_ ) . toEqual ( "1717425069" )
68- } ) ;
69- it ( 'should find: DepositTransactions' , async ( ) => {
70- const res = await anchorageGraphQLService . findWithdrawalMessagesPassed (
71- [
72- "3210114" ,
73- "3210116"
74- ] , 288 )
75-
76- expect ( res [ 0 ] . __typename ) . toEqual ( "MessagePassed" ) ;
77- expect ( res [ 0 ] . transactionHash_ ) . toEqual ( "0x00182e7e904c2a1947c372c21cd1e0efde36badfa249552869861c588c5facf9" )
78- expect ( res [ 0 ] . timestamp_ ) . toEqual ( "1717425069" )
79- } ) ;
8089 it ( 'should find: DepositTransactions, map them and return the transactions' , async ( ) => {
8190 const res = await anchorageGraphQLService . queryDepositTransactions (
8291 new JsonRpcProvider ( "https://boba-ethereum.gateway.tenderly.co" ) ,
@@ -99,4 +108,75 @@ describe('Anchorage: Integration Test', function () {
99108 expect ( res [ 0 ] . to ) . toEqual ( "0xd134a7d9485c1aac0cbf82718cf6d6e3fd130945" ) ;
100109 expect ( res [ 0 ] . action . status ) . toEqual ( "succeeded" ) ;
101110 } ) ;
111+
112+ describe ( 'should find WITHDRAWALSINITIATED events' , ( ) => {
113+ l2NetworkMap . forEach ( ( info ) => {
114+ test ( `${ info . networkName } ` , async ( ) => {
115+ const res = await anchorageGraphQLService
116+ . findWithdrawalsInitiated (
117+ info . fromAddress ,
118+ info . chainId )
119+ expect ( res [ 0 ] . __typename ) . toEqual ( 'WithdrawalInitiated' )
120+ expect ( res [ 0 ] . transactionHash_ ) . toBeDefined ( ) ;
121+ expect ( res [ 0 ] . block_number ) . toBeDefined ( ) ;
122+ expect ( res [ 0 ] . timestamp_ ) . toBeDefined ( ) ;
123+ } )
124+ } )
125+ } )
126+
127+ describe ( 'should find WithdrawalsInitiatedBnb events' , ( ) => {
128+ l2NetworkMap . forEach ( ( info ) => {
129+ if ( ! info . isBnb ) {
130+ return ;
131+ }
132+ if ( info . chainId === 56288 ) {
133+ // skip incase of mainnet bnb as anchorage yet to be release on bnb mainnet.
134+ return ;
135+ }
136+ test ( `${ info . networkName } ` , async ( ) => {
137+ const res = await anchorageGraphQLService
138+ . findWithdrawalsInitiatedBnb (
139+ info . fromAddress ,
140+ info . chainId )
141+ const ethRes = res . find ( ( d : any ) => d . __typename === "ETHBridgeInitiated" )
142+ const ercRes = res . find ( ( d : any ) => d . __typename === "ERC20BridgeInitiated" )
143+ console . log ( ethRes ) ;
144+ expect ( ethRes . __typename ) . toEqual ( 'ETHBridgeInitiated' )
145+ expect ( ethRes . block_number ) . toBeDefined ( ) ;
146+ expect ( ethRes . timestamp_ ) . toBeDefined ( ) ;
147+ expect ( ercRes . __typename ) . toEqual ( 'ERC20BridgeInitiated' )
148+ expect ( ercRes . transactionHash_ ) . toBeDefined ( ) ;
149+ expect ( ercRes . block_number ) . toBeDefined ( ) ;
150+ expect ( ercRes . timestamp_ ) . toBeDefined ( ) ;
151+ } )
152+ } )
153+ } )
154+
155+ describe ( 'MessagePassed Events' , ( ) => {
156+ l2NetworkMap . forEach ( ( info ) => {
157+ if ( info . chainId === 56288 ) {
158+ // skip incase of mainnet bnb as anchorage yet to be release on bnb mainnet.
159+ return ;
160+ }
161+ test ( `${ info . networkName } using WithdrawalHash` , async ( ) => {
162+ const res = await anchorageGraphQLService . findWithdrawalMessagedPassed (
163+ info . withdrawalHash ,
164+ info . chainId )
165+ expect ( res [ 0 ] . __typename ) . toEqual ( "MessagePassed" ) ;
166+ expect ( res [ 0 ] . transactionHash_ ) . toBeDefined ( )
167+ expect ( res [ 0 ] . timestamp_ ) . toBeDefined ( )
168+ expect ( res [ 0 ] . block_number ) . toBeDefined ( )
169+ } )
170+ test ( `${ info . networkName } using block number` , async ( ) => {
171+ const res = await anchorageGraphQLService . findWithdrawalMessagesPassed (
172+ info . blocks ,
173+ info . chainId )
174+ expect ( res [ 0 ] . __typename ) . toEqual ( "MessagePassed" ) ;
175+ expect ( res [ 0 ] . transactionHash_ ) . toBeDefined ( )
176+ expect ( res [ 0 ] . timestamp_ ) . toBeDefined ( )
177+ expect ( res [ 0 ] . block_number ) . toBeDefined ( )
178+ } )
179+ } )
180+ } )
181+
102182} ) ;
0 commit comments