-
Notifications
You must be signed in to change notification settings - Fork 334
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
9 changed files
with
271 additions
and
242 deletions.
There are no files selected for viewing
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
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
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
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 |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// Copyright 2020-2024 SubQuery Pte Ltd authors & contributors | ||
// SPDX-License-Identifier: GPL-3.0 | ||
|
||
import {isCustomDs} from '@subql/common-substrate'; | ||
import { | ||
SubstrateBlockHandler, | ||
SubstrateCallHandler, | ||
SubstrateDatasource, | ||
SubstrateDatasourceKind, | ||
SubstrateEventHandler, | ||
SubstrateHandlerKind, | ||
SubstrateRuntimeHandler, | ||
} from '@subql/types'; | ||
import {BaseCustomDataSource} from '@subql/types-core'; | ||
import {getModulos} from './project'; | ||
|
||
const blockHandler: SubstrateBlockHandler = { | ||
kind: SubstrateHandlerKind.Block, | ||
handler: 'handleBlock', | ||
}; | ||
const callHandler: SubstrateCallHandler = { | ||
kind: SubstrateHandlerKind.Call, | ||
handler: 'handleCall', | ||
filter: {method: 'call', module: 'module'}, | ||
}; | ||
const eventHandler: SubstrateEventHandler = { | ||
kind: SubstrateHandlerKind.Event, | ||
handler: 'handleEvent', | ||
filter: {method: 'event', module: 'module'}, | ||
}; | ||
|
||
const makeDs = (handlers: SubstrateRuntimeHandler[]) => { | ||
return { | ||
name: '', | ||
kind: SubstrateDatasourceKind.Runtime, | ||
mapping: { | ||
file: '', | ||
handlers, | ||
}, | ||
}; | ||
}; | ||
|
||
describe('Project Utils', () => { | ||
it('gets the correct modulos', () => { | ||
const modulos = getModulos<SubstrateDatasource, BaseCustomDataSource>( | ||
[ | ||
makeDs([{...blockHandler, filter: {modulo: 5}}]), | ||
makeDs([callHandler]), | ||
makeDs([eventHandler, {...blockHandler, filter: {modulo: 2}}]), | ||
], | ||
isCustomDs, | ||
SubstrateHandlerKind.Block | ||
); | ||
|
||
expect(modulos).toEqual([5, 2]); | ||
}); | ||
}); |
Oops, something went wrong.