forked from smartcontractkit/external-adapters-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfixtures.ts
100 lines (98 loc) · 2.38 KB
/
fixtures.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
import nock from 'nock'
export const mockETHBalanceResponseSuccess = (): nock =>
nock('http://localhost:8545', {
encodedQueryParams: true,
})
.persist()
.post('/', { method: 'eth_chainId', params: [], id: /^\d+$/, jsonrpc: '2.0' })
.reply(200, (_, request) => ({ jsonrpc: '2.0', id: request['id'], result: '0x1' }), [
'Content-Type',
'application/json',
'Connection',
'close',
'Vary',
'Accept-Encoding',
'Vary',
'Origin',
])
.post('/', {
method: 'eth_getBalance',
params: ['0xef9ffcfbecb6213e5903529c8457b6f61141140d', 'latest'],
id: /^\d+$/,
jsonrpc: '2.0',
})
.reply(
200,
(_, request) => ({ jsonrpc: '2.0', id: request['id'], result: '0x2fe84e3113d7b' }),
[
'Content-Type',
'application/json',
'Connection',
'close',
'Vary',
'Accept-Encoding',
'Vary',
'Origin',
],
)
.post('/', {
method: 'eth_getBalance',
params: ['0x6a1544f72a2a275715e8d5924e6d8a017f0e41ed', 'latest'],
id: /^\d+$/,
jsonrpc: '2.0',
})
.reply(
200,
(_, request) => ({ jsonrpc: '2.0', id: request['id'], result: '0x164451e4741c3ada' }),
[
'Content-Type',
'application/json',
'Connection',
'close',
'Vary',
'Accept-Encoding',
'Vary',
'Origin',
],
)
export const mockETHBalanceAtBlockResponseSuccess = (): nock =>
nock('http://localhost:8545', {
encodedQueryParams: true,
})
.persist()
.post('/', {
method: 'eth_blockNumber',
params: [],
id: /^\d+$/,
jsonrpc: '2.0',
})
.reply(200, (_, request) => ({ jsonrpc: '2.0', id: request['id'], result: '0xddae3f' }), [
'Content-Type',
'application/json',
'Connection',
'close',
'Vary',
'Accept-Encoding',
'Vary',
'Origin',
])
.post('/', {
method: 'eth_getBalance',
params: ['0x6a1544f72a2a275715e8d5924e6d8a017f0e41ed', '0xddae2b'],
id: /^\d+$/,
jsonrpc: '2.0',
})
.reply(
200,
(_, request) => ({ jsonrpc: '2.0', id: request['id'], result: '0x37ad4e2c14e7e0' }),
[
'Content-Type',
'application/json',
'Connection',
'close',
'Vary',
'Accept-Encoding',
'Vary',
'Origin',
],
)