Skip to content

Commit 981aa02

Browse files
committed
subscription tests
1 parent 29e56bb commit 981aa02

File tree

17 files changed

+576
-25
lines changed

17 files changed

+576
-25
lines changed

.github/workflows/test.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ jobs:
4242
if: matrix.project == 'eth-providers'
4343
run: yarn workspace @acala-network/eth-rpc-adapter run start:coverage
4444

45+
- name: generate typechain for eth-rpc-adapter tests
46+
if: matrix.project == 'eth-rpc-adapter'
47+
run: yarn workspace @acala-network/eth-rpc-adapter run typegen
48+
4549
- name: run tests
4650
run: yarn workspace @acala-network/${{ matrix.project }} run test:coverage
4751

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,7 @@ lib
7676
**/.yarn/install-state.gz
7777

7878
## openzeppelin cache
79-
**/.openzeppelin/
79+
**/.openzeppelin/
80+
81+
## typechain files
82+
**/types

codecov.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ coverage:
1313

1414
comment:
1515
layout: "reach, diff, flags, files"
16-
behavior: default
16+
behavior: new
1717
require_changes: false
1818
require_base: false
1919
require_head: false

packages/eth-rpc-adapter/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"scripts": {
88
"build": "tsc",
99
"ncc:pack": "ncc build src/index.ts -t --target es2020",
10+
"typegen": "typechain --target=ethers-v5 --out-dir=./src/__tests__/types src/__tests__/abis/*.json",
1011
"dev": "ts-node-dev -T -r tsconfig-paths/register src/index.ts -l | pino-pretty --singleLine --colorize --ignore time,hostname,jsonrpc,dd",
1112
"clean": "rm -rf tsconfig.tsbuildinfo .nyc_output coverage/ lib/",
1213
"health-check": "./scripts/health-check.sh",
@@ -47,6 +48,7 @@
4748
"pm2": "^5.4.2",
4849
"ts-node": "^10.9.1",
4950
"ts-node-dev": "^2.0.0",
51+
"typechain": "^8.3.2",
5052
"vitest": "^2.1.1"
5153
},
5254
"files": [
Lines changed: 260 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,260 @@
1+
{
2+
"abi": [
3+
{
4+
"anonymous": false,
5+
"inputs": [
6+
{
7+
"indexed": true,
8+
"internalType": "address",
9+
"name": "owner",
10+
"type": "address"
11+
},
12+
{
13+
"indexed": true,
14+
"internalType": "address",
15+
"name": "spender",
16+
"type": "address"
17+
},
18+
{
19+
"indexed": false,
20+
"internalType": "uint256",
21+
"name": "value",
22+
"type": "uint256"
23+
}
24+
],
25+
"name": "Approval",
26+
"type": "event"
27+
},
28+
{
29+
"anonymous": false,
30+
"inputs": [
31+
{
32+
"indexed": true,
33+
"internalType": "address",
34+
"name": "from",
35+
"type": "address"
36+
},
37+
{
38+
"indexed": true,
39+
"internalType": "address",
40+
"name": "to",
41+
"type": "address"
42+
},
43+
{
44+
"indexed": false,
45+
"internalType": "uint256",
46+
"name": "value",
47+
"type": "uint256"
48+
}
49+
],
50+
"name": "Transfer",
51+
"type": "event"
52+
},
53+
{
54+
"constant": true,
55+
"inputs": [
56+
{
57+
"internalType": "address",
58+
"name": "owner",
59+
"type": "address"
60+
},
61+
{
62+
"internalType": "address",
63+
"name": "spender",
64+
"type": "address"
65+
}
66+
],
67+
"name": "allowance",
68+
"outputs": [
69+
{
70+
"internalType": "uint256",
71+
"name": "",
72+
"type": "uint256"
73+
}
74+
],
75+
"payable": false,
76+
"stateMutability": "view",
77+
"type": "function"
78+
},
79+
{
80+
"constant": false,
81+
"inputs": [
82+
{
83+
"internalType": "address",
84+
"name": "spender",
85+
"type": "address"
86+
},
87+
{
88+
"internalType": "uint256",
89+
"name": "value",
90+
"type": "uint256"
91+
}
92+
],
93+
"name": "approve",
94+
"outputs": [
95+
{
96+
"internalType": "bool",
97+
"name": "",
98+
"type": "bool"
99+
}
100+
],
101+
"payable": false,
102+
"stateMutability": "nonpayable",
103+
"type": "function"
104+
},
105+
{
106+
"constant": true,
107+
"inputs": [
108+
{
109+
"internalType": "address",
110+
"name": "owner",
111+
"type": "address"
112+
}
113+
],
114+
"name": "balanceOf",
115+
"outputs": [
116+
{
117+
"internalType": "uint256",
118+
"name": "",
119+
"type": "uint256"
120+
}
121+
],
122+
"payable": false,
123+
"stateMutability": "view",
124+
"type": "function"
125+
},
126+
{
127+
"constant": true,
128+
"inputs": [],
129+
"name": "decimals",
130+
"outputs": [
131+
{
132+
"internalType": "uint8",
133+
"name": "",
134+
"type": "uint8"
135+
}
136+
],
137+
"payable": false,
138+
"stateMutability": "view",
139+
"type": "function"
140+
},
141+
{
142+
"constant": true,
143+
"inputs": [],
144+
"name": "name",
145+
"outputs": [
146+
{
147+
"internalType": "string",
148+
"name": "",
149+
"type": "string"
150+
}
151+
],
152+
"payable": false,
153+
"stateMutability": "view",
154+
"type": "function"
155+
},
156+
{
157+
"constant": true,
158+
"inputs": [],
159+
"name": "symbol",
160+
"outputs": [
161+
{
162+
"internalType": "string",
163+
"name": "",
164+
"type": "string"
165+
}
166+
],
167+
"payable": false,
168+
"stateMutability": "view",
169+
"type": "function"
170+
},
171+
{
172+
"constant": true,
173+
"inputs": [],
174+
"name": "totalSupply",
175+
"outputs": [
176+
{
177+
"internalType": "uint256",
178+
"name": "",
179+
"type": "uint256"
180+
}
181+
],
182+
"payable": false,
183+
"stateMutability": "view",
184+
"type": "function"
185+
},
186+
{
187+
"constant": false,
188+
"inputs": [
189+
{
190+
"internalType": "address",
191+
"name": "to",
192+
"type": "address"
193+
},
194+
{
195+
"internalType": "uint256",
196+
"name": "value",
197+
"type": "uint256"
198+
}
199+
],
200+
"name": "transfer",
201+
"outputs": [
202+
{
203+
"internalType": "bool",
204+
"name": "",
205+
"type": "bool"
206+
}
207+
],
208+
"payable": false,
209+
"stateMutability": "nonpayable",
210+
"type": "function"
211+
},
212+
{
213+
"constant": false,
214+
"inputs": [
215+
{
216+
"internalType": "address",
217+
"name": "from",
218+
"type": "address"
219+
},
220+
{
221+
"internalType": "address",
222+
"name": "to",
223+
"type": "address"
224+
},
225+
{
226+
"internalType": "uint256",
227+
"name": "value",
228+
"type": "uint256"
229+
}
230+
],
231+
"name": "transferFrom",
232+
"outputs": [
233+
{
234+
"internalType": "bool",
235+
"name": "",
236+
"type": "bool"
237+
}
238+
],
239+
"payable": false,
240+
"stateMutability": "nonpayable",
241+
"type": "function"
242+
}
243+
],
244+
"evm": {
245+
"bytecode": {
246+
"linkReferences": {},
247+
"object": "",
248+
"opcodes": "",
249+
"sourceMap": ""
250+
},
251+
"deployedBytecode": {
252+
"linkReferences": {},
253+
"object": "",
254+
"opcodes": "",
255+
"sourceMap": ""
256+
}
257+
},
258+
"metadata": "{\"compiler\":{\"version\":\"0.5.16+commit.9c3226ce\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Approval\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Transfer\",\"type\":\"event\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"}],\"name\":\"allowance\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"approve\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"}],\"name\":\"balanceOf\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"decimals\",\"outputs\":[{\"internalType\":\"uint8\",\"name\":\"\",\"type\":\"uint8\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"name\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"symbol\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"totalSupply\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"transfer\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"transferFrom\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"methods\":{}},\"userdoc\":{\"methods\":{}}},\"settings\":{\"compilationTarget\":{\"contracts/interfaces/IERC20.sol\":\"IERC20\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"optimizer\":{\"enabled\":true,\"runs\":999999},\"remappings\":[]},\"sources\":{\"contracts/interfaces/IERC20.sol\":{\"keccak256\":\"0x61db17aebc5d812c7002d15c1da954065e56abe49d64b14c034abe5604d70eb3\",\"urls\":[\"bzz-raw://b006685e753f9120469f10b09c159f222d4cb8b507a6c1f0c14ed50c883ebe66\",\"dweb:/ipfs/QmSyY7iTugbczPwfGK67etiyPULenYGzzRYbt8aabwwkUb\"]}},\"version\":1}",
259+
"bytecode": ""
260+
}

