Skip to content

Commit d065566

Browse files
committed
test: add regression tests for issues MOON-2822 MOON-2824
1 parent 0469a8d commit d065566

File tree

1 file changed

+110
-0
lines changed

1 file changed

+110
-0
lines changed
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
import "@moonbeam-network/api-augment";
2+
import { describeSuite, beforeAll, expect } from "@moonwall/cli";
3+
import { ApiPromise } from "@polkadot/api";
4+
import { ethers } from "ethers";
5+
import { encodeFunctionData } from "viem";
6+
7+
describeSuite({
8+
id: "S15",
9+
title: "Verify regressions which happend in the past",
10+
foundationMethods: "read_only",
11+
testCases: async ({ context, it, log }) => {
12+
let paraApi: ApiPromise;
13+
14+
beforeAll(async function () {
15+
paraApi = context.polkadotJs("para");
16+
const chainId = (await paraApi.query.ethereumChainId.chainId()).toString();
17+
log(`Loading test data for chainId ${chainId}.`);
18+
});
19+
20+
it({
21+
id: "C001",
22+
title: "Verify MOON-2824",
23+
test: async function () {
24+
if (paraApi.consts.system.version.specName.toString() !== "moonriver") {
25+
log("Skipping... (Test specific for moonriver)");
26+
return; // TODO: replace this with this.skip() when added to vitest
27+
}
28+
const CONTRACT_ADDRESS = "0x1b30a3b5744e733d8d2f19f0812e3f79152a8777";
29+
const ERROR_STARTED_AT_BLOCK = `0x${(1471037).toString(16)}`;
30+
const abi = [{
31+
"inputs": [
32+
{
33+
"internalType": "address",
34+
"name": "who",
35+
"type": "address"
36+
},
37+
{
38+
"internalType": "uint256",
39+
"name": "n",
40+
"type": "uint256"
41+
}
42+
],
43+
"name": "balanceOf",
44+
"outputs": [
45+
{
46+
"internalType": "uint256",
47+
"name": "",
48+
"type": "uint256"
49+
}
50+
],
51+
"stateMutability": "view",
52+
"type": "function"
53+
}];
54+
const calldata = encodeFunctionData({
55+
abi,
56+
functionName: "balanceOf",
57+
args: ["0x30763be2bf075c3fDeA704c5f59A76d011d02943", 2],
58+
});
59+
const result = await (context.ethers().provider as ethers.JsonRpcProvider).call(
60+
{
61+
to: CONTRACT_ADDRESS,
62+
data: calldata,
63+
// The error occurs between runtime 1201 and 1605
64+
// https://docs.moonbeam.network/builders/build/runtime-upgrades/
65+
blockTag: ERROR_STARTED_AT_BLOCK,
66+
67+
},
68+
);
69+
70+
expect(result).to.contain("0x");
71+
},
72+
});
73+
74+
it({
75+
id: "C002",
76+
title: "Verify MOON-2822",
77+
test: async function () {
78+
if (paraApi.consts.system.version.specName.toString() !== "moonbeam") {
79+
log("Skipping... (Test specific for moonbeam)");
80+
return; // TODO: replace this with this.skip() when added to vitest
81+
}
82+
const CONTRACT_ADDRESS = "0xFfFFfFff1FcaCBd218EDc0EbA20Fc2308C778080";
83+
const abi = [
84+
{
85+
"inputs": [],
86+
"name": "totalSupply",
87+
"outputs": [],
88+
"stateMutability": "nonpayable",
89+
"type": "function"
90+
}
91+
];
92+
const calldata = encodeFunctionData({
93+
abi,
94+
functionName: "totalSupply",
95+
args: [],
96+
});
97+
const result = await (context.ethers().provider as ethers.JsonRpcProvider).call(
98+
{
99+
to: CONTRACT_ADDRESS,
100+
from: "0xA9f7C749DdCd4E1b86eC539970DEA61a63A6CDD4",
101+
data: calldata,
102+
blockTag: "latest",
103+
},
104+
);
105+
106+
expect(result).to.contain("0x");
107+
},
108+
});
109+
},
110+
});

0 commit comments

Comments
 (0)