From d924a7287599b1b76bd20e092b54753ffb26df12 Mon Sep 17 00:00:00 2001 From: ironbeer <7997273+ironbeer@users.noreply.github.com> Date: Tue, 28 May 2024 03:21:02 +0900 Subject: [PATCH] Fix test error --- src/repositories/datastore.service.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/repositories/datastore.service.ts b/src/repositories/datastore.service.ts index eb25eb6..dbb81d0 100644 --- a/src/repositories/datastore.service.ts +++ b/src/repositories/datastore.service.ts @@ -5,14 +5,16 @@ import { createHash } from 'crypto'; import { RateLimit } from 'src/config/transactionAllowList'; import { RequestContext } from 'src/entities'; +type DATASTORE = '' | 'redis'; + @Injectable() export class DatastoreService { - private datastore: string; + private datastore: DATASTORE; private redis: Redis; private blockNumberCacheExpire: number; constructor(private configService: ConfigService) { - this.datastore = this.configService.get('datastore') ?? ''; + this.datastore = this.configService.get('datastore') ?? ''; if (this.datastore === 'redis' && process.env.REDIS_URI) { this.redis = new Redis(process.env.REDIS_URI); } @@ -31,7 +33,9 @@ export class DatastoreService { // for testing close() { - this.redis.disconnect(); + if (this.datastore === 'redis') { + this.redis.disconnect(); + } } async setTransactionHistory(