Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
jiqiang90 committed Apr 9, 2024
1 parent 105d4a0 commit bf99a08
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,28 +1,73 @@
// Copyright 2020-2024 SubQuery Pte Ltd authors & contributors
// SPDX-License-Identifier: GPL-3.0

import { NodeConfig } from '@subql/node-core';
import { EventEmitter2 } from '@nestjs/event-emitter';
import { NETWORK_FAMILY } from '@subql/common';
import { DictionaryService, NodeConfig } from '@subql/node-core';
import { MetaData } from '@subql/utils';
import { AlgorandDictionaryV1 } from './algorandDictionaryV1';

describe('dictionary service', () => {
let dictionary: AlgorandDictionaryV1;
const nodeConfig = {
dictionaryTimeout: 10000,
dictionaryRegistry:
'https://github.com/subquery/templates/raw/main/dist/dictionary.json',
} as NodeConfig;
const project = {
network: {
chainId: 'wGHE2Pwdvd7S12BL5FaOP20EGYesN73ktiC1qzkkit8=',
},
} as any;

class TestDictionaryService extends DictionaryService<any, any> {
async initDictionaries(): Promise<void> {
return Promise.resolve(undefined);
}
async getRegistryDictionaries(chainId: string): Promise<string[]> {
return this.resolveDictionary(
NETWORK_FAMILY.algorand,
chainId,
this.nodeConfig.dictionaryRegistry,
);
}
}
describe('dictionary v1', () => {
let dictionary: AlgorandDictionaryV1;
beforeEach(async () => {
const testDictionaryService = new TestDictionaryService(
project.network.chainId,
nodeConfig,
new EventEmitter2(),
);
const dictionaryEndpoints =
await testDictionaryService.getRegistryDictionaries(
project.network.chainId,
);
dictionary = await AlgorandDictionaryV1.create(
{
network: {
chainId: 'wGHE2Pwdvd7S12BL5FaOP20EGYesN73ktiC1qzkkit8=',
dictionary:
'https://api.subquery.network/sq/subquery/Algorand-Dictionary',
dictionary: dictionaryEndpoints[1],
},
} as any,
{ dictionaryTimeout: 10000 } as NodeConfig,
jest.fn(),
'https://api.subquery.network/sq/subquery/Algorand-Dictionary',
dictionaryEndpoints[1], // use endpoint from network
);
});

it('successfully validates metatada', () => {
expect(dictionary.metadataValid).toBeTruthy();
// @ts-ignore
expect(
dictionary.dictionaryValidation(
{
lastProcessedHeight: 10000,
targetHeight: 10000,
chain: 'wGHE2Pwdvd7S12BL5FaOP20EGYesN73ktiC1qzkkit8=',
genesisHash: 'wGHE2Pwdvd7S12BL5FaOP20EGYesN73ktiC1qzkkit8=',
startHeight: 1,
} as MetaData,
1,
),
).toBeTruthy();
});
});
2 changes: 1 addition & 1 deletion packages/node/src/indexer/worker/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const logger = getLogger(`worker #${threadId}`);
async function initWorker(startHeight: number): Promise<void> {
try {
const app = await NestFactory.create(WorkerModule, {
// logger: new NestLogger(!!argv.debug), // TIP: If the worker is crashing comment out this line for better logging
logger: new NestLogger(!!argv.debug), // TIP: If the worker is crashing comment out this line for better logging
});

await app.init();
Expand Down

0 comments on commit bf99a08

Please sign in to comment.