Skip to content

Commit

Permalink
Fix test error
Browse files Browse the repository at this point in the history
  • Loading branch information
ironbeer committed May 27, 2024
1 parent 48ddb37 commit d924a72
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/repositories/datastore.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string>('datastore') ?? '';
this.datastore = this.configService.get<DATASTORE>('datastore') ?? '';
if (this.datastore === 'redis' && process.env.REDIS_URI) {
this.redis = new Redis(process.env.REDIS_URI);
}
Expand All @@ -31,7 +33,9 @@ export class DatastoreService {

// for testing
close() {
this.redis.disconnect();
if (this.datastore === 'redis') {
this.redis.disconnect();
}
}

async setTransactionHistory(
Expand Down

0 comments on commit d924a72

Please sign in to comment.