diff --git a/src/helpers/getCoingeckoCoinList.ts b/src/helpers/getCoingeckoCoinsList.ts similarity index 92% rename from src/helpers/getCoingeckoCoinList.ts rename to src/helpers/getCoingeckoCoinsList.ts index e103196..281ecca 100644 --- a/src/helpers/getCoingeckoCoinList.ts +++ b/src/helpers/getCoingeckoCoinsList.ts @@ -8,12 +8,12 @@ type GeckoCoin = { platforms?: { [key: string]: string }; }; -const COINS_LIST_TTL = 21600000; // 6h +const COINS_LIST_TTL = 86400000; // 24h let gCoinsList: GeckoCoin[] | undefined; let gCoinsListTs = 0; export async function getCoingeckoCoinsList() { - await sleep(300000); + await sleep(5000); if (gCoinsList && Date.now() - COINS_LIST_TTL < gCoinsListTs) return gCoinsList; diff --git a/src/jobs/coingeckoJob.ts b/src/jobs/coingeckoJob.ts index 6da2664..c09a3a2 100644 --- a/src/jobs/coingeckoJob.ts +++ b/src/jobs/coingeckoJob.ts @@ -7,7 +7,7 @@ import { import axios, { AxiosResponse } from 'axios'; import { sleep } from '../helpers/misc'; import { Token, JobFct, Job } from '../types'; -import { getCoingeckoCoinsList } from '../helpers/getCoingeckoCoinList'; +import { getCoingeckoCoinsList } from '../helpers/getCoingeckoCoinsList'; import { constTokensMap } from '../tokens/constTokens'; import { getKey } from '../helpers/getKey'; diff --git a/tests/getCoingeckoCoinsList.test.ts b/tests/getCoingeckoCoinsList.test.ts new file mode 100644 index 0000000..ae06528 --- /dev/null +++ b/tests/getCoingeckoCoinsList.test.ts @@ -0,0 +1,17 @@ +import { getCoingeckoCoinsList } from '../src/helpers/getCoingeckoCoinsList'; + +describe('getCoingeckoCoinsList', () => { + jest.setTimeout(1200000); // Increase the timeout to handle potential network delays + it('sould getCoingeckoCoinsList', async () => { + // eslint-disable-next-line @typescript-eslint/no-unused-vars + const list1 = await getCoingeckoCoinsList(); + + const debut = performance.now(); + // eslint-disable-next-line @typescript-eslint/no-unused-vars + const list2 = await getCoingeckoCoinsList(); + const fin = performance.now(); + const tempsEcoule = fin - debut; + + expect(tempsEcoule).toBeLessThan(1000); + }); +});