Skip to content

Commit 7bb59ca

Browse files
committed
change:
- setup jest to read the env param - update the subgraph url - added spec for withdrawalInitiated, withdrawalInitiatedBnb, MessagePassed.
1 parent 8ddb60c commit 7bb59ca

File tree

8 files changed

+132
-55
lines changed

8 files changed

+132
-55
lines changed

jest.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ const config = {
2020
"lcov"
2121
],
2222
testTimeout: 60000,
23+
setupFiles: ['<rootDir>/jest.setup.js']
2324
};
2425

2526
export default config;

jest.setup.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
require('dotenv').config();

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
"@apollo/client": "3.5.10",
2828
"@ethersproject/providers": "^5.7.2",
2929
"@types/jest": "^29.5.12",
30-
"dotenv": "^16.4.5",
3130
"ethers": "^5.5.4",
3231
"graphql": "^16.8.2",
3332
"node-fetch": "^2.6.1",
@@ -36,6 +35,7 @@
3635
"devDependencies": {
3736
"@types/node": "^16.18.62",
3837
"@types/node-fetch": "^2.6.11",
38+
"dotenv": "^16.4.5",
3939
"jest": "^29.7.0",
4040
"jest-config": "^29.7.0",
4141
"jest-coverage-badges": "^1.1.2",

pnpm-lock.yaml

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/graphql.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ if (!fetchLib) {
1919
export class GraphQLService {
2020
private readonly apikey = process.env.REACT_APP_THE_GRAPH_API_KEY
2121

22-
private readonly uri = `https://gateway-arbitrum.network.thegraph.com/api/${this.apikey}/subgraphs/id`
22+
private readonly uri = `https://gateway.thegraph.com/api/${this.apikey}/subgraphs/id`
2323

2424
private withSubgraphId(subgraphId: string) {
2525
return `${this.uri}/${subgraphId}`
Lines changed: 124 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,60 @@
11
import {anchorageGraphQLService} from "../../src";
22
import {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
});

tests/integration/dao.spec.ts

Lines changed: 0 additions & 5 deletions
This file was deleted.

tests/unit/utils.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const {filterLatestGroupedSupportedTokens} = require("../../src/utils");
1+
const { filterLatestGroupedSupportedTokens } = require("../../src/utils");
22

33
describe('GraphQL Utils', () => {
44
it('should return the latest supported events only', () => {

0 commit comments

Comments
 (0)