@chainlink/external-adapter-framework 0.0.22 → 0.0.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cache/factory.js +27 -0
- package/cache/index.js +16 -1
- package/cache/local.js +26 -0
- package/cache/redis.js +45 -0
- package/package.json +2 -2
- package/transports/batch-warming.js +36 -0
- package/transports/rest.js +32 -0
- package/transports/util.js +33 -0
- package/transports/websocket.js +31 -0
- package/adapter.d.ts +0 -139
- package/background-executor.d.ts +0 -9
- package/cache/factory.d.ts +0 -6
- package/cache/index.d.ts +0 -94
- package/cache/local.d.ts +0 -23
- package/cache/metrics.d.ts +0 -27
- package/cache/redis.d.ts +0 -16
- package/config/index.d.ts +0 -258
- package/config/provider-limits.d.ts +0 -27
- package/examples/bank-frick/accounts.d.ts +0 -39
- package/examples/bank-frick/config/index.d.ts +0 -4
- package/examples/bank-frick/index.d.ts +0 -2
- package/examples/bank-frick/util.d.ts +0 -4
- package/examples/coingecko/batch-warming.d.ts +0 -7
- package/examples/coingecko/batch-warming.js +0 -53
- package/examples/coingecko/index.d.ts +0 -2
- package/examples/coingecko/index.js +0 -11
- package/examples/coingecko/rest.d.ts +0 -12
- package/examples/coingecko/rest.js +0 -51
- package/examples/coingecko/src/config/index.d.ts +0 -2
- package/examples/coingecko/src/cryptoUtils.d.ts +0 -31
- package/examples/coingecko/src/endpoint/coins.d.ts +0 -9
- package/examples/coingecko/src/endpoint/crypto-marketcap.d.ts +0 -3
- package/examples/coingecko/src/endpoint/crypto-volume.d.ts +0 -3
- package/examples/coingecko/src/endpoint/crypto.d.ts +0 -3
- package/examples/coingecko/src/endpoint/dominance.d.ts +0 -3
- package/examples/coingecko/src/endpoint/global-marketcap.d.ts +0 -3
- package/examples/coingecko/src/endpoint/index.d.ts +0 -6
- package/examples/coingecko/src/globalUtils.d.ts +0 -27
- package/examples/coingecko/src/index.d.ts +0 -4
- package/examples/coingecko/test/e2e/adapter.test.js +0 -262
- package/examples/coingecko/test/integration/adapter.test.js +0 -264
- package/examples/coingecko/test/integration/capturedRequests.json +0 -1
- package/examples/coingecko/test/integration/fixtures.js +0 -41
- package/examples/coingecko-old/batch-warming.d.ts +0 -7
- package/examples/coingecko-old/index.d.ts +0 -2
- package/examples/coingecko-old/rest.d.ts +0 -12
- package/examples/ncfx/config/index.d.ts +0 -12
- package/examples/ncfx/index.d.ts +0 -13
- package/examples/ncfx/websocket.d.ts +0 -47
- package/index.d.ts +0 -11
- package/metrics/constants.d.ts +0 -16
- package/metrics/index.d.ts +0 -15
- package/metrics/util.d.ts +0 -7
- package/rate-limiting/background/fixed-frequency.d.ts +0 -11
- package/rate-limiting/index.d.ts +0 -55
- package/rate-limiting/metrics.d.ts +0 -3
- package/rate-limiting/request/simple-counting.d.ts +0 -21
- package/test.d.ts +0 -1
- package/test.js +0 -6
- package/transports/batch-warming.d.ts +0 -35
- package/transports/index.d.ts +0 -73
- package/transports/metrics.d.ts +0 -22
- package/transports/rest.d.ts +0 -44
- package/transports/util.d.ts +0 -9
- package/transports/websocket.d.ts +0 -80
- package/util/index.d.ts +0 -12
- package/util/logger.d.ts +0 -42
- package/util/recordRequests.js +0 -45
- package/util/request.d.ts +0 -56
- package/util/subscription-set/expiring-sorted-set.d.ts +0 -22
- package/util/subscription-set/subscription-set.d.ts +0 -18
- package/util/test-payload-loader.d.ts +0 -25
- package/validation/error.d.ts +0 -50
- package/validation/index.d.ts +0 -5
- package/validation/input-params.d.ts +0 -15
- package/validation/override-functions.d.ts +0 -3
- package/validation/overrideFunctions.js +0 -40
- package/validation/validator.d.ts +0 -47
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { AxiosRequestConfig, AxiosResponse } from 'axios';
|
|
2
|
-
import { AdapterConfig } from '../../../config';
|
|
3
|
-
import { InputParameters } from '../../../validation';
|
|
4
|
-
export interface CryptoRequestParams {
|
|
5
|
-
coinid?: string;
|
|
6
|
-
base?: string;
|
|
7
|
-
quote: string;
|
|
8
|
-
}
|
|
9
|
-
export declare const cryptoInputParams: InputParameters;
|
|
10
|
-
export interface ProviderRequestBody {
|
|
11
|
-
ids: string;
|
|
12
|
-
vs_currencies: string;
|
|
13
|
-
include_market_cap?: boolean;
|
|
14
|
-
include_24hr_vol?: boolean;
|
|
15
|
-
}
|
|
16
|
-
export interface ProviderResponseBody {
|
|
17
|
-
[base: string]: {
|
|
18
|
-
[quote: string]: number;
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
interface ResultEntryWithoutOverrides {
|
|
22
|
-
value: number;
|
|
23
|
-
params: {
|
|
24
|
-
quote: string;
|
|
25
|
-
base?: string;
|
|
26
|
-
coinid?: string;
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
export declare const buildBatchedRequestBody: (params: CryptoRequestParams[], config: AdapterConfig) => AxiosRequestConfig<ProviderRequestBody>;
|
|
30
|
-
export declare const constructEntry: (res: AxiosResponse<ProviderResponseBody>, requestPayload: CryptoRequestParams, resultPath: string) => ResultEntryWithoutOverrides | undefined;
|
|
31
|
-
export {};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { AdapterEndpoint } from '../../../../../src/adapter';
|
|
2
|
-
import { InputParameters } from '../../../../../src/validation';
|
|
3
|
-
export declare const inputParameters: InputParameters;
|
|
4
|
-
export interface CoinsResponse {
|
|
5
|
-
id: string;
|
|
6
|
-
symbol: string;
|
|
7
|
-
name: string;
|
|
8
|
-
}
|
|
9
|
-
export declare const endpoint: AdapterEndpoint<import("../../../../util/request").AdapterRequestData, CoinsResponse[], import("../../../../config").SettingsMap>;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export { endpoint as coins } from './coins';
|
|
2
|
-
export { endpoint as crypto } from './crypto';
|
|
3
|
-
export { endpoint as cryptoMarketcap } from './crypto-marketcap';
|
|
4
|
-
export { endpoint as globalMarketcap } from './global-marketcap';
|
|
5
|
-
export { endpoint as dominance } from './dominance';
|
|
6
|
-
export { endpoint as cryptoVolume } from './crypto-volume';
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { AxiosRequestConfig, AxiosResponse } from 'axios';
|
|
2
|
-
import { InputParameters } from '../../../validation';
|
|
3
|
-
export declare const inputParameters: InputParameters;
|
|
4
|
-
export interface AdapterRequestParams {
|
|
5
|
-
market: string;
|
|
6
|
-
}
|
|
7
|
-
export interface ProviderResponseBody {
|
|
8
|
-
data: {
|
|
9
|
-
active_cryptocurrencies: number;
|
|
10
|
-
upcoming_icos: number;
|
|
11
|
-
ongoing_icos: number;
|
|
12
|
-
ended_icos: number;
|
|
13
|
-
markets: number;
|
|
14
|
-
total_market_cap: Record<string, number>;
|
|
15
|
-
total_volume: Record<string, number>;
|
|
16
|
-
market_cap_percentage: Record<string, number>;
|
|
17
|
-
market_cap_change_percentage_24h_usd: number;
|
|
18
|
-
updated_at: number;
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
interface ResultEntry {
|
|
22
|
-
value: number;
|
|
23
|
-
params: AdapterRequestParams;
|
|
24
|
-
}
|
|
25
|
-
export declare const buildGlobalRequestBody: (apiKey?: string) => AxiosRequestConfig<never>;
|
|
26
|
-
export declare const constructEntry: (res: AxiosResponse<ProviderResponseBody>, requestPayload: AdapterRequestParams, resultPath: 'total_market_cap' | 'market_cap_percentage') => ResultEntry | undefined;
|
|
27
|
-
export {};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { Adapter } from '../../../../src/adapter';
|
|
3
|
-
export declare const adapter: Adapter<import("../../../config").SettingsMap>;
|
|
4
|
-
export declare const server: () => Promise<import("fastify").FastifyInstance<import("fastify").RawServerDefault, import("http").IncomingMessage, import("http").ServerResponse<import("http").IncomingMessage>, import("fastify").FastifyBaseLogger, import("fastify").FastifyTypeProviderDefault> | undefined>;
|
|
@@ -1,262 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
/* eslint-disable max-nested-callbacks */
|
|
7
|
-
const index_1 = require("../../src/index");
|
|
8
|
-
const __1 = require("../../../..");
|
|
9
|
-
const supertest_1 = __importDefault(require("supertest"));
|
|
10
|
-
let adapterServer;
|
|
11
|
-
function sleep(ms) {
|
|
12
|
-
// eslint-disable-next-line
|
|
13
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
14
|
-
}
|
|
15
|
-
describe('execute', () => {
|
|
16
|
-
const id = '1';
|
|
17
|
-
let req;
|
|
18
|
-
jest.setTimeout(10000);
|
|
19
|
-
const successfulRequests = {
|
|
20
|
-
crypto: {
|
|
21
|
-
id,
|
|
22
|
-
data: {
|
|
23
|
-
base: 'ETH',
|
|
24
|
-
quote: 'USD',
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
cryptoWithCoinid: {
|
|
28
|
-
id,
|
|
29
|
-
data: {
|
|
30
|
-
coinid: 'bitcoin',
|
|
31
|
-
quote: 'USD',
|
|
32
|
-
},
|
|
33
|
-
},
|
|
34
|
-
cryptoWithOverride: {
|
|
35
|
-
id,
|
|
36
|
-
data: {
|
|
37
|
-
base: 'BTC',
|
|
38
|
-
quote: 'EUR',
|
|
39
|
-
overrides: {
|
|
40
|
-
coingecko: {
|
|
41
|
-
BTC: 'solana',
|
|
42
|
-
},
|
|
43
|
-
},
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
coins: {
|
|
47
|
-
id,
|
|
48
|
-
endpoint: 'coins',
|
|
49
|
-
},
|
|
50
|
-
marketcap: {
|
|
51
|
-
id,
|
|
52
|
-
endpoint: 'marketcap',
|
|
53
|
-
data: {
|
|
54
|
-
base: 'ETH',
|
|
55
|
-
quote: 'USD',
|
|
56
|
-
},
|
|
57
|
-
},
|
|
58
|
-
volume: {
|
|
59
|
-
id,
|
|
60
|
-
endpoint: 'volume',
|
|
61
|
-
data: {
|
|
62
|
-
base: 'ETH',
|
|
63
|
-
quote: 'USD',
|
|
64
|
-
},
|
|
65
|
-
},
|
|
66
|
-
globalmarketcap: {
|
|
67
|
-
id,
|
|
68
|
-
endpoint: 'globalmarketcap',
|
|
69
|
-
data: {
|
|
70
|
-
market: 'ETH',
|
|
71
|
-
},
|
|
72
|
-
},
|
|
73
|
-
dominance: {
|
|
74
|
-
id,
|
|
75
|
-
endpoint: 'dominance',
|
|
76
|
-
data: {
|
|
77
|
-
market: 'ETH',
|
|
78
|
-
},
|
|
79
|
-
},
|
|
80
|
-
};
|
|
81
|
-
const errorRequests = {
|
|
82
|
-
cryptoWithBadSymbol: {
|
|
83
|
-
id,
|
|
84
|
-
data: {
|
|
85
|
-
base: 'ZWXK',
|
|
86
|
-
quote: 'USD',
|
|
87
|
-
},
|
|
88
|
-
},
|
|
89
|
-
cryptoWithBadOverride: {
|
|
90
|
-
id,
|
|
91
|
-
data: {
|
|
92
|
-
base: 'LINK',
|
|
93
|
-
quote: 'USD',
|
|
94
|
-
overrides: {
|
|
95
|
-
coingecko: {
|
|
96
|
-
LINK: 'badtokenid',
|
|
97
|
-
},
|
|
98
|
-
},
|
|
99
|
-
},
|
|
100
|
-
},
|
|
101
|
-
dominanceWithBadSymbol: {
|
|
102
|
-
id,
|
|
103
|
-
endpoint: 'dominance',
|
|
104
|
-
data: {
|
|
105
|
-
market: 'ZWXK',
|
|
106
|
-
},
|
|
107
|
-
},
|
|
108
|
-
};
|
|
109
|
-
beforeAll(async () => {
|
|
110
|
-
try {
|
|
111
|
-
adapterServer = await (0, __1.expose)(index_1.adapter);
|
|
112
|
-
req = (0, supertest_1.default)('localhost:8080');
|
|
113
|
-
}
|
|
114
|
-
catch {
|
|
115
|
-
throw new Error('Could not start server when running CoinGecko e2e tests');
|
|
116
|
-
}
|
|
117
|
-
if (!adapterServer) {
|
|
118
|
-
throw new Error('Could not start server when running CoinGecko e2e tests');
|
|
119
|
-
}
|
|
120
|
-
// Send inital requests to warm the cache
|
|
121
|
-
const pendingRequests = [];
|
|
122
|
-
for (const reqData of Object.values(successfulRequests)) {
|
|
123
|
-
pendingRequests.push(req.post('/').send(reqData));
|
|
124
|
-
}
|
|
125
|
-
for (const reqData of Object.values(errorRequests)) {
|
|
126
|
-
pendingRequests.push(req.post('/').send(reqData));
|
|
127
|
-
}
|
|
128
|
-
// Wait for all the pending requests to be complete
|
|
129
|
-
Promise.all(pendingRequests);
|
|
130
|
-
// Sleep while the cache is filled
|
|
131
|
-
await sleep(5000);
|
|
132
|
-
});
|
|
133
|
-
afterAll((done) => {
|
|
134
|
-
if (adapterServer) {
|
|
135
|
-
adapterServer.close(done());
|
|
136
|
-
}
|
|
137
|
-
});
|
|
138
|
-
describe('crypto api', () => {
|
|
139
|
-
it('should return success', async () => {
|
|
140
|
-
// Send inital request to warm cache
|
|
141
|
-
const response = await req
|
|
142
|
-
.post('/')
|
|
143
|
-
.send(successfulRequests.crypto)
|
|
144
|
-
.set('Accept', '*/*')
|
|
145
|
-
.set('Content-Type', 'application/json')
|
|
146
|
-
.expect(200);
|
|
147
|
-
expect(response.body.result).toBeGreaterThan(0);
|
|
148
|
-
});
|
|
149
|
-
it('should return success with coinid', async () => {
|
|
150
|
-
const response = await req
|
|
151
|
-
.post('/')
|
|
152
|
-
.send(successfulRequests.cryptoWithCoinid)
|
|
153
|
-
.set('Accept', '*/*')
|
|
154
|
-
.set('Content-Type', 'application/json')
|
|
155
|
-
.expect('Content-Type', /json/)
|
|
156
|
-
.expect(200);
|
|
157
|
-
expect(response.body.result).toBeGreaterThan(0);
|
|
158
|
-
});
|
|
159
|
-
it('should return error message for bad symbol', async () => {
|
|
160
|
-
await req
|
|
161
|
-
.post('/')
|
|
162
|
-
.send(errorRequests.cryptoWithBadSymbol)
|
|
163
|
-
.set('Accept', '*/*')
|
|
164
|
-
.set('Content-Type', 'application/json')
|
|
165
|
-
.expect(504);
|
|
166
|
-
});
|
|
167
|
-
it('should return success with override', async () => {
|
|
168
|
-
const response = await req
|
|
169
|
-
.post('/')
|
|
170
|
-
.send(successfulRequests.cryptoWithOverride)
|
|
171
|
-
.set('Accept', '*/*')
|
|
172
|
-
.set('Content-Type', 'application/json')
|
|
173
|
-
.expect('Content-Type', /json/)
|
|
174
|
-
.expect(200);
|
|
175
|
-
expect(response.body.result).toBeGreaterThan(0);
|
|
176
|
-
});
|
|
177
|
-
it('should return 504 for bad override', async () => {
|
|
178
|
-
const response = await req
|
|
179
|
-
.post('/')
|
|
180
|
-
.send(errorRequests.cryptoWithBadOverride)
|
|
181
|
-
.set('Accept', '*/*')
|
|
182
|
-
.set('Content-Type', 'application/json')
|
|
183
|
-
.expect(504);
|
|
184
|
-
expect(typeof response.body.result === 'string');
|
|
185
|
-
});
|
|
186
|
-
it('should return 504 for bad symbol', async () => {
|
|
187
|
-
await req
|
|
188
|
-
.post('/')
|
|
189
|
-
.send(errorRequests.cryptoWithBadSymbol)
|
|
190
|
-
.set('Accept', '*/*')
|
|
191
|
-
.set('Content-Type', 'application/json')
|
|
192
|
-
.expect(504);
|
|
193
|
-
});
|
|
194
|
-
});
|
|
195
|
-
describe('coins api', () => {
|
|
196
|
-
it('should return success', async () => {
|
|
197
|
-
await req
|
|
198
|
-
.post('/')
|
|
199
|
-
.send(successfulRequests.coins)
|
|
200
|
-
.set('Accept', '*/*')
|
|
201
|
-
.set('Content-Type', 'application/json')
|
|
202
|
-
.expect('Content-Type', /json/)
|
|
203
|
-
.expect(200);
|
|
204
|
-
});
|
|
205
|
-
});
|
|
206
|
-
describe('volume api', () => {
|
|
207
|
-
it('should return success', async () => {
|
|
208
|
-
const response = await req
|
|
209
|
-
.post('/')
|
|
210
|
-
.send(successfulRequests.volume)
|
|
211
|
-
.set('Accept', '*/*')
|
|
212
|
-
.set('Content-Type', 'application/json')
|
|
213
|
-
.expect('Content-Type', /json/)
|
|
214
|
-
.expect(200);
|
|
215
|
-
expect(response.body.result).toBeGreaterThan(0);
|
|
216
|
-
});
|
|
217
|
-
});
|
|
218
|
-
describe('marketcap api', () => {
|
|
219
|
-
it('should return success', async () => {
|
|
220
|
-
const response = await req
|
|
221
|
-
.post('/')
|
|
222
|
-
.send(successfulRequests.marketcap)
|
|
223
|
-
.set('Accept', '*/*')
|
|
224
|
-
.set('Content-Type', 'application/json')
|
|
225
|
-
.expect('Content-Type', /json/)
|
|
226
|
-
.expect(200);
|
|
227
|
-
expect(response.body.result).toBeGreaterThan(0);
|
|
228
|
-
});
|
|
229
|
-
});
|
|
230
|
-
describe('globalmarketcap api', () => {
|
|
231
|
-
it('should return success', async () => {
|
|
232
|
-
const response = await req
|
|
233
|
-
.post('/')
|
|
234
|
-
.send(successfulRequests.globalmarketcap)
|
|
235
|
-
.set('Accept', '*/*')
|
|
236
|
-
.set('Content-Type', 'application/json')
|
|
237
|
-
.expect('Content-Type', /json/)
|
|
238
|
-
.expect(200);
|
|
239
|
-
expect(response.body.result).toBeGreaterThan(0);
|
|
240
|
-
});
|
|
241
|
-
});
|
|
242
|
-
describe('dominance api', () => {
|
|
243
|
-
it('should return success', async () => {
|
|
244
|
-
const response = await req
|
|
245
|
-
.post('/')
|
|
246
|
-
.send(successfulRequests.dominance)
|
|
247
|
-
.set('Accept', '*/*')
|
|
248
|
-
.set('Content-Type', 'application/json')
|
|
249
|
-
.expect('Content-Type', /json/)
|
|
250
|
-
.expect(200);
|
|
251
|
-
expect(response.body.result).toBeGreaterThan(0);
|
|
252
|
-
});
|
|
253
|
-
it('should return 504 for bad symbol', async () => {
|
|
254
|
-
await req
|
|
255
|
-
.post('/')
|
|
256
|
-
.send(errorRequests.dominanceWithBadSymbol)
|
|
257
|
-
.set('Accept', '*/*')
|
|
258
|
-
.set('Content-Type', 'application/json')
|
|
259
|
-
.expect(504);
|
|
260
|
-
});
|
|
261
|
-
});
|
|
262
|
-
});
|
|
@@ -1,264 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
/* eslint-disable max-nested-callbacks */
|
|
7
|
-
const index_1 = require("../../src/index");
|
|
8
|
-
const __1 = require("../../../..");
|
|
9
|
-
const supertest_1 = __importDefault(require("supertest"));
|
|
10
|
-
const fixtures_1 = require("./fixtures");
|
|
11
|
-
let adapterServer;
|
|
12
|
-
function sleep(ms) {
|
|
13
|
-
// eslint-disable-next-line
|
|
14
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
15
|
-
}
|
|
16
|
-
describe('execute', () => {
|
|
17
|
-
const id = '1';
|
|
18
|
-
let req;
|
|
19
|
-
jest.setTimeout(10000);
|
|
20
|
-
const successfulRequests = {
|
|
21
|
-
crypto: {
|
|
22
|
-
id,
|
|
23
|
-
data: {
|
|
24
|
-
base: 'ETH',
|
|
25
|
-
quote: 'USD',
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
|
-
cryptoWithCoinid: {
|
|
29
|
-
id,
|
|
30
|
-
data: {
|
|
31
|
-
coinid: 'bitcoin',
|
|
32
|
-
quote: 'USD',
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
|
-
cryptoWithOverride: {
|
|
36
|
-
id,
|
|
37
|
-
data: {
|
|
38
|
-
base: 'BTC',
|
|
39
|
-
quote: 'EUR',
|
|
40
|
-
overrides: {
|
|
41
|
-
coingecko: {
|
|
42
|
-
BTC: 'solana',
|
|
43
|
-
},
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
|
-
coins: {
|
|
48
|
-
id,
|
|
49
|
-
endpoint: 'coins',
|
|
50
|
-
},
|
|
51
|
-
marketcap: {
|
|
52
|
-
id,
|
|
53
|
-
endpoint: 'marketcap',
|
|
54
|
-
data: {
|
|
55
|
-
base: 'ETH',
|
|
56
|
-
quote: 'USD',
|
|
57
|
-
},
|
|
58
|
-
},
|
|
59
|
-
volume: {
|
|
60
|
-
id,
|
|
61
|
-
endpoint: 'volume',
|
|
62
|
-
data: {
|
|
63
|
-
base: 'ETH',
|
|
64
|
-
quote: 'USD',
|
|
65
|
-
},
|
|
66
|
-
},
|
|
67
|
-
globalmarketcap: {
|
|
68
|
-
id,
|
|
69
|
-
endpoint: 'globalmarketcap',
|
|
70
|
-
data: {
|
|
71
|
-
market: 'ETH',
|
|
72
|
-
},
|
|
73
|
-
},
|
|
74
|
-
dominance: {
|
|
75
|
-
id,
|
|
76
|
-
endpoint: 'dominance',
|
|
77
|
-
data: {
|
|
78
|
-
market: 'ETH',
|
|
79
|
-
},
|
|
80
|
-
},
|
|
81
|
-
};
|
|
82
|
-
const errorRequests = {
|
|
83
|
-
cryptoWithBadSymbol: {
|
|
84
|
-
id,
|
|
85
|
-
data: {
|
|
86
|
-
base: 'ZWXK',
|
|
87
|
-
quote: 'USD',
|
|
88
|
-
},
|
|
89
|
-
},
|
|
90
|
-
cryptoWithBadOverride: {
|
|
91
|
-
id,
|
|
92
|
-
data: {
|
|
93
|
-
base: 'LINK',
|
|
94
|
-
quote: 'USD',
|
|
95
|
-
overrides: {
|
|
96
|
-
coingecko: {
|
|
97
|
-
LINK: 'badtokenid',
|
|
98
|
-
},
|
|
99
|
-
},
|
|
100
|
-
},
|
|
101
|
-
},
|
|
102
|
-
dominanceWithBadSymbol: {
|
|
103
|
-
id,
|
|
104
|
-
endpoint: 'dominance',
|
|
105
|
-
data: {
|
|
106
|
-
market: 'ZWXK',
|
|
107
|
-
},
|
|
108
|
-
},
|
|
109
|
-
};
|
|
110
|
-
beforeAll(async () => {
|
|
111
|
-
try {
|
|
112
|
-
adapterServer = await (0, __1.expose)(index_1.adapter);
|
|
113
|
-
req = (0, supertest_1.default)('localhost:8080');
|
|
114
|
-
}
|
|
115
|
-
catch {
|
|
116
|
-
throw new Error('Could not start server when running CoinGecko e2e tests');
|
|
117
|
-
}
|
|
118
|
-
if (!adapterServer) {
|
|
119
|
-
throw new Error('Could not start server when running CoinGecko e2e tests');
|
|
120
|
-
}
|
|
121
|
-
(0, fixtures_1.createMocks)();
|
|
122
|
-
// Send inital requests to warm the cache
|
|
123
|
-
const pendingRequests = [];
|
|
124
|
-
for (const reqData of Object.values(successfulRequests)) {
|
|
125
|
-
pendingRequests.push(req.post('/').send(reqData));
|
|
126
|
-
}
|
|
127
|
-
for (const reqData of Object.values(errorRequests)) {
|
|
128
|
-
pendingRequests.push(req.post('/').send(reqData));
|
|
129
|
-
}
|
|
130
|
-
// Wait for all the pending requests to be complete
|
|
131
|
-
Promise.all(pendingRequests);
|
|
132
|
-
// Sleep while the cache is filled
|
|
133
|
-
await sleep(5000);
|
|
134
|
-
});
|
|
135
|
-
afterAll((done) => {
|
|
136
|
-
if (adapterServer) {
|
|
137
|
-
adapterServer.close(done());
|
|
138
|
-
}
|
|
139
|
-
});
|
|
140
|
-
describe('crypto api', () => {
|
|
141
|
-
it('should return success', async () => {
|
|
142
|
-
// Send inital request to warm cache
|
|
143
|
-
const response = await req
|
|
144
|
-
.post('/')
|
|
145
|
-
.send(successfulRequests.crypto)
|
|
146
|
-
.set('Accept', '*/*')
|
|
147
|
-
.set('Content-Type', 'application/json')
|
|
148
|
-
.expect(200);
|
|
149
|
-
expect(response.body.result).toMatchSnapshot();
|
|
150
|
-
});
|
|
151
|
-
it('should return success with coinid', async () => {
|
|
152
|
-
const response = await req
|
|
153
|
-
.post('/')
|
|
154
|
-
.send(successfulRequests.cryptoWithCoinid)
|
|
155
|
-
.set('Accept', '*/*')
|
|
156
|
-
.set('Content-Type', 'application/json')
|
|
157
|
-
.expect('Content-Type', /json/)
|
|
158
|
-
.expect(200);
|
|
159
|
-
expect(response.body.result).toMatchSnapshot();
|
|
160
|
-
});
|
|
161
|
-
it('should return error message for bad symbol', async () => {
|
|
162
|
-
await req
|
|
163
|
-
.post('/')
|
|
164
|
-
.send(errorRequests.cryptoWithBadSymbol)
|
|
165
|
-
.set('Accept', '*/*')
|
|
166
|
-
.set('Content-Type', 'application/json')
|
|
167
|
-
.expect(504);
|
|
168
|
-
});
|
|
169
|
-
it('should return success with override', async () => {
|
|
170
|
-
const response = await req
|
|
171
|
-
.post('/')
|
|
172
|
-
.send(successfulRequests.cryptoWithOverride)
|
|
173
|
-
.set('Accept', '*/*')
|
|
174
|
-
.set('Content-Type', 'application/json')
|
|
175
|
-
.expect('Content-Type', /json/)
|
|
176
|
-
.expect(200);
|
|
177
|
-
expect(response.body.result).toMatchSnapshot();
|
|
178
|
-
});
|
|
179
|
-
it('should return 504 for bad override', async () => {
|
|
180
|
-
const response = await req
|
|
181
|
-
.post('/')
|
|
182
|
-
.send(errorRequests.cryptoWithBadOverride)
|
|
183
|
-
.set('Accept', '*/*')
|
|
184
|
-
.set('Content-Type', 'application/json')
|
|
185
|
-
.expect(504);
|
|
186
|
-
expect(typeof response.body.result === 'string');
|
|
187
|
-
});
|
|
188
|
-
it('should return 504 for bad symbol', async () => {
|
|
189
|
-
await req
|
|
190
|
-
.post('/')
|
|
191
|
-
.send(errorRequests.cryptoWithBadSymbol)
|
|
192
|
-
.set('Accept', '*/*')
|
|
193
|
-
.set('Content-Type', 'application/json')
|
|
194
|
-
.expect(504);
|
|
195
|
-
});
|
|
196
|
-
});
|
|
197
|
-
describe('coins api', () => {
|
|
198
|
-
it('should return success', async () => {
|
|
199
|
-
await req
|
|
200
|
-
.post('/')
|
|
201
|
-
.send(successfulRequests.coins)
|
|
202
|
-
.set('Accept', '*/*')
|
|
203
|
-
.set('Content-Type', 'application/json')
|
|
204
|
-
.expect('Content-Type', /json/)
|
|
205
|
-
.expect(200);
|
|
206
|
-
});
|
|
207
|
-
});
|
|
208
|
-
describe('volume api', () => {
|
|
209
|
-
it('should return success', async () => {
|
|
210
|
-
const response = await req
|
|
211
|
-
.post('/')
|
|
212
|
-
.send(successfulRequests.volume)
|
|
213
|
-
.set('Accept', '*/*')
|
|
214
|
-
.set('Content-Type', 'application/json')
|
|
215
|
-
.expect('Content-Type', /json/)
|
|
216
|
-
.expect(200);
|
|
217
|
-
expect(response.body.result).toMatchSnapshot();
|
|
218
|
-
});
|
|
219
|
-
});
|
|
220
|
-
describe('marketcap api', () => {
|
|
221
|
-
it('should return success', async () => {
|
|
222
|
-
const response = await req
|
|
223
|
-
.post('/')
|
|
224
|
-
.send(successfulRequests.marketcap)
|
|
225
|
-
.set('Accept', '*/*')
|
|
226
|
-
.set('Content-Type', 'application/json')
|
|
227
|
-
.expect('Content-Type', /json/)
|
|
228
|
-
.expect(200);
|
|
229
|
-
expect(response.body.result).toMatchSnapshot();
|
|
230
|
-
});
|
|
231
|
-
});
|
|
232
|
-
describe('globalmarketcap api', () => {
|
|
233
|
-
it('should return success', async () => {
|
|
234
|
-
const response = await req
|
|
235
|
-
.post('/')
|
|
236
|
-
.send(successfulRequests.globalmarketcap)
|
|
237
|
-
.set('Accept', '*/*')
|
|
238
|
-
.set('Content-Type', 'application/json')
|
|
239
|
-
.expect('Content-Type', /json/)
|
|
240
|
-
.expect(200);
|
|
241
|
-
expect(response.body.result).toMatchSnapshot();
|
|
242
|
-
});
|
|
243
|
-
});
|
|
244
|
-
describe('dominance api', () => {
|
|
245
|
-
it('should return success', async () => {
|
|
246
|
-
const response = await req
|
|
247
|
-
.post('/')
|
|
248
|
-
.send(successfulRequests.dominance)
|
|
249
|
-
.set('Accept', '*/*')
|
|
250
|
-
.set('Content-Type', 'application/json')
|
|
251
|
-
.expect('Content-Type', /json/)
|
|
252
|
-
.expect(200);
|
|
253
|
-
expect(response.body.result).toMatchSnapshot();
|
|
254
|
-
});
|
|
255
|
-
it('should return 504 for bad symbol', async () => {
|
|
256
|
-
await req
|
|
257
|
-
.post('/')
|
|
258
|
-
.send(errorRequests.dominanceWithBadSymbol)
|
|
259
|
-
.set('Accept', '*/*')
|
|
260
|
-
.set('Content-Type', 'application/json')
|
|
261
|
-
.expect(504);
|
|
262
|
-
});
|
|
263
|
-
});
|
|
264
|
-
});
|