Skip to content

Commit a6c6ebe

Browse files
authored
polished batch evm tx parsing (#995)
* polished batch evm tx parsing * use snapshot * update * polish isBatchExtrinsic * polish * fix old test snapshot * fix lint
1 parent 2d462e8 commit a6c6ebe

File tree

6 files changed

+1101
-822
lines changed

6 files changed

+1101
-822
lines changed

packages/eth-providers/src/__tests__/e2e/__snapshots__/parseBlock.test.ts.snap

Lines changed: 1019 additions & 0 deletions
Large diffs are not rendered by default.

packages/eth-providers/src/__tests__/e2e/parseBlock.test.ts

Lines changed: 45 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,10 @@
11
import { ApiPromise, WsProvider } from '@polkadot/api';
22
import { TransactionReceipt } from '@ethersproject/abstract-provider';
3-
import {
4-
acala1102030a,
5-
acala1102030b,
6-
acala1555311a,
7-
acala1555311b,
8-
acala1563383,
9-
acala2669090,
10-
acala2859806,
11-
karura1824665,
12-
karura2043397b,
13-
karura2449983a,
14-
karura2449983b,
15-
karura2826860,
16-
karura2936174,
17-
karura3524761,
18-
karura3597964,
19-
karura3607973,
20-
} from './receipt-snapshots';
21-
import { afterAll, beforeAll, describe, expect, it } from 'vitest';
3+
import { afterAll, beforeAll, describe, it } from 'vitest';
4+
import { options } from '@acala-network/api';
5+
226
import { getAllReceiptsAtBlock } from '../../utils/parseBlock';
237
import { hexlifyRpcResult, sleep } from '../../utils';
24-
import { options } from '@acala-network/api';
258

269
interface FormatedReceipt {
2710
to?: string;
@@ -94,125 +77,130 @@ describe.concurrent('getAllReceiptsAtBlock', () => {
9477
await apiA.disconnect();
9578
});
9679

97-
describe.concurrent('transfer kar', async () => {
98-
it('basic one', async () => {
80+
describe.concurrent('transfer kar', () => {
81+
it('basic one', async ({ expect }) => {
9982
const blockNumber = 3607973;
10083
const receipts = await getAllReceiptsAtBlockNumber(apiK, blockNumber);
10184

10285
expect(receipts.length).to.equal(1);
103-
expect(receipts[0]).to.deep.equal(karura3607973);
86+
expect(receipts).toMatchSnapshot();
10487
});
10588
});
10689

10790
describe.concurrent('contract creation', () => {
108-
it('basic one', async () => {
91+
it('basic one', async ({ expect }) => {
10992
const blockNumber = 3524761;
11093
const receipts = await getAllReceiptsAtBlockNumber(apiK, blockNumber);
11194

11295
expect(receipts.length).to.equal(1);
113-
expect(receipts[0]).to.deep.equal(karura3524761);
96+
expect(receipts).toMatchSnapshot();
11497
});
11598

116-
it('with logs + legacy gas', async () => {
99+
it('with logs + legacy gas', async ({ expect }) => {
117100
const blockNumber = 1824665;
118101
const receipts = await getAllReceiptsAtBlockNumber(apiK, blockNumber);
119102

120103
expect(receipts.length).to.equal(1);
121-
expect(receipts[0]).to.deep.equal(karura1824665);
122-
});
123-
124-
it('2 contract creation failed', async () => {
125-
const blockNumber = 1102030;
126-
const receipts = await getAllReceiptsAtBlockNumber(apiA, blockNumber);
127-
128-
expect(receipts.length).to.equal(2);
129-
expect(receipts[0]).to.deep.equal(acala1102030a);
130-
expect(receipts[1]).to.deep.equal(acala1102030b);
104+
expect(receipts).toMatchSnapshot();
131105
});
132106
});
133107

134108
describe.concurrent('contract call', () => {
135-
it('aggregatedDex.swapWithExactSupply => transfer 1 erc20', async () => {
109+
it('aggregatedDex.swapWithExactSupply => transfer 1 erc20', async ({ expect }) => {
136110
const blockNumber = 2826860;
137111
const receipts = await getAllReceiptsAtBlockNumber(apiK, blockNumber);
138112

139113
expect(receipts.length).to.equal(1);
140-
expect(receipts[0]).to.deep.equal(karura2826860);
114+
expect(receipts).toMatchSnapshot();
141115
});
142116

143-
it('evm.call => tranfer 2 erc20', async () => {
117+
it('evm.call => tranfer 2 erc20', async ({ expect }) => {
144118
const blockNumber = 3597964;
145119
const receipts = await getAllReceiptsAtBlockNumber(apiK, blockNumber);
146120

147121
expect(receipts.length).to.equal(1);
148-
expect(receipts[0]).to.deep.equal(karura3597964);
122+
expect(receipts).toMatchSnapshot();
149123
});
150124

151-
it('evm.call + aggregatedDex.swapWithExactSupply', async () => {
125+
it('evm.call + aggregatedDex.swapWithExactSupply', async ({ expect }) => {
152126
const blockNumber = 2449983;
153127
const receipts = await getAllReceiptsAtBlockNumber(apiK, blockNumber);
154128

155129
expect(receipts.length).to.equal(2);
156-
expect(receipts[0]).to.deep.equal(karura2449983a);
157-
expect(receipts[1]).to.deep.equal(karura2449983b);
130+
expect(receipts).toMatchSnapshot();
158131
});
159132

160-
it('negative usedStorage', async () => {
133+
it('negative usedStorage', async ({ expect }) => {
161134
const blockNumber = 2043397;
162135
const receipts = await getAllReceiptsAtBlockNumber(apiK, blockNumber);
163136

164137
expect(receipts.length).to.equal(2);
165-
expect(receipts[1]).to.deep.equal(karura2043397b);
138+
expect(receipts).toMatchSnapshot();
166139
});
167140
});
168141

169142
describe.concurrent('orphan tx', () => {
170-
it('1 orphan tx', async () => {
143+
it('1 orphan tx', async ({ expect }) => {
171144
const blockNumber = 1563383;
172145
const receipts = await getAllReceiptsAtBlockNumber(apiA, blockNumber);
173146

174147
expect(receipts.length).to.equal(1);
175-
expect(receipts[0]).to.deep.equal(acala1563383);
148+
expect(receipts).toMatchSnapshot();
176149
});
177150

178-
it('1 successful orphan + 1 failed orphan', async () => {
151+
it('1 successful orphan + 1 failed orphan', async ({ expect }) => {
179152
const blockNumber = 1555311;
180153
const receipts = await getAllReceiptsAtBlockNumber(apiA, blockNumber);
181154

182155
expect(receipts.length).to.equal(2);
183-
expect(receipts[0]).to.deep.equal(acala1555311a);
184-
expect(receipts[1]).to.deep.equal(acala1555311b);
156+
expect(receipts).toMatchSnapshot();
157+
});
158+
159+
it('9 contract creation failed by technicalCommittee', async ({ expect }) => {
160+
const blockNumber = 1102030;
161+
const receipts = await getAllReceiptsAtBlockNumber(apiA, blockNumber);
162+
163+
expect(receipts.length).to.equal(9);
164+
expect(receipts).toMatchSnapshot();
165+
});
166+
167+
it('batch approve + draw lottery', async ({ expect }) => {
168+
const blockNumber = 6066931;
169+
const receipts = await getAllReceiptsAtBlockNumber(apiA, blockNumber);
170+
171+
expect(receipts.length).to.equal(2);
172+
expect(receipts).toMatchSnapshot();
185173
});
186174
});
187175

188176
describe.concurrent('erc20 XCM', () => {
189-
it('basic xcm', async () => {
177+
it('basic xcm', async ({ expect }) => {
190178
const blockNumber = 2936174;
191179
const receipts = await getAllReceiptsAtBlockNumber(apiK, blockNumber);
192180

193181
expect(receipts.length).to.equal(1);
194-
expect(receipts[0]).to.deep.equal(karura2936174);
182+
expect(receipts).toMatchSnapshot();
195183
});
196184

197-
it('with some other random txs in the block', async () => {
185+
it('with some other random txs in the block', async ({ expect }) => {
198186
const blockNumber = 2669090;
199187
const receipts = await getAllReceiptsAtBlockNumber(apiA, blockNumber);
200188

201189
expect(receipts.length).to.equal(1);
202-
expect(receipts[0]).to.deep.equal(acala2669090);
190+
expect(receipts).toMatchSnapshot();
203191
});
204192

205-
it('multiple xcms', async () => {
193+
it('multiple xcms', async ({ expect }) => {
206194
const blockNumber = 2859806;
207195
const receipts = await getAllReceiptsAtBlockNumber(apiA, blockNumber);
208196

209197
expect(receipts.length).to.equal(1);
210-
expect(receipts[0]).to.deep.equal(acala2859806);
198+
expect(receipts).toMatchSnapshot();
211199
});
212200
});
213201

214202
describe.concurrent.skip('other types', () => {
215-
it('failed EVM extrinsic - 0 gasLimit', async () => {
203+
it('failed EVM extrinsic - 0 gasLimit', async ({ expect }) => {
216204
// TODO: construct a similar one on karura
217205
});
218206
});

0 commit comments

Comments
 (0)