forked from smartcontractkit/external-adapters-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadapter.test.ts
87 lines (82 loc) · 2.23 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
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
import { AdapterRequest } from '@chainlink/types'
import request, { SuperTest, Test } from 'supertest'
import { server as startServer } from '../../src'
import * as http from 'http'
import { AddressInfo } from 'net'
describe('execute', () => {
const id = '1'
let server: http.Server
let req: SuperTest<Test>
beforeAll(async () => {
server = await startServer()
req = request(`localhost:${(server.address() as AddressInfo).port}`)
})
afterAll((done) => {
server.close(done)
})
describe('reduce adapter', () => {
const data: AdapterRequest = {
id,
data: {
reducer: 'sum',
initialValue: 0,
dataPath: 'addresses',
valuePath: 'balance',
addresses: [
{
address: '3D8DJLwUXFfZvE8yJRu729MZ8uLy25SuLz',
coin: 'btc',
chain: 'mainnet',
balance: 44900000000,
},
{
address: '3EyjZ6CtEZEKyc719NZMyWaJpJG5jsVJL1',
coin: 'btc',
chain: 'mainnet',
balance: 9899463044,
},
{
address: '38bzm6nhQMFJe71jJw1U7CbgNrVNpkonZF',
coin: 'btc',
chain: 'mainnet',
balance: 307499838499,
},
{
address: '3ANaBZ6odMrzdg9xifgRNxAUFUxnReesws',
coin: 'btc',
chain: 'mainnet',
balance: 904070305884,
},
{
address: '3FFgKaYkEf1M73QtzuY9DGqC7VeM2sAQhT',
coin: 'btc',
chain: 'mainnet',
balance: 80000,
},
{
address: '3KTeq879YjzhqkAXzZmdapJAVC6qz5qEth',
coin: 'btc',
chain: 'mainnet',
balance: 264148085712,
},
{
address: '35ULMyVnFoYaPaMxwHTRmaGdABpAThM4QR',
coin: 'btc',
chain: 'mainnet',
balance: 2601100000,
},
],
},
}
it('should return success', async () => {
const response = await req
.post('/')
.send(data)
.set('Accept', '*/*')
.set('Content-Type', 'application/json')
.expect('Content-Type', /json/)
.expect(200)
expect(response.body).toMatchSnapshot()
})
})
})