forked from smartcontractkit/external-adapters-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadapter.test.ts
55 lines (48 loc) · 1.33 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
import { AdapterRequest, Execute } from '@chainlink/types'
import { makeExecute } from '../../src'
import { ethers } from 'ethers'
jest.mock('ethers', () => ({
...jest.requireActual('ethers'),
ethers: {
providers: {
JsonRpcProvider: function (_: string): ethers.provider.JsonRpcProvider {
return {}
},
},
Contract: function () {
return {
walletAddresses: (____: string) => {
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()
})
afterAll(() => {
process.env = 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()
})
})
})