diff --git a/src/cache/response.ts b/src/cache/response.ts index aac609ee..9e8af79f 100644 --- a/src/cache/response.ts +++ b/src/cache/response.ts @@ -11,7 +11,11 @@ import { makeLogger, } from '../util' import CensorList from '../util/censor/censor-list' -import { InputParameters, InputParametersDefinition, TypeFromDefinition } from '../validation/input-params' +import { + InputParameters, + InputParametersDefinition, + TypeFromDefinition, +} from '../validation/input-params' import { validator } from '../validation/utils' import { Cache, calculateCacheKey, calculateFeedId } from './' import * as cacheMetrics from './metrics' @@ -155,7 +159,11 @@ export class ResponseCache< * @param params - set of parameters that uniquely relate to the response * @param ttl - a new time in milliseconds until the response expires */ - async writeTTL(transportName: string, params: TypeFromDefinition[], ttl: number): Promise { + async writeTTL( + transportName: string, + params: TypeFromDefinition[], + ttl: number, + ): Promise { for (const param of params) { const key = calculateCacheKey({ transportName: transportName, diff --git a/test/cache/response-cache.test.ts b/test/cache/response-cache.test.ts index ef26a78c..bb0ce68f 100644 --- a/test/cache/response-cache.test.ts +++ b/test/cache/response-cache.test.ts @@ -5,7 +5,12 @@ import { Adapter, AdapterEndpoint } from '../../src/adapter' import { AdapterConfig, SettingsDefinitionFromConfig } from '../../src/config' import { AdapterRequest } from '../../src/util' import { TypeFromDefinition } from '../../src/validation/input-params' -import { NopTransport, TestAdapter, assertEqualResponses, runAllUntilTime } from '../../src/util/testing-utils' +import { + NopTransport, + TestAdapter, + assertEqualResponses, + runAllUntilTime, +} from '../../src/util/testing-utils' import { cacheTestInputParameters, CacheTestTransportTypes } from './helper' const test = untypedTest as TestFn<{ @@ -151,7 +156,7 @@ test.serial('updates the response cache ttl', async (t) => { await this.responseCache.writeTTL(this.name, entries, 120_000) } - if (requestCount === 0 ){ + if (requestCount === 0) { await this.responseCache.write(this.name, [ { params: req.requestContext.data, @@ -178,13 +183,11 @@ test.serial('updates the response cache ttl', async (t) => { // First request sets the response in the cache await testAdapter.request({ base: 'BTC', factor: 10 }) // On second request we refresh the cache TTL of a response with factor:10, and set it to 120_000 - await testAdapter.request({base: 'BTC', factor: 11}) + await testAdapter.request({ base: 'BTC', factor: 11 }) // Advancing the clock to make sure that the TTL was updated and we get the response await runAllUntilTime(t.context.clock, 110000) - const response = await testAdapter.request({base: 'BTC', factor: 10}) + const response = await testAdapter.request({ base: 'BTC', factor: 10 }) t.is(response.json().statusCode, 200) t.is(response.json().result, 1234) - }) -