-
Notifications
You must be signed in to change notification settings - Fork 308
/
adapter.test.ts
56 lines (49 loc) · 1.43 KB
/
adapter.test.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
import { AdapterRequest, Execute } from '@chainlink/ea-bootstrap'
import { makeExecute } from '../../src'
import { ethers } from 'ethers'
import { setEnvVariables } from '@chainlink/ea-test-helpers'
jest.mock('ethers', () => ({
...jest.requireActual('ethers'),
ethers: {
providers: {
JsonRpcProvider: function (): ethers.providers.JsonRpcProvider {
return {} as ethers.providers.JsonRpcProvider
},
},
Contract: function () {
return {
walletAddresses: () => {
return [
'addr_test1qz87tn9yat3xfutzds43tnj8qw457hk3v46w4028rtnx56v89wjwnrwcvlfm2atvcnnclh3x7thwrl7pgnffaw24mgws0dga4m',
]
},
}
},
},
}))
let oldEnv: NodeJS.ProcessEnv
describe('chain-reserve-wallet', () => {
let execute: Execute
beforeAll(async () => {
oldEnv = JSON.parse(JSON.stringify(process.env))
process.env.RPC_URL = process.env.RPC_URL || 'test-endpoint'
execute = makeExecute() as Execute
})
afterAll(() => {
setEnvVariables(oldEnv)
})
describe('when making a request to fetch the contract addresses', () => {
const data: AdapterRequest = {
id: '1',
data: {
chainId: 'testnet',
network: 'cardano',
contractAddress: '0xAe1932a83DeD75db2afD1E4EC6c0D4241554100A',
},
}
it('is successful', async () => {
const response = await execute(data, {})
expect(response).toMatchSnapshot()
})
})
})