-
-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cleanup tuple type extraction, tiny test
- Loading branch information
1 parent
1959e2d
commit e095c16
Showing
4 changed files
with
43 additions
and
11 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,36 @@ | ||
from dipdup.config.substrate_node import SubstrateNodeDatasourceConfig | ||
from dipdup.datasources.substrate_node import SubstrateNodeDatasource | ||
from dipdup.runtimes import extract_tuple_inner_types | ||
from dipdup.runtimes import get_type_registry | ||
|
||
|
||
def get_dummy_node() -> 'SubstrateNodeDatasource': | ||
config = SubstrateNodeDatasourceConfig( | ||
kind='substrate.node', | ||
url='https://polkadot-asset-hub-rpc.polkadot.io', | ||
) | ||
config._name = 'test' | ||
return SubstrateNodeDatasource(config) | ||
|
||
|
||
async def test_extract_tuple_inner_types() -> None: | ||
datasource = get_dummy_node() | ||
|
||
runtime_config = datasource._interface.runtime_config | ||
runtime_config.update_type_registry(get_type_registry('legacy')) | ||
runtime_config.update_type_registry(get_type_registry('statemint')) | ||
|
||
types = ( | ||
# 'Tuple:staging_xcm:v4:location:Locationstaging_xcm:v4:location:Location', | ||
'Tuple:staging_xcm:v3:multilocation:MultiLocationstaging_xcm:v3:multilocation:MultiLocation', | ||
'Tuple:U128U8U128', | ||
) | ||
expected_inner_types = ( | ||
# ['location', 'location'], | ||
['multilocation', 'multilocation'], | ||
['u128', 'u8', 'u128'], | ||
) | ||
|
||
for type_, expected_types in zip(types, expected_inner_types, strict=True): | ||
result = extract_tuple_inner_types(type_, datasource._interface.runtime_config.type_registry) | ||
assert result == expected_types |