packages/eth-rpc-adapter/src/__tests__/endpoint.test.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,7 @@ import {
6767
toDeterministic,
6868
waitForHeight,
6969
eth_estimateGas,
70-
} from './utils';
7170

72-
import {
7371
ADDRESS_ALICE,
7472
DETERMINISTIC_SETUP_DEX_ADDRESS,
7573
GAS_MONSTER_GAS_REQUIRED,
@@ -81,8 +79,8 @@ import {
8179
deployHelloWorldData,
8280
evmAccounts,
8381
log22_0,
84-
log22_1,
85-
} from './consts';
82+
log22_1 } from './utils';
83+
8684

8785
const subql = new SubqlProvider(SUBQL_URL);
8886

packages/eth-rpc-adapter/src/__tests__/errors.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ import ADDRESS from '@acala-network/contracts/utils/MandalaAddress';
77
import TokenABI from '@acala-network/contracts/build/contracts/Token.json';
88
import axios from 'axios';
99

10-
import { RPC_URL, eth_call, eth_chainId, eth_estimateGas, eth_getEthGas, eth_sendRawTransaction } from './utils';
11-
import { evmAccounts } from './consts';
10+
import { RPC_URL, eth_call, eth_chainId, eth_estimateGas, eth_getEthGas, eth_sendRawTransaction , evmAccounts } from './utils';
1211

1312
describe('errors', () => {
1413
const POOR_ACCOUNT = '0xa872f6cbd25a0e04a08b1e21098017a9e6194d101d75e13111f71410c59cd570';

packages/eth-rpc-adapter/src/__tests__/signer.test.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
import { Eip1193Bridge } from '../eip1193-bridge';
21
import { EvmRpcProvider } from '@acala-network/eth-providers';
32
import { Wallet, verifyMessage } from '@ethersproject/wallet';
43
import { afterAll, describe, expect, it } from 'vitest';
5-
import dotenv from 'dotenv';
64

7-
dotenv.config();
5+
import { Eip1193Bridge } from '../eip1193-bridge';
86

97
const endpoint = process.env.ENDPOINT_URL || 'ws://127.0.0.1:9944';
108

0 commit comments

Comments
 (0)