-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
53 additions
and
8 deletions.
There are no files selected for viewing
59 changes: 52 additions & 7 deletions
59
packages/node/src/indexer/dictionary/v1/algorandDictionaryV1.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters