|
1 | | -import {InfuraProvider} from '@ethersproject/providers'; |
| 1 | +import { InfuraProvider } from '@ethersproject/providers'; |
2 | 2 | import { assert } from 'chai'; |
3 | 3 | import { Contract, Provider } from '../src'; |
4 | 4 |
|
5 | 5 | const provider = new InfuraProvider('mainnet'); |
6 | 6 | const ethcallProvider = new Provider(provider, 1); |
7 | 7 |
|
8 | | -it('human readable abi', async () => { |
9 | | - const abi = ['function totalSupply() public view returns (uint256)']; |
10 | | - const addresses = [ |
11 | | - '0x0bc529c00C6401aEF6D220BE8C6Ea1667F6Ad93e', |
12 | | - '0x1f9840a85d5af5bf1d1762f925bdaddc4201f984' |
13 | | - ]; |
| 8 | +describe('ethereum network', () => { |
| 9 | + it('human readable abi', async () => { |
| 10 | + const abi = ['function totalSupply() public view returns (uint256)']; |
| 11 | + const addresses = [ |
| 12 | + '0x0bc529c00C6401aEF6D220BE8C6Ea1667F6Ad93e', |
| 13 | + '0x1f9840a85d5af5bf1d1762f925bdaddc4201f984' |
| 14 | + ]; |
14 | 15 |
|
15 | | - const yfiContract = new Contract(addresses[0], abi); |
16 | | - const uniContract = new Contract(addresses[1], abi); |
| 16 | + const yfiContract = new Contract(addresses[0], abi); |
| 17 | + const uniContract = new Contract(addresses[1], abi); |
17 | 18 |
|
18 | | - const calls = [yfiContract.totalSupply(), uniContract.totalSupply()]; |
19 | | - const [yfiSupply, uniSupply] = await ethcallProvider.all(calls); |
| 19 | + const calls = [yfiContract.totalSupply(), uniContract.totalSupply()]; |
| 20 | + const [yfiSupply, uniSupply] = await ethcallProvider.all(calls); |
20 | 21 |
|
21 | | - assert.equal(yfiSupply.toString(), '36666000000000000000000'); |
22 | | - assert.equal(uniSupply.toString(), '1000000000000000000000000000'); |
23 | | -}); |
| 22 | + assert.equal(yfiSupply.toString(), '36666000000000000000000'); |
| 23 | + assert.equal(uniSupply.toString(), '1000000000000000000000000000'); |
| 24 | + }).timeout(5_000); |
24 | 25 |
|
25 | | -it('json abi', async () => { |
26 | | - const abi = [ |
27 | | - { |
| 26 | + it('json abi', async () => { |
| 27 | + const abi = [ |
| 28 | + { |
28 | 29 | constant: true, |
29 | 30 | inputs: [], |
30 | 31 | name: 'totalSupply', |
31 | 32 | outputs: [ |
32 | | - { |
33 | | - internalType: 'uint256', |
34 | | - name: '', |
35 | | - type: 'uint256' |
36 | | - } |
| 33 | + { |
| 34 | + internalType: 'uint256', |
| 35 | + name: '', |
| 36 | + type: 'uint256' |
| 37 | + } |
37 | 38 | ], |
38 | 39 | payable: false, |
39 | 40 | stateMutability: 'view', |
40 | 41 | type: 'function' |
41 | | - } |
42 | | - ]; |
43 | | - const addresses = [ |
44 | | - '0x0bc529c00C6401aEF6D220BE8C6Ea1667F6Ad93e', |
45 | | - '0x1f9840a85d5af5bf1d1762f925bdaddc4201f984' |
46 | | - ]; |
47 | | - |
48 | | - const yfiContract = new Contract(addresses[0], abi); |
49 | | - const uniContract = new Contract(addresses[1], abi); |
50 | | - |
51 | | - const calls = [yfiContract.totalSupply(), uniContract.totalSupply()]; |
52 | | - const [yfiSupply, uniSupply] = await ethcallProvider.all(calls); |
53 | | - |
54 | | - assert.equal(yfiSupply.toString(), '36666000000000000000000'); |
55 | | - assert.equal(uniSupply.toString(), '1000000000000000000000000000'); |
56 | | -}); |
| 42 | + } |
| 43 | + ]; |
| 44 | + const addresses = [ |
| 45 | + '0x0bc529c00C6401aEF6D220BE8C6Ea1667F6Ad93e', |
| 46 | + '0x1f9840a85d5af5bf1d1762f925bdaddc4201f984' |
| 47 | + ]; |
| 48 | + |
| 49 | + const yfiContract = new Contract(addresses[0], abi); |
| 50 | + const uniContract = new Contract(addresses[1], abi); |
| 51 | + |
| 52 | + const calls = [yfiContract.totalSupply(), uniContract.totalSupply()]; |
| 53 | + const [yfiSupply, uniSupply] = await ethcallProvider.all(calls); |
| 54 | + |
| 55 | + assert.equal(yfiSupply.toString(), '36666000000000000000000'); |
| 56 | + assert.equal(uniSupply.toString(), '1000000000000000000000000000'); |
| 57 | + }) |
| 58 | +}) |
0 commit comments