diff --git a/src/dipdup/config/starknet.py b/src/dipdup/config/starknet.py index c8de9573f..67d36ca69 100644 --- a/src/dipdup/config/starknet.py +++ b/src/dipdup/config/starknet.py @@ -4,6 +4,7 @@ from abc import ABC from typing import Annotated from typing import Literal +from typing import TypeAlias from pydantic import AfterValidator from pydantic import ConfigDict @@ -17,7 +18,7 @@ from dipdup.config.starknet_subsquid import StarknetSubsquidDatasourceConfig from dipdup.exceptions import ConfigurationError -StarknetDatasourceConfigU = StarknetSubsquidDatasourceConfig | StarknetNodeDatasourceConfig +StarknetDatasourceConfigU: TypeAlias = StarknetSubsquidDatasourceConfig | StarknetNodeDatasourceConfig _HEX_ADDRESS_REGEXP = re.compile(r'(0x)?[0-9a-f]{1,64}', re.IGNORECASE | re.ASCII) diff --git a/tests/configs/demo_starknet_events.yml b/tests/configs/demo_starknet_events.yml new file mode 100644 index 000000000..e4afe7026 --- /dev/null +++ b/tests/configs/demo_starknet_events.yml @@ -0,0 +1,27 @@ +spec_version: 3.0 +package: demo_starknet_events + +datasources: + subsquid: + kind: starknet.subsquid + url: https://v2.archive.subsquid.io/network/starknet-mainnet + node: + kind: starknet.node + url: https://starknet-mainnet.g.alchemy.com/v2 + +contracts: + stark_usdt: + kind: starknet + address: '0x68f5c6a61780768455de69077e07e89787839bf8166decfbf92b645209c0fb8' + typename: stark_usdt + +indexes: + starknet_usdt_events: + kind: starknet.events + datasources: + - subsquid + - node + handlers: + - callback: on_transfer + contract: stark_usdt + name: Transfer diff --git a/tests/test_config/test_config.py b/tests/test_config/test_config.py index 834ca1189..55a7c2e19 100644 --- a/tests/test_config/test_config.py +++ b/tests/test_config/test_config.py @@ -19,9 +19,16 @@ from dipdup.models.tezos_tzkt import TransactionSubscription from dipdup.yaml import DipDupYAMLConfig +TEST_CONFIGS = Path(__file__).parent.parent / 'configs' + + +@pytest.fixture(params=list(Path.glob(TEST_CONFIGS, 'demo_*.yml'))) +def demo_dipdup_config(request): + yield request.param + def create_config(merge_subs: bool = False, origs: bool = False) -> DipDupConfig: - path = Path(__file__).parent.parent / 'configs' / 'dipdup.yaml' + path = TEST_CONFIGS / 'dipdup.yaml' config = DipDupConfig.load([path]) if origs: config.indexes['hen_mainnet'].types += (TezosOperationType.origination,) # type: ignore @@ -88,12 +95,10 @@ async def test_reserved_keywords() -> None: ) # FIXME: Can't use `from_` field alias in dataclasses - raw_config, _ = DipDupYAMLConfig.load( - paths=[Path(__file__).parent.parent / 'configs' / 'demo_tezos_token_transfers_4.yml'] - ) + raw_config, _ = DipDupYAMLConfig.load(paths=[TEST_CONFIGS / 'demo_tezos_token_transfers_4.yml']) assert raw_config['indexes']['tzbtc_holders_mainnet']['handlers'][1]['from_'] == 'tzbtc_mainnet' - config = DipDupConfig.load([Path(__file__).parent.parent / 'configs' / 'demo_tezos_token_transfers_4.yml']) + config = DipDupConfig.load([TEST_CONFIGS / 'demo_tezos_token_transfers_4.yml']) assert config.indexes['tzbtc_holders_mainnet'].handlers[1].from_ == 'tzbtc_mainnet' # type: ignore[misc,union-attr] @@ -148,5 +153,5 @@ async def test_http_config() -> None: ) -# async def test_evm() -> None: -# DipDupConfig.load([Path(__file__).parent.parent / 'configs' / 'evm_subsquid.yml']) +async def test_load_demo_config(demo_dipdup_config) -> None: + DipDupConfig.load([demo_dipdup_config])