Skip to content

Commit aa911af

Browse files
committed
Finish accoiunt tests
1 parent 46b39b1 commit aa911af

File tree

2 files changed

+133
-198
lines changed

2 files changed

+133
-198
lines changed

tests/account.js

-198
This file was deleted.

tests/accounts.js

+133
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
const EtherscanAPI = require('../build')
2+
3+
describe('Etherscan accounts methods', () => {
4+
const e = new EtherscanAPI()
5+
6+
test('getAccountBalance', async () => {
7+
const blaance = await e.getAccountBalance(
8+
'0xde0b295669a9fd93d5f28d9ec85e40f4cb697bae'
9+
)
10+
11+
expect(isNaN(Number(blaance))).toBeFalsy()
12+
})
13+
14+
test('getAccountBalances', () => {
15+
return e
16+
.getAccountBalances([
17+
'0xddbd2b932c763ba5b1b7ae3b362eac3e8d40121a',
18+
'0x63a9975ba31b0b9626b34300f7f627147df1f526',
19+
'0x198ef1ec325a96cc354c7266a038be8b5c558f67'
20+
])
21+
.then(data => {
22+
expect(data.length).toBe(3)
23+
expect(Object.keys(data[0])).toEqual(['account', 'balance'])
24+
})
25+
})
26+
27+
test('getTransactions', () => {
28+
return e
29+
.getTransactions(
30+
'0xddbd2b932c763ba5b1b7ae3b362eac3e8d40121a',
31+
0,
32+
9999999,
33+
3,
34+
3,
35+
'asc'
36+
)
37+
.then(data => {
38+
expect(data.length).toBe(3)
39+
expect(Object.keys(data[0])).toEqual([
40+
'blockNumber',
41+
'timeStamp',
42+
'hash',
43+
'nonce',
44+
'blockHash',
45+
'transactionIndex',
46+
'from',
47+
'to',
48+
'value',
49+
'gas',
50+
'gasPrice',
51+
'isError',
52+
'txreceipt_status',
53+
'input',
54+
'contractAddress',
55+
'cumulativeGasUsed',
56+
'gasUsed',
57+
'confirmations'
58+
])
59+
})
60+
})
61+
62+
test('getInternalTransactions', () => {
63+
return e
64+
.getInternalTransactions(
65+
'0x2c1ba59d6f58433fb1eaee7d20b26ed83bda51a3',
66+
0,
67+
2702578,
68+
3,
69+
3,
70+
'asc'
71+
)
72+
.then(data => {
73+
expect(data.length).toBe(3)
74+
expect(Object.keys(data[0])).toEqual([
75+
'blockNumber',
76+
'timeStamp',
77+
'hash',
78+
'from',
79+
'to',
80+
'value',
81+
'contractAddress',
82+
'input',
83+
'type',
84+
'gas',
85+
'gasUsed',
86+
'traceId',
87+
'isError',
88+
'errCode'
89+
])
90+
})
91+
})
92+
93+
test('getInternalTransactionsByHash', () => {
94+
return e
95+
.getInternalTransactionsByHash(
96+
'0x40eb908387324f2b575b4879cd9d7188f69c8fc9d87c901b9e2daaea4b442170'
97+
)
98+
.then(data => {
99+
expect(Object.keys(data[0])).toEqual([
100+
'blockNumber',
101+
'timeStamp',
102+
'from',
103+
'to',
104+
'value',
105+
'contractAddress',
106+
'input',
107+
'type',
108+
'gas',
109+
'gasUsed',
110+
'isError',
111+
'errCode'
112+
])
113+
})
114+
})
115+
116+
test('getMinedBlocks', () => {
117+
return e
118+
.getMinedBlocks(
119+
'0x9dd134d14d1e65f84b706d6f205cd5b1cd03a46b',
120+
'blocks',
121+
10,
122+
1
123+
)
124+
.then(data => {
125+
expect(data.length).toBe(10)
126+
expect(Object.keys(data[0])).toEqual([
127+
'blockNumber',
128+
'timeStamp',
129+
'blockReward'
130+
])
131+
})
132+
})
133+
})

0 commit comments

Comments
 (0)