diff --git a/.github/workflows/deploypypi.yml b/.github/workflows/deploypypi.yml index cc15951b..62b6c87d 100644 --- a/.github/workflows/deploypypi.yml +++ b/.github/workflows/deploypypi.yml @@ -4,32 +4,50 @@ on: release: types: [created] +permissions: + contents: read + jobs: - deploy: + check: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - name: Set up Python - uses: actions/setup-python@v1 + - name: Checkout code + uses: actions/checkout@v4 + with: + persist-credentials: false + - name: Set up Python 3.12 + uses: actions/setup-python@v5 with: python-version: '3.12' - - name: Install project dependencies + + - name: Lint and format code with pre-commit + uses: pre-commit/action@v3.0.1 + + - name: Install dependencies run: | python -m pip install --upgrade pip - pip install -r requirements.txt - - name: Lint with flake8 - run: | - pip install flake8 - # stop the build if there are Python syntax errors or undefined names - flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics - # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide - flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + pip install -e . + pip install -r requirements-test.txt - name: Test with pytest run: | - pip install pytest pytest + + publish: + runs-on: ubuntu-latest + needs: [check] + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + persist-credentials: false + - name: Set up Python 3.12 + uses: actions/setup-python@v5 + with: + python-version: '3.12' + - name: Install deploy dependencies run: | + python -m pip install --upgrade pip pip install setuptools wheel twine - name: Build and publish env: @@ -37,4 +55,42 @@ jobs: TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} run: | python setup.py sdist bdist_wheel - twine upload dist/* + twine upload dist/* --verbose + + check-released: + runs-on: ubuntu-latest + needs: [publish] + timeout-minutes: 10 + steps: + - name: Set up Python 3.12 + uses: actions/setup-python@v5 + with: + python-version: '3.12' + + - name: Install and import the uploaded package + run: | + python -m pip install --upgrade pip + set +e + while true; do + log=$( + 2>&1 python -m pip install \ + "substrate-interface==${GITHUB_REF#refs/tags/v}" + ) + status=$? + if [ "$status" = 0 ]; then + echo "Installed successfully." + break + elif grep -q 'Could not find a version' <<<"$log"; then + echo "Waiting for release to propagate to the index..." + sleep 5 + else + echo '::error::Unexpected output from "pip install", release seems to have failed.' + cat <<<"$log" + exit 1 + fi + done + + if ! python -c 'import substrateinterface'; then + echo '::error::Unable to import the installed package!' + exit 2 + fi diff --git a/.github/workflows/unittests.yml b/.github/workflows/unittests.yml index f21cfa33..ec6225fc 100644 --- a/.github/workflows/unittests.yml +++ b/.github/workflows/unittests.yml @@ -9,33 +9,64 @@ on: schedule: - cron: '0 7 * * *' -jobs: - build: +permissions: + contents: read +jobs: + lint: runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + persist-credentials: false + - name: Set up Python 3.13 + uses: actions/setup-python@v5 + with: + python-version: '3.13' + - name: Lint and format code with pre-commit + uses: pre-commit/action@v3.0.1 + with: + extra_args: --all-files -v + + test: + runs-on: ${{ matrix.python-version == '3.7' && 'ubuntu-22.04' || 'ubuntu-latest' }} strategy: matrix: - python-version: [3.12] + python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12', '3.13'] + fail-fast: false steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v4 + with: + persist-credentials: false - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v1 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Install dependencies run: | python -m pip install --upgrade pip - pip install -r requirements.txt - - name: Lint with flake8 - run: | - pip install flake8 - # stop the build if there are Python syntax errors or undefined names - flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics - # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide - flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + CI_COMMIT_TAG="v0.0.1+$(git rev-parse HEAD)" pip install -e . + pip install -r requirements-test.txt - name: Test with pytest run: | - pip install pytest pytest + + check-docs: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + persist-credentials: false + - name: Set up Python 3.13 + uses: actions/setup-python@v5 + with: + python-version: '3.13' + - name: Check documentation build + run: | + pip install -r requirements-docs.txt + # TODO: Enable when documentation is fixed + mkdocs build # --strict diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..1b40e687 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,22 @@ +# This is only a stub, other hooks will land later + +repos: + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.12.3 + hooks: + # Disabled until next PR + # - id: ruff-format + - id: ruff-check + args: [--fix] + + - repo: https://github.com/python-jsonschema/check-jsonschema + rev: 0.33.2 + hooks: + - id: check-github-workflows + + - repo: https://github.com/rhysd/actionlint + rev: v1.7.7 + hooks: + - id: actionlint + additional_dependencies: + - github.com/wasilibs/go-shellcheck/cmd/shellcheck@v0.10.0 diff --git a/docs/index.md b/docs/index.md index 42befb1f..b25d7139 100644 --- a/docs/index.md +++ b/docs/index.md @@ -20,7 +20,7 @@ Overview of available [extensions](/extensions/); adding or improving existing f ## Metadata docs [Documentation of Substrate metadata](https://polkascan.github.io/py-substrate-metadata-docs/) for well known runtimes and how to use it with py-substrate-interface. -## Contact and Support +## Contact and Support For questions, please see the [Substrate StackExchange](https://substrate.stackexchange.com/questions/tagged/python), [Github Discussions](https://github.com/polkascan/py-substrate-interface/discussions) or reach out to us on our [matrix](http://matrix.org) chat group: [Polkascan Technical](https://matrix.to/#/#polkascan:matrix.org). diff --git a/examples/.ruff.toml b/examples/.ruff.toml new file mode 100644 index 00000000..f68a04b9 --- /dev/null +++ b/examples/.ruff.toml @@ -0,0 +1,3 @@ +# Prefer human-readable line length and non-eol python for examples +target-version = "py39" +line-length = 88 diff --git a/examples/extensions.py b/examples/extensions.py index 8a7f83d8..ff0802e8 100644 --- a/examples/extensions.py +++ b/examples/extensions.py @@ -1,4 +1,4 @@ -from datetime import datetime, timedelta +from datetime import datetime from substrateinterface import SubstrateInterface from substrateinterface.extensions import SubstrateNodeExtension diff --git a/mkdocs.yml b/mkdocs.yml index 35620113..c782d563 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -95,3 +95,7 @@ markdown_extensions: - pymdownx.snippets - pymdownx.superfences +watch: + - docs + - substrateinterface + - mkdocs.yml \ No newline at end of file diff --git a/requirements-docs.txt b/requirements-docs.txt new file mode 100644 index 00000000..a6f8d578 --- /dev/null +++ b/requirements-docs.txt @@ -0,0 +1,5 @@ +mkdocs +mkdocs-material +mkdocs-autorefs +mkdocstrings +mkdocstrings[python] diff --git a/requirements-test.txt b/requirements-test.txt new file mode 100644 index 00000000..b75a42e7 --- /dev/null +++ b/requirements-test.txt @@ -0,0 +1 @@ +pytest>=4.4.0 diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index ba6d35a1..00000000 --- a/requirements.txt +++ /dev/null @@ -1,23 +0,0 @@ -websocket-client>=0.57.0,<2 -base58>=1.0.3,<3 -certifi>=2019.3.9 -idna>=2.1.0,<4 -requests>=2.21.0,<3 -xxhash>=1.3.0,<4 -pytest>=4.4.0 -ecdsa>=0.17.0,<1 -eth-keys>=0.2.1,<1 -eth_utils>=1.3.0,<6 -pycryptodome>=3.11.0,<4 -PyNaCl>=1.0.1,<2 - -scalecodec>=1.2.10,<1.3 -py-sr25519-bindings>=0.2.0,<1 -py-ed25519-zebra-bindings>=1.0,<2 -py-bip39-bindings>=0.1.9,<1 - -mkdocs -mkdocs-material -mkdocs-autorefs -mkdocstrings -mkdocstrings[python] diff --git a/ruff.toml b/ruff.toml new file mode 100644 index 00000000..e71f3e50 --- /dev/null +++ b/ruff.toml @@ -0,0 +1,21 @@ +target-version = "py37" +line-length = 127 + +[analyze] +detect-string-imports = true + +[format] +docstring-code-format = true + +[lint] +# Minimal for now; more rules are needed +select = ["E", "F"] + +[lint.per-file-ignores] +"test/fixtures.py" = [ + # Giant blobs + "E501" +] +"**/__init__.py" = [ + "F403", # Allow star imports for reexport +] \ No newline at end of file diff --git a/setup.py b/setup.py index 4b2eef9b..ec0b7d08 100644 --- a/setup.py +++ b/setup.py @@ -30,6 +30,9 @@ # Python 3 only projects can skip this import from io import open +# FIXME: this should never be used, version shouldn't be resolved at runtime, +# it has to be shipped with the package. When this is gone, remove workaround +# from unittests.yml workflow. if environ.get('TRAVIS_TAG'): version = environ['TRAVIS_TAG'].replace('v', '') elif environ.get('CI_COMMIT_TAG'): diff --git a/substrateinterface/__init__.py b/substrateinterface/__init__.py index 9d8717e8..da988b91 100644 --- a/substrateinterface/__init__.py +++ b/substrateinterface/__init__.py @@ -14,6 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +from . import base, contracts, keypair, interfaces, extensions from .base import * from .contracts import * from .keypair import * diff --git a/substrateinterface/base.py b/substrateinterface/base.py index ae4d497c..a4764a92 100644 --- a/substrateinterface/base.py +++ b/substrateinterface/base.py @@ -24,12 +24,12 @@ import logging import requests -from typing import Optional, Union, List +from typing import Any, Dict, Optional, Union, List -from websocket import create_connection, WebSocketConnectionClosedException +from websocket import WebSocket, create_connection, WebSocketConnectionClosedException from scalecodec.base import ScaleBytes, RuntimeConfigurationObject, ScaleType -from scalecodec.types import GenericCall, GenericExtrinsic, Extrinsic, MultiAccountId, GenericRuntimeCallDefinition +from scalecodec.types import GenericCall, GenericExtrinsic, MultiAccountId, GenericRuntimeCallDefinition from scalecodec.type_registry import load_type_registry_preset from scalecodec.updater import update_type_registries from .extensions import Extension @@ -39,9 +39,9 @@ from .exceptions import SubstrateRequestException, ConfigurationError, StorageFunctionNotFound, BlockNotFound, \ ExtrinsicNotFound, ExtensionCallNotFound -from .constants import * -from .keypair import Keypair, KeypairType, MnemonicLanguageCode -from .utils.ss58 import ss58_decode, ss58_encode, is_valid_ss58_address, get_ss58_format +from .constants import WELL_KNOWN_STORAGE_KEYS +from .keypair import Keypair +from .utils.ss58 import ss58_decode, ss58_encode, is_valid_ss58_address __all__ = ['SubstrateInterface', 'ExtrinsicReceipt', 'logger'] @@ -67,22 +67,54 @@ def remove(): class SubstrateInterface: - def __init__(self, url=None, websocket=None, ss58_format=None, type_registry=None, type_registry_preset=None, - cache_region=None, runtime_config=None, use_remote_preset=False, ws_options=None, - auto_discover=True, auto_reconnect=True, config=None): + def __init__( + self, + url: Optional[str] = None, + websocket: Optional[WebSocket] = None, + ss58_format: Optional[int] = None, + type_registry: Optional[Dict[str, Any]] = None, + type_registry_preset: Optional[str] = None, + cache_region: Optional[Any] = None, + runtime_config: Optional[RuntimeConfigurationObject] = None, + use_remote_preset: bool = False, + ws_options: Optional[Dict[str, Any]] = None, + auto_discover: bool = True, + auto_reconnect: bool = True, + config: Optional[Dict[str, Any]] = None, + ) -> None: """ A specialized class in interfacing with a Substrate node. Parameters ---------- - url: the URL to the substrate node, either in format https://127.0.0.1:9933 or wss://127.0.0.1:9944 - ss58_format: The address type which account IDs will be SS58-encoded to Substrate addresses. Defaults to 42, for Kusama the address type is 2 - type_registry: A dict containing the custom type registry in format: {'types': {'customType': 'u32'},..} - type_registry_preset: The name of the predefined type registry shipped with the SCALE-codec, e.g. kusama - cache_region: a Dogpile cache region as a central store for the metadata cache - use_remote_preset: When True preset is downloaded from GitHub master, otherwise use files from local installed scalecodec package - ws_options: dict of options to pass to the websocket-client create_connection function - config: dict of config flags to overwrite default configuration + url: + The URL to the substrate node, either in format `https://127.0.0.1:9933` + or `wss://127.0.0.1:9944`. Conflicts with `websocket`. + websocket: + An already initialized `websockets.WebSocket`. Conflicts with `url`. + ss58_format: + The address type which account IDs will be SS58-encoded to Substrate addresses. + Defaults to `42`, for Kusama the address type is `2` + type_registry: + A dict containing the custom type registry in format: + `{'types': {'customType': 'u32'},..}` + type_registry_preset: + The name of the predefined type registry shipped with the SCALE-codec, e.g. kusama + cache_region: + A Dogpile cache region as a central store for the metadata cache + use_remote_preset: + When True, download preset from GitHub master, otherwise use files from + locally installed scalecodec package + runtime_config: + Runtime configuration to use. + ws_options: + A dict of options to pass to the websocket-client create_connection function + auto_discover: + Whether to guess the preset by chain name. + auto_reconnect: + Whether to reestablish the websocket connection on failure automatically. + config: + A dict of config flags to overwrite default configuration """ if (not url and not websocket) or (url and websocket): @@ -170,13 +202,9 @@ def __init__(self, url=None, websocket=None, ss58_format=None, type_registry=Non self.reload_type_registry(use_remote_preset=use_remote_preset, auto_discover=auto_discover) - def connect_websocket(self): + def connect_websocket(self) -> None: """ - (Re)creates the websocket connection, if the URL contains a 'ws' or 'wss' scheme - - Returns - ------- - + (Re)create the websocket connection, if the URL contains a 'ws' or 'wss' scheme. """ if self.url and (self.url[0:6] == 'wss://' or self.url[0:5] == 'ws://'): self.debug_message("Connecting to {} ...".format(self.url)) @@ -187,11 +215,7 @@ def connect_websocket(self): def close(self): """ - Cleans up resources for this instance like active websocket connection and active extensions - - Returns - ------- - + Clean up resources for this instance like active websocket connection and active extensions. """ if self.websocket: self.debug_message("Closing websocket connection") @@ -206,17 +230,14 @@ def __exit__(self, exc_type, exc_val, exc_tb): self.close() @staticmethod - def debug_message(message: str): + def debug_message(message: str) -> None: """ Submits a message to the debug logger Parameters ---------- - message: str Debug message - - Returns - ------- - + message: + Debug message """ logger.debug(message) @@ -1385,10 +1406,15 @@ def compose_call( Parameters ---------- - call_module: Name of the runtime module e.g. Balances - call_function: Name of the call function e.g. transfer - call_params: This is a dict containing the params of the call. e.g. `{'dest': 'EaG2CRhJWPb7qmdcJvy3LiWdh26Jreu9Dx6R1rXxPmYXoDk', 'value': 1000000000000}` - block_hash: Use metadata at given block_hash to compose call + call_module: + Name of the runtime module e.g. Balances + call_function: + Name of the call function e.g. transfer + call_params: + This is a dict containing the params of the call. e.g. + `{'dest': 'EaG2CRhJWPb7qmdcJvy3LiWdh26Jreu9Dx6R1rXxPmYXoDk', 'value': 1000000000000}` + block_hash: + Use metadata at given block_hash to compose call Returns ------- @@ -2343,7 +2369,7 @@ def decode_block(block_data, block_data_hash=None): extrinsic_decoder.decode(check_remaining=self.config.get('strict_scale_decode')) block_data['extrinsics'][idx] = extrinsic_decoder - except Exception as e: + except Exception: if not ignore_decoding_errors: raise block_data['extrinsics'][idx] = None @@ -2684,7 +2710,7 @@ def decode_scale(self, type_string, scale_bytes, block_hash=None, return_scale_o """ self.init_runtime(block_hash=block_hash) - if type(scale_bytes) == str: + if type(scale_bytes) == str: # noqa: E721 scale_bytes = ScaleBytes(scale_bytes) obj = self.runtime_config.create_scale_object( @@ -2952,19 +2978,17 @@ def update_type_registry_presets(self) -> bool: except Exception: return False - def reload_type_registry(self, use_remote_preset: bool = True, auto_discover: bool = True): + def reload_type_registry(self, use_remote_preset: bool = True, auto_discover: bool = True) -> None: """ Reload type registry and preset used to instantiate the SubtrateInterface object. Useful to periodically apply changes in type definitions when a runtime upgrade occurred Parameters ---------- - use_remote_preset: When True preset is downloaded from Github master, otherwise use files from local installed scalecodec package + use_remote_preset: + When True, download the preset from Github master, otherwise use files + from locally installed scalecodec package auto_discover - - Returns - ------- - """ self.runtime_config.clear_type_registry() @@ -3030,7 +3054,7 @@ def register_extension(self, extension: Extension): class ExtrinsicReceipt: """ Object containing information of submitted extrinsic. Block hash where extrinsic is included is required - when retrieving triggered events or determine if extrinsic was succesfull + when retrieving triggered events or determine if extrinsic was successful """ def __init__(self, substrate: SubstrateInterface, extrinsic_hash: str = None, block_hash: str = None, diff --git a/substrateinterface/contracts.py b/substrateinterface/contracts.py index 2ca1ab9e..824d787b 100644 --- a/substrateinterface/contracts.py +++ b/substrateinterface/contracts.py @@ -464,8 +464,12 @@ def __init__(self, *args, **kwargs): super(ContractExecutionReceipt, self).__init__(*args, **kwargs) @classmethod - def create_from_extrinsic_receipt(cls, receipt: ExtrinsicReceipt, - contract_metadata: ContractMetadata, contract_address: str = None) -> "ContractExecutionReceipt": + def create_from_extrinsic_receipt( + cls, + receipt: ExtrinsicReceipt, + contract_metadata: ContractMetadata, + contract_address: str = None, + ) -> "ContractExecutionReceipt": """ Promotes a ExtrinsicReceipt object to a ContractExecutionReceipt. It uses the provided ContractMetadata to decode "ContractExecution" events @@ -498,7 +502,9 @@ def process_events(self): for event in self.triggered_events: if self.substrate.implements_scaleinfo(): - if event.value['module_id'] == 'Contracts' and event.value['event_id'] == 'ContractEmitted' and event.value['attributes']['contract'] == self.contract_address: + if (event.value['module_id'] == 'Contracts' + and event.value['event_id'] == 'ContractEmitted' + and event.value['attributes']['contract'] == self.contract_address): contract_data = event['event'][1][1]['data'].value_object @@ -658,13 +664,22 @@ def deploy(self, keypair: Keypair, constructor: str, args: dict = None, value: i Parameters ---------- keypair - constructor: name of the constructor to use, provided in the metadata - args: arguments for the constructor - value: Value sent to created contract address - gas_limit: Gas limit as WeightV2 type. Will default to {'ref_time': 25990000000, 'proof_size': 11990383647911208550}. - deployment_salt: optional string or hex-string that acts as a salt for this deployment - upload_code: When True the WASM blob itself will be uploaded with the deploy, False if the WASM is already present on-chain - storage_deposit_limit: The maximum amount of balance that can be charged to pay for the storage consumed. + constructor: + Name of the constructor to use, provided in the metadata + args: + Arguments for the constructor + value: + Value sent to created contract address + gas_limit: + Gas limit as `WeightV2` type. Will default to + `{'ref_time': 25990000000, 'proof_size': 11990383647911208550}` + deployment_salt: + optional string or hex-string that acts as a salt for this deployment + upload_code: + When True the WASM blob itself will be uploaded with the deploy, + False if the WASM is already present on-chain + storage_deposit_limit: + The maximum amount of balance that can be charged to pay for the storage consumed. Returns ------- diff --git a/substrateinterface/keypair.py b/substrateinterface/keypair.py index e5ada598..20550c7a 100644 --- a/substrateinterface/keypair.py +++ b/substrateinterface/keypair.py @@ -157,8 +157,11 @@ def generate_mnemonic(cls, words: int = 12, language_code: str = MnemonicLanguag Parameters ---------- - words: The amount of words to generate, valid values are 12, 15, 18, 21 and 24 - language_code: The language to use, valid values are: 'en', 'zh-hans', 'zh-hant', 'fr', 'it', 'ja', 'ko', 'es'. Defaults to `MnemonicLanguageCode.ENGLISH` + words: + The amount of words to generate, valid values are 12, 15, 18, 21 and 24 + language_code: + The language to use, valid values are: 'en', 'zh-hans', 'zh-hant', 'fr', 'it', 'ja', 'ko', 'es'. + Defaults to `MnemonicLanguageCode.ENGLISH` Returns ------- @@ -173,8 +176,11 @@ def validate_mnemonic(cls, mnemonic: str, language_code: str = MnemonicLanguageC Parameters ---------- - mnemonic: Seed phrase - language_code: The language to use, valid values are: 'en', 'zh-hans', 'zh-hant', 'fr', 'it', 'ja', 'ko', 'es'. Defaults to `MnemonicLanguageCode.ENGLISH` + mnemonic: + Seed phrase + language_code: + The language to use, valid values are: 'en', 'zh-hans', 'zh-hant', 'fr', 'it', 'ja', 'ko', 'es'. + Defaults to `MnemonicLanguageCode.ENGLISH` Returns ------- @@ -190,10 +196,15 @@ def create_from_mnemonic(cls, mnemonic: str, ss58_format=42, crypto_type=Keypair Parameters ---------- - mnemonic: Seed phrase - ss58_format: Substrate address format - crypto_type: Use `KeypairType.SR25519` or `KeypairType.ED25519` cryptography for generating the Keypair - language_code: The language to use, valid values are: 'en', 'zh-hans', 'zh-hant', 'fr', 'it', 'ja', 'ko', 'es'. Defaults to `MnemonicLanguageCode.ENGLISH` + mnemonic: + Seed phrase + ss58_format: + Substrate address format + crypto_type: + Use `KeypairType.SR25519` or `KeypairType.ED25519` cryptography for generating the Keypair + language_code: + The language to use, valid values are: 'en', 'zh-hans', 'zh-hant', 'fr', 'it', 'ja', 'ko', 'es'. + Defaults to `MnemonicLanguageCode.ENGLISH` Returns ------- @@ -257,7 +268,8 @@ def create_from_seed( @classmethod def create_from_uri( - cls, suri: str, ss58_format: Optional[int] = 42, crypto_type=KeypairType.SR25519, language_code: str = MnemonicLanguageCode.ENGLISH + cls, suri: str, ss58_format: Optional[int] = 42, + crypto_type=KeypairType.SR25519, language_code: str = MnemonicLanguageCode.ENGLISH ) -> 'Keypair': """ Creates Keypair for specified suri in following format: `[mnemonic]/[soft-path]//[hard-path]` @@ -265,9 +277,14 @@ def create_from_uri( Parameters ---------- suri: - ss58_format: Substrate address format - crypto_type: Use KeypairType.SR25519 or KeypairType.ED25519 cryptography for generating the Keypair - language_code: The language to use, valid values are: 'en', 'zh-hans', 'zh-hant', 'fr', 'it', 'ja', 'ko', 'es'. Defaults to `MnemonicLanguageCode.ENGLISH` + Substrate URI to parse + ss58_format: + Substrate address format + crypto_type: + Use KeypairType.SR25519 or KeypairType.ED25519 cryptography for generating the Keypair + language_code: + The language to use, valid values are: 'en', 'zh-hans', 'zh-hant', 'fr', 'it', 'ja', 'ko', 'es'. + Defaults to `MnemonicLanguageCode.ENGLISH` Returns ------- diff --git a/test/fixtures.py b/test/fixtures.py index 3a38e825..d65cae91 100644 --- a/test/fixtures.py +++ b/test/fixtures.py @@ -21,3 +21,119 @@ metadata_node_template_hex = "0x6d6574610c241853797374656d011853797374656d401c4163636f756e7401010230543a3a4163636f756e744964944163636f756e74496e666f3c543a3a496e6465782c20543a3a4163636f756e74446174613e00210100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004e8205468652066756c6c206163636f756e7420696e666f726d6174696f6e20666f72206120706172746963756c6172206163636f756e742049442e3845787472696e736963436f756e7400000c753332040004b820546f74616c2065787472696e7369637320636f756e7420666f72207468652063757272656e7420626c6f636b2e2c426c6f636b576569676874010064776569676874733a3a45787472696e7369637357656967687440000000000000000000000000000000000488205468652063757272656e742077656967687420666f722074686520626c6f636b2e40416c6c45787472696e736963734c656e00000c753332040004410120546f74616c206c656e6774682028696e2062797465732920666f7220616c6c2065787472696e736963732070757420746f6765746865722c20666f72207468652063757272656e7420626c6f636b2e24426c6f636b4861736801010538543a3a426c6f636b4e756d6265721c543a3a48617368008000000000000000000000000000000000000000000000000000000000000000000498204d6170206f6620626c6f636b206e756d6265727320746f20626c6f636b206861736865732e3445787472696e736963446174610101050c7533321c5665633c75383e000400043d012045787472696e73696373206461746120666f72207468652063757272656e7420626c6f636b20286d61707320616e2065787472696e736963277320696e64657820746f206974732064617461292e184e756d626572010038543a3a426c6f636b4e756d6265721000000000040901205468652063757272656e7420626c6f636b206e756d626572206265696e672070726f6365737365642e205365742062792060657865637574655f626c6f636b602e28506172656e744861736801001c543a3a4861736880000000000000000000000000000000000000000000000000000000000000000004702048617368206f66207468652070726576696f757320626c6f636b2e3845787472696e73696373526f6f7401001c543a3a486173688000000000000000000000000000000000000000000000000000000000000000000415012045787472696e7369637320726f6f74206f66207468652063757272656e7420626c6f636b2c20616c736f2070617274206f662074686520626c6f636b206865616465722e1844696765737401002c4469676573744f663c543e040004f020446967657374206f66207468652063757272656e7420626c6f636b2c20616c736f2070617274206f662074686520626c6f636b206865616465722e184576656e747301008c5665633c4576656e745265636f72643c543a3a4576656e742c20543a3a486173683e3e040004a0204576656e7473206465706f736974656420666f72207468652063757272656e7420626c6f636b2e284576656e74436f756e740100284576656e74496e646578100000000004b820546865206e756d626572206f66206576656e747320696e2074686520604576656e74733c543e60206c6973742e2c4576656e74546f706963730101021c543a3a48617368845665633c28543a3a426c6f636b4e756d6265722c204576656e74496e646578293e000400282501204d617070696e67206265747765656e206120746f7069632028726570726573656e74656420627920543a3a486173682920616e64206120766563746f72206f6620696e646578657394206f66206576656e747320696e2074686520603c4576656e74733c543e3e60206c6973742e00510120416c6c20746f70696320766563746f727320686176652064657465726d696e69737469632073746f72616765206c6f636174696f6e7320646570656e64696e67206f6e2074686520746f7069632e2054686973450120616c6c6f7773206c696768742d636c69656e747320746f206c6576657261676520746865206368616e67657320747269652073746f7261676520747261636b696e67206d656368616e69736d20616e64e420696e2063617365206f66206368616e67657320666574636820746865206c697374206f66206576656e7473206f6620696e7465726573742e004d01205468652076616c756520686173207468652074797065206028543a3a426c6f636b4e756d6265722c204576656e74496e646578296020626563617573652069662077652075736564206f6e6c79206a7573744d012074686520604576656e74496e64657860207468656e20696e20636173652069662074686520746f70696320686173207468652073616d6520636f6e74656e7473206f6e20746865206e65787420626c6f636b0101206e6f206e6f74696669636174696f6e2077696c6c20626520747269676765726564207468757320746865206576656e74206d69676874206265206c6f73742e484c61737452756e74696d65557067726164650000584c61737452756e74696d6555706772616465496e666f04000455012053746f726573207468652060737065635f76657273696f6e6020616e642060737065635f6e616d6560206f66207768656e20746865206c6173742072756e74696d6520757067726164652068617070656e65642e545570677261646564546f553332526566436f756e74010010626f6f6c0400044d012054727565206966207765206861766520757067726164656420736f207468617420607479706520526566436f756e74602069732060753332602e2046616c7365202864656661756c7429206966206e6f742e38457865637574696f6e50686173650000145068617365040004882054686520657865637574696f6e207068617365206f662074686520626c6f636b2e01282866696c6c5f626c6f636b04185f726174696f1c50657262696c6c040901204120646973706174636820746861742077696c6c2066696c6c2074686520626c6f636b2077656967687420757020746f2074686520676976656e20726174696f2e1872656d61726b041c5f72656d61726b1c5665633c75383e1c6c204d616b6520736f6d65206f6e2d636861696e2072656d61726b2e002c2023203c7765696768743e24202d20604f28312960e0202d2042617365205765696768743a20302e36363520c2b5732c20696e646570656e64656e74206f662072656d61726b206c656e6774682e50202d204e6f204442206f7065726174696f6e732e302023203c2f7765696768743e387365745f686561705f7061676573041470616765730c75363420fc2053657420746865206e756d626572206f6620706167657320696e2074686520576562417373656d626c7920656e7669726f6e6d656e74277320686561702e002c2023203c7765696768743e24202d20604f283129604c202d20312073746f726167652077726974652e64202d2042617365205765696768743a20312e34303520c2b57360202d203120777269746520746f20484541505f5041474553302023203c2f7765696768743e207365745f636f64650410636f64651c5665633c75383e28682053657420746865206e65772072756e74696d6520636f64652e002c2023203c7765696768743e3501202d20604f2843202b2053296020776865726520604360206c656e677468206f662060636f64656020616e642060536020636f6d706c6578697479206f66206063616e5f7365745f636f64656088202d20312073746f726167652077726974652028636f64656320604f28432960292e7901202d20312063616c6c20746f206063616e5f7365745f636f6465603a20604f28532960202863616c6c73206073705f696f3a3a6d6973633a3a72756e74696d655f76657273696f6e6020776869636820697320657870656e73697665292e2c202d2031206576656e742e7d012054686520776569676874206f6620746869732066756e6374696f6e20697320646570656e64656e74206f6e207468652072756e74696d652c206275742067656e6572616c6c792074686973206973207665727920657870656e736976652e902057652077696c6c207472656174207468697320617320612066756c6c20626c6f636b2e302023203c2f7765696768743e5c7365745f636f64655f776974686f75745f636865636b730410636f64651c5665633c75383e201d012053657420746865206e65772072756e74696d6520636f646520776974686f757420646f696e6720616e7920636865636b73206f662074686520676976656e2060636f6465602e002c2023203c7765696768743e90202d20604f2843296020776865726520604360206c656e677468206f662060636f64656088202d20312073746f726167652077726974652028636f64656320604f28432960292e2c202d2031206576656e742e75012054686520776569676874206f6620746869732066756e6374696f6e20697320646570656e64656e74206f6e207468652072756e74696d652e2057652077696c6c207472656174207468697320617320612066756c6c20626c6f636b2e302023203c2f7765696768743e5c7365745f6368616e6765735f747269655f636f6e666967044c6368616e6765735f747269655f636f6e666967804f7074696f6e3c4368616e67657354726965436f6e66696775726174696f6e3e28a02053657420746865206e6577206368616e676573207472696520636f6e66696775726174696f6e2e002c2023203c7765696768743e24202d20604f28312960b0202d20312073746f72616765207772697465206f722064656c6574652028636f64656320604f28312960292ed8202d20312063616c6c20746f20606465706f7369745f6c6f67603a20557365732060617070656e6460204150492c20736f204f28312964202d2042617365205765696768743a20372e32313820c2b57334202d204442205765696768743aa820202020202d205772697465733a204368616e67657320547269652c2053797374656d20446967657374302023203c2f7765696768743e2c7365745f73746f7261676504146974656d73345665633c4b657956616c75653e206c2053657420736f6d65206974656d73206f662073746f726167652e002c2023203c7765696768743e94202d20604f2849296020776865726520604960206c656e677468206f6620606974656d73607c202d206049602073746f72616765207772697465732028604f28312960292e74202d2042617365205765696768743a20302e353638202a206920c2b57368202d205772697465733a204e756d626572206f66206974656d73302023203c2f7765696768743e306b696c6c5f73746f7261676504106b657973205665633c4b65793e2078204b696c6c20736f6d65206974656d732066726f6d2073746f726167652e002c2023203c7765696768743efc202d20604f28494b296020776865726520604960206c656e677468206f6620606b6579736020616e6420604b60206c656e677468206f66206f6e65206b657964202d206049602073746f726167652064656c6574696f6e732e70202d2042617365205765696768743a202e333738202a206920c2b57368202d205772697465733a204e756d626572206f66206974656d73302023203c2f7765696768743e2c6b696c6c5f70726566697808187072656669780c4b6579205f7375626b6579730c7533322c1501204b696c6c20616c6c2073746f72616765206974656d7320776974682061206b657920746861742073746172747320776974682074686520676976656e207072656669782e003d01202a2a4e4f54453a2a2a2057652072656c79206f6e2074686520526f6f74206f726967696e20746f2070726f7669646520757320746865206e756d626572206f66207375626b65797320756e64657241012074686520707265666978207765206172652072656d6f76696e6720746f2061636375726174656c792063616c63756c6174652074686520776569676874206f6620746869732066756e6374696f6e2e002c2023203c7765696768743edc202d20604f285029602077686572652060506020616d6f756e74206f66206b65797320776974682070726566697820607072656669786064202d206050602073746f726167652064656c6574696f6e732e74202d2042617365205765696768743a20302e383334202a205020c2b57380202d205772697465733a204e756d626572206f66207375626b657973202b2031302023203c2f7765696768743e1c7375696369646500286501204b696c6c207468652073656e64696e67206163636f756e742c20617373756d696e6720746865726520617265206e6f207265666572656e636573206f75747374616e64696e6720616e642074686520636f6d706f7369746590206461746120697320657175616c20746f206974732064656661756c742076616c75652e002c2023203c7765696768743e24202d20604f283129607c202d20312073746f72616765207265616420616e642064656c6574696f6e2e54202d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d5c2042617365205765696768743a20382e36323620c2b5731101204e6f2044422052656164206f72205772697465206f7065726174696f6e7320626563617573652063616c6c657220697320616c726561647920696e206f7665726c6179302023203c2f7765696768743e01144045787472696e7369635375636365737304304469737061746368496e666f04b820416e2065787472696e73696320636f6d706c65746564207375636365737366756c6c792e205c5b696e666f5c5d3c45787472696e7369634661696c6564083444697370617463684572726f72304469737061746368496e666f049420416e2065787472696e736963206661696c65642e205c5b6572726f722c20696e666f5c5d2c436f64655570646174656400045420603a636f6465602077617320757064617465642e284e65774163636f756e7404244163636f756e744964047c2041206e6577205c5b6163636f756e745c5d2077617320637265617465642e344b696c6c65644163636f756e7404244163636f756e744964046c20416e205c5b6163636f756e745c5d20776173207265617065642e1838426c6f636b48617368436f756e7438543a3a426c6f636b4e756d626572106009000004d820546865206d6178696d756d206e756d626572206f6620626c6f636b7320746f20616c6c6f7720696e206d6f7274616c20657261732e484d6178696d756d426c6f636b576569676874185765696768742000204aa9d1010000047c20546865206d6178696d756d20776569676874206f66206120626c6f636b2e2044625765696768743c52756e74696d6544625765696768744040787d010000000000e1f505000000000409012054686520776569676874206f662072756e74696d65206461746162617365206f7065726174696f6e73207468652072756e74696d652063616e20696e766f6b652e50426c6f636b457865637574696f6e576569676874185765696768742000f2052a0100000004510120546865206261736520776569676874206f6620657865637574696e67206120626c6f636b2c20696e646570656e64656e74206f6620746865207472616e73616374696f6e7320696e2074686520626c6f636b2e4c45787472696e736963426173655765696768741857656967687420405973070000000004790120546865206261736520776569676874206f6620616e2045787472696e73696320696e2074686520626c6f636b2c20696e646570656e64656e74206f6620746865206f662065787472696e736963206265696e672065786563757465642e484d6178696d756d426c6f636b4c656e6774680c753332100000500004a820546865206d6178696d756d206c656e677468206f66206120626c6f636b2028696e206279746573292e143c496e76616c6964537065634e616d6508150120546865206e616d65206f662073706563696669636174696f6e20646f6573206e6f74206d61746368206265747765656e207468652063757272656e742072756e74696d655420616e6420746865206e65772072756e74696d652e685370656356657273696f6e4e65656473546f496e637265617365084501205468652073706563696669636174696f6e2076657273696f6e206973206e6f7420616c6c6f77656420746f206465637265617365206265747765656e207468652063757272656e742072756e74696d655420616e6420746865206e65772072756e74696d652e744661696c6564546f4578747261637452756e74696d6556657273696f6e0cf0204661696c656420746f2065787472616374207468652072756e74696d652076657273696f6e2066726f6d20746865206e65772072756e74696d652e000d01204569746865722063616c6c696e672060436f72655f76657273696f6e60206f72206465636f64696e67206052756e74696d6556657273696f6e60206661696c65642e4c4e6f6e44656661756c74436f6d706f7369746504010120537569636964652063616c6c6564207768656e20746865206163636f756e7420686173206e6f6e2d64656661756c7420636f6d706f7369746520646174612e3c4e6f6e5a65726f526566436f756e740439012054686572652069732061206e6f6e2d7a65726f207265666572656e636520636f756e742070726576656e74696e6720746865206163636f756e742066726f6d206265696e67207075726765642e006052616e646f6d6e657373436f6c6c656374697665466c6970016052616e646f6d6e657373436f6c6c656374697665466c6970043852616e646f6d4d6174657269616c0100305665633c543a3a486173683e04000c610120536572696573206f6620626c6f636b20686561646572732066726f6d20746865206c61737420383120626c6f636b73207468617420616374732061732072616e646f6d2073656564206d6174657269616c2e2054686973610120697320617272616e67656420617320612072696e672062756666657220776974682060626c6f636b5f6e756d626572202520383160206265696e672074686520696e64657820696e746f20746865206056656360206f664420746865206f6c6465737420686173682e0100000000012454696d657374616d70012454696d657374616d70080c4e6f77010024543a3a4d6f6d656e7420000000000000000004902043757272656e742074696d6520666f72207468652063757272656e7420626c6f636b2e24446964557064617465010010626f6f6c040004b420446964207468652074696d657374616d7020676574207570646174656420696e207468697320626c6f636b3f01040c736574040c6e6f7748436f6d706163743c543a3a4d6f6d656e743e3c5820536574207468652063757272656e742074696d652e00590120546869732063616c6c2073686f756c6420626520696e766f6b65642065786163746c79206f6e63652070657220626c6f636b2e2049742077696c6c2070616e6963206174207468652066696e616c697a6174696f6ed82070686173652c20696620746869732063616c6c206861736e2774206265656e20696e766f6b656420627920746861742074696d652e004501205468652074696d657374616d702073686f756c642062652067726561746572207468616e207468652070726576696f7573206f6e652062792074686520616d6f756e74207370656369666965642062794420604d696e696d756d506572696f64602e00d820546865206469737061746368206f726967696e20666f7220746869732063616c6c206d7573742062652060496e686572656e74602e002c2023203c7765696768743ed0202d20604f285429602077686572652060546020636f6d706c6578697479206f6620606f6e5f74696d657374616d705f73657460a101202d20312073746f72616765207265616420616e6420312073746f72616765206d75746174696f6e2028636f64656320604f28312960292e202862656361757365206f6620604469645570646174653a3a74616b656020696e20606f6e5f66696e616c697a656029b4202d2031206576656e742068616e646c657220606f6e5f74696d657374616d705f7365746020604f285429602e302023203c2f7765696768743e0004344d696e696d756d506572696f6424543a3a4d6f6d656e7420b80b00000000000010690120546865206d696e696d756d20706572696f64206265747765656e20626c6f636b732e204265776172652074686174207468697320697320646966666572656e7420746f20746865202a65787065637465642a20706572696f64690120746861742074686520626c6f636b2070726f64756374696f6e206170706172617475732070726f76696465732e20596f75722063686f73656e20636f6e73656e7375732073797374656d2077696c6c2067656e6572616c6c79650120776f726b2077697468207468697320746f2064657465726d696e6520612073656e7369626c6520626c6f636b2074696d652e20652e672e20466f7220417572612c2069742077696c6c20626520646f75626c6520746869737020706572696f64206f6e2064656661756c742073657474696e67732e000210417572610000000000031c4772616e647061013c4772616e64706146696e616c6974791814537461746501006c53746f72656453746174653c543a3a426c6f636b4e756d6265723e04000490205374617465206f66207468652063757272656e7420617574686f72697479207365742e3450656e64696e674368616e676500008c53746f72656450656e64696e674368616e67653c543a3a426c6f636b4e756d6265723e040004c42050656e64696e67206368616e67653a20287369676e616c65642061742c207363686564756c6564206368616e6765292e284e657874466f72636564000038543a3a426c6f636b4e756d626572040004bc206e65787420626c6f636b206e756d6265722077686572652077652063616e20666f7263652061206368616e67652e1c5374616c6c656400008028543a3a426c6f636b4e756d6265722c20543a3a426c6f636b4e756d626572290400049020607472756560206966207765206172652063757272656e746c79207374616c6c65642e3043757272656e7453657449640100145365744964200000000000000000085d0120546865206e756d626572206f66206368616e6765732028626f746820696e207465726d73206f66206b65797320616e6420756e6465726c79696e672065636f6e6f6d696320726573706f6e736962696c697469657329c420696e20746865202273657422206f66204772616e6470612076616c696461746f72732066726f6d2067656e657369732e30536574496453657373696f6e0001051453657449643053657373696f6e496e6465780004001059012041206d617070696e672066726f6d206772616e6470612073657420494420746f2074686520696e646578206f6620746865202a6d6f737420726563656e742a2073657373696f6e20666f722077686963682069747368206d656d62657273207765726520726573706f6e7369626c652e00b82054574f582d4e4f54453a2060536574496460206973206e6f7420756e646572207573657220636f6e74726f6c2e010c4c7265706f72745f65717569766f636174696f6e084865717569766f636174696f6e5f70726f6f66a845717569766f636174696f6e50726f6f663c543a3a486173682c20543a3a426c6f636b4e756d6265723e3c6b65795f6f776e65725f70726f6f6640543a3a4b65794f776e657250726f6f66100d01205265706f727420766f7465722065717569766f636174696f6e2f6d69736265686176696f722e2054686973206d6574686f642077696c6c2076657269667920746865f82065717569766f636174696f6e2070726f6f6620616e642076616c69646174652074686520676976656e206b6579206f776e6572736869702070726f6f66fc20616761696e73742074686520657874726163746564206f6666656e6465722e20496620626f7468206172652076616c69642c20746865206f6666656e6365482077696c6c206265207265706f727465642e707265706f72745f65717569766f636174696f6e5f756e7369676e6564084865717569766f636174696f6e5f70726f6f66a845717569766f636174696f6e50726f6f663c543a3a486173682c20543a3a426c6f636b4e756d6265723e3c6b65795f6f776e65725f70726f6f6640543a3a4b65794f776e657250726f6f66240d01205265706f727420766f7465722065717569766f636174696f6e2f6d69736265686176696f722e2054686973206d6574686f642077696c6c2076657269667920746865f82065717569766f636174696f6e2070726f6f6620616e642076616c69646174652074686520676976656e206b6579206f776e6572736869702070726f6f66fc20616761696e73742074686520657874726163746564206f6666656e6465722e20496620626f7468206172652076616c69642c20746865206f6666656e6365482077696c6c206265207265706f727465642e00110120546869732065787472696e736963206d7573742062652063616c6c656420756e7369676e656420616e642069742069732065787065637465642074686174206f6e6c79190120626c6f636b20617574686f72732077696c6c2063616c6c206974202876616c69646174656420696e206056616c6964617465556e7369676e656460292c206173207375636819012069662074686520626c6f636b20617574686f7220697320646566696e65642069742077696c6c20626520646566696e6564206173207468652065717569766f636174696f6e28207265706f727465722e306e6f74655f7374616c6c6564081464656c617938543a3a426c6f636b4e756d6265726c626573745f66696e616c697a65645f626c6f636b5f6e756d62657238543a3a426c6f636b4e756d6265721c1d01204e6f74652074686174207468652063757272656e7420617574686f7269747920736574206f6620746865204752414e4450412066696e616c69747920676164676574206861732901207374616c6c65642e20546869732077696c6c2074726967676572206120666f7263656420617574686f7269747920736574206368616e67652061742074686520626567696e6e696e672101206f6620746865206e6578742073657373696f6e2c20746f20626520656e6163746564206064656c61796020626c6f636b7320616674657220746861742e205468652064656c617915012073686f756c64206265206869676820656e6f75676820746f20736166656c7920617373756d6520746861742074686520626c6f636b207369676e616c6c696e6720746865290120666f72636564206368616e67652077696c6c206e6f742062652072652d6f726765642028652e672e203130303020626c6f636b73292e20546865204752414e44504120766f7465727329012077696c6c20737461727420746865206e657720617574686f7269747920736574207573696e672074686520676976656e2066696e616c697a656420626c6f636b20617320626173652e5c204f6e6c792063616c6c61626c6520627920726f6f742e010c384e6577417574686f7269746965730434417574686f726974794c69737404d8204e657720617574686f726974792073657420686173206265656e206170706c6965642e205c5b617574686f726974795f7365745c5d1850617573656400049c2043757272656e7420617574686f726974792073657420686173206265656e207061757365642e1c526573756d65640004a02043757272656e7420617574686f726974792073657420686173206265656e20726573756d65642e001c2c50617573654661696c656408090120417474656d707420746f207369676e616c204752414e445041207061757365207768656e2074686520617574686f72697479207365742069736e2774206c697665a8202865697468657220706175736564206f7220616c72656164792070656e64696e67207061757365292e30526573756d654661696c656408150120417474656d707420746f207369676e616c204752414e44504120726573756d65207768656e2074686520617574686f72697479207365742069736e277420706175736564a42028656974686572206c697665206f7220616c72656164792070656e64696e6720726573756d65292e344368616e676550656e64696e6704ec20417474656d707420746f207369676e616c204752414e445041206368616e67652077697468206f6e6520616c72656164792070656e64696e672e1c546f6f536f6f6e04c02043616e6e6f74207369676e616c20666f72636564206368616e676520736f20736f6f6e206166746572206c6173742e60496e76616c69644b65794f776e65727368697050726f6f660435012041206b6579206f776e6572736869702070726f6f662070726f76696465642061732070617274206f6620616e2065717569766f636174696f6e207265706f727420697320696e76616c69642e60496e76616c696445717569766f636174696f6e50726f6f6604350120416e2065717569766f636174696f6e2070726f6f662070726f76696465642061732070617274206f6620616e2065717569766f636174696f6e207265706f727420697320696e76616c69642e584475706c69636174654f6666656e63655265706f7274041901204120676976656e2065717569766f636174696f6e207265706f72742069732076616c69642062757420616c72656164792070726576696f75736c79207265706f727465642e042042616c616e636573012042616c616e6365731034546f74616c49737375616e6365010028543a3a42616c616e6365400000000000000000000000000000000004982054686520746f74616c20756e6974732069737375656420696e207468652073797374656d2e1c4163636f756e7401010230543a3a4163636f756e7449645c4163636f756e74446174613c543a3a42616c616e63653e000101000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c6c205468652062616c616e6365206f6620616e206163636f756e742e004101204e4f54453a2054686973206973206f6e6c79207573656420696e20746865206361736520746861742074686973206d6f64756c65206973207573656420746f2073746f72652062616c616e6365732e144c6f636b7301010230543a3a4163636f756e744964705665633c42616c616e63654c6f636b3c543a3a42616c616e63653e3e00040008b820416e79206c6971756964697479206c6f636b73206f6e20736f6d65206163636f756e742062616c616e6365732e2501204e4f54453a2053686f756c64206f6e6c79206265206163636573736564207768656e2073657474696e672c206368616e67696e6720616e642066726565696e672061206c6f636b2e3853746f7261676556657273696f6e01002052656c656173657304000c7c2053746f726167652076657273696f6e206f66207468652070616c6c65742e00a020546869732069732073657420746f2076322e302e3020666f72206e6577206e6574776f726b732e0110207472616e736665720810646573748c3c543a3a4c6f6f6b7570206173205374617469634c6f6f6b75703e3a3a536f757263651476616c75654c436f6d706163743c543a3a42616c616e63653e6cd8205472616e7366657220736f6d65206c697175696420667265652062616c616e636520746f20616e6f74686572206163636f756e742e00090120607472616e73666572602077696c6c207365742074686520604672656542616c616e636560206f66207468652073656e64657220616e642072656365697665722e21012049742077696c6c2064656372656173652074686520746f74616c2069737375616e6365206f66207468652073797374656d2062792074686520605472616e73666572466565602e1501204966207468652073656e6465722773206163636f756e742069732062656c6f7720746865206578697374656e7469616c206465706f736974206173206120726573756c74b4206f6620746865207472616e736665722c20746865206163636f756e742077696c6c206265207265617065642e00190120546865206469737061746368206f726967696e20666f7220746869732063616c6c206d75737420626520605369676e65646020627920746865207472616e736163746f722e002c2023203c7765696768743e3101202d20446570656e64656e74206f6e20617267756d656e747320627574206e6f7420637269746963616c2c20676976656e2070726f70657220696d706c656d656e746174696f6e7320666f72cc202020696e70757420636f6e6669672074797065732e205365652072656c617465642066756e6374696f6e732062656c6f772e6901202d20497420636f6e7461696e732061206c696d69746564206e756d626572206f6620726561647320616e642077726974657320696e7465726e616c6c7920616e64206e6f20636f6d706c657820636f6d7075746174696f6e2e004c2052656c617465642066756e6374696f6e733a0051012020202d2060656e737572655f63616e5f77697468647261776020697320616c776179732063616c6c656420696e7465726e616c6c792062757420686173206120626f756e64656420636f6d706c65786974792e2d012020202d205472616e7366657272696e672062616c616e63657320746f206163636f756e7473207468617420646964206e6f74206578697374206265666f72652077696c6c206361757365d420202020202060543a3a4f6e4e65774163636f756e743a3a6f6e5f6e65775f6163636f756e746020746f2062652063616c6c65642e61012020202d2052656d6f76696e6720656e6f7567682066756e64732066726f6d20616e206163636f756e742077696c6c20747269676765722060543a3a4475737452656d6f76616c3a3a6f6e5f756e62616c616e636564602e49012020202d20607472616e736665725f6b6565705f616c6976656020776f726b73207468652073616d652077617920617320607472616e73666572602c206275742068617320616e206164646974696f6e616cf82020202020636865636b207468617420746865207472616e736665722077696c6c206e6f74206b696c6c20746865206f726967696e206163636f756e742e88202d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d4501202d2042617365205765696768743a2037332e363420c2b5732c20776f7273742063617365207363656e6172696f20286163636f756e7420637265617465642c206163636f756e742072656d6f76656429dc202d204442205765696768743a2031205265616420616e64203120577269746520746f2064657374696e6174696f6e206163636f756e741501202d204f726967696e206163636f756e7420697320616c726561647920696e206d656d6f72792c20736f206e6f204442206f7065726174696f6e7320666f72207468656d2e302023203c2f7765696768743e2c7365745f62616c616e63650c0c77686f8c3c543a3a4c6f6f6b7570206173205374617469634c6f6f6b75703e3a3a536f75726365206e65775f667265654c436f6d706163743c543a3a42616c616e63653e306e65775f72657365727665644c436f6d706163743c543a3a42616c616e63653e489420536574207468652062616c616e636573206f66206120676976656e206163636f756e742e00210120546869732077696c6c20616c74657220604672656542616c616e63656020616e642060526573657276656442616c616e63656020696e2073746f726167652e2069742077696c6c090120616c736f2064656372656173652074686520746f74616c2069737375616e6365206f66207468652073797374656d202860546f74616c49737375616e636560292e190120496620746865206e65772066726565206f722072657365727665642062616c616e63652069732062656c6f7720746865206578697374656e7469616c206465706f7369742c01012069742077696c6c20726573657420746865206163636f756e74206e6f6e63652028606672616d655f73797374656d3a3a4163636f756e744e6f6e636560292e00b420546865206469737061746368206f726967696e20666f7220746869732063616c6c2069732060726f6f74602e002c2023203c7765696768743e80202d20496e646570656e64656e74206f662074686520617267756d656e74732ec4202d20436f6e7461696e732061206c696d69746564206e756d626572206f6620726561647320616e64207772697465732e58202d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d3c202d2042617365205765696768743a6820202020202d204372656174696e673a2032372e353620c2b5736420202020202d204b696c6c696e673a2033352e313120c2b57398202d204442205765696768743a203120526561642c203120577269746520746f206077686f60302023203c2f7765696768743e38666f7263655f7472616e736665720c18736f757263658c3c543a3a4c6f6f6b7570206173205374617469634c6f6f6b75703e3a3a536f7572636510646573748c3c543a3a4c6f6f6b7570206173205374617469634c6f6f6b75703e3a3a536f757263651476616c75654c436f6d706163743c543a3a42616c616e63653e1851012045786163746c7920617320607472616e73666572602c2065786365707420746865206f726967696e206d75737420626520726f6f7420616e642074686520736f75726365206163636f756e74206d61792062652c207370656369666965642e2c2023203c7765696768743e4101202d2053616d65206173207472616e736665722c20627574206164646974696f6e616c207265616420616e6420777269746520626563617573652074686520736f75726365206163636f756e74206973902020206e6f7420617373756d656420746f20626520696e20746865206f7665726c61792e302023203c2f7765696768743e4c7472616e736665725f6b6565705f616c6976650810646573748c3c543a3a4c6f6f6b7570206173205374617469634c6f6f6b75703e3a3a536f757263651476616c75654c436f6d706163743c543a3a42616c616e63653e2c51012053616d6520617320746865205b607472616e73666572605d2063616c6c2c206275742077697468206120636865636b207468617420746865207472616e736665722077696c6c206e6f74206b696c6c2074686540206f726967696e206163636f756e742e00bc20393925206f66207468652074696d6520796f752077616e74205b607472616e73666572605d20696e73746561642e00c4205b607472616e73666572605d3a207374727563742e4d6f64756c652e68746d6c236d6574686f642e7472616e736665722c2023203c7765696768743ee8202d2043686561706572207468616e207472616e736665722062656361757365206163636f756e742063616e6e6f74206265206b696c6c65642e60202d2042617365205765696768743a2035312e3420c2b5731d01202d204442205765696768743a2031205265616420616e64203120577269746520746f2064657374202873656e64657220697320696e206f7665726c617920616c7265616479292c20233c2f7765696768743e01201c456e646f77656408244163636f756e7449641c42616c616e636504250120416e206163636f756e74207761732063726561746564207769746820736f6d6520667265652062616c616e63652e205c5b6163636f756e742c20667265655f62616c616e63655c5d20447573744c6f737408244163636f756e7449641c42616c616e636508410120416e206163636f756e74207761732072656d6f7665642077686f73652062616c616e636520776173206e6f6e2d7a65726f206275742062656c6f77204578697374656e7469616c4465706f7369742cd020726573756c74696e6720696e20616e206f75747269676874206c6f73732e205c5b6163636f756e742c2062616c616e63655c5d205472616e736665720c244163636f756e744964244163636f756e7449641c42616c616e636504a0205472616e73666572207375636365656465642e205c5b66726f6d2c20746f2c2076616c75655c5d2842616c616e63655365740c244163636f756e7449641c42616c616e63651c42616c616e636504cc20412062616c616e6365207761732073657420627920726f6f742e205c5b77686f2c20667265652c2072657365727665645c5d1c4465706f73697408244163636f756e7449641c42616c616e636504210120536f6d6520616d6f756e7420776173206465706f73697465642028652e672e20666f72207472616e73616374696f6e2066656573292e205c5b77686f2c206465706f7369745c5d20526573657276656408244163636f756e7449641c42616c616e636504210120536f6d652062616c616e63652077617320726573657276656420286d6f7665642066726f6d206672656520746f207265736572766564292e205c5b77686f2c2076616c75655c5d28556e726573657276656408244163636f756e7449641c42616c616e636504290120536f6d652062616c616e63652077617320756e726573657276656420286d6f7665642066726f6d20726573657276656420746f2066726565292e205c5b77686f2c2076616c75655c5d4852657365727665526570617472696174656410244163636f756e744964244163636f756e7449641c42616c616e6365185374617475730c510120536f6d652062616c616e636520776173206d6f7665642066726f6d207468652072657365727665206f6620746865206669727374206163636f756e7420746f20746865207365636f6e64206163636f756e742edc2046696e616c20617267756d656e7420696e64696361746573207468652064657374696e6174696f6e2062616c616e636520747970652ea8205c5b66726f6d2c20746f2c2062616c616e63652c2064657374696e6174696f6e5f7374617475735c5d04484578697374656e7469616c4465706f73697428543a3a42616c616e636540f401000000000000000000000000000004d420546865206d696e696d756d20616d6f756e7420726571756972656420746f206b65657020616e206163636f756e74206f70656e2e203856657374696e6742616c616e6365049c2056657374696e672062616c616e636520746f6f206869676820746f2073656e642076616c7565544c69717569646974795265737472696374696f6e7304c8204163636f756e74206c6971756964697479207265737472696374696f6e732070726576656e74207769746864726177616c204f766572666c6f77047420476f7420616e206f766572666c6f7720616674657220616464696e674c496e73756666696369656e7442616c616e636504782042616c616e636520746f6f206c6f7720746f2073656e642076616c7565484578697374656e7469616c4465706f73697404ec2056616c756520746f6f206c6f7720746f20637265617465206163636f756e742064756520746f206578697374656e7469616c206465706f736974244b656570416c6976650490205472616e736665722f7061796d656e7420776f756c64206b696c6c206163636f756e745c4578697374696e6756657374696e675363686564756c6504cc20412076657374696e67207363686564756c6520616c72656164792065786973747320666f722074686973206163636f756e742c446561644163636f756e74048c2042656e6566696369617279206163636f756e74206d757374207072652d657869737405485472616e73616374696f6e5061796d656e7401485472616e73616374696f6e5061796d656e7408444e6578744665654d756c7469706c6965720100284d756c7469706c69657240000064a7b3b6e00d0000000000000000003853746f7261676556657273696f6e01002052656c6561736573040000000008485472616e73616374696f6e427974654665653042616c616e63654f663c543e4001000000000000000000000000000000040d01205468652066656520746f206265207061696420666f72206d616b696e672061207472616e73616374696f6e3b20746865207065722d6279746520706f7274696f6e2e2c576569676874546f466565a45665633c576569676874546f466565436f656666696369656e743c42616c616e63654f663c543e3e3e5c0401000000000000000000000000000000000000000001040d012054686520706f6c796e6f6d69616c2074686174206973206170706c69656420696e206f7264657220746f20646572697665206665652066726f6d207765696768742e0006105375646f01105375646f040c4b6579010030543a3a4163636f756e74496480000000000000000000000000000000000000000000000000000000000000000004842054686520604163636f756e74496460206f6620746865207375646f206b65792e0110107375646f041063616c6c5c426f783c3c542061732054726169743e3a3a43616c6c3e2839012041757468656e7469636174657320746865207375646f206b657920616e64206469737061746368657320612066756e6374696f6e2063616c6c20776974682060526f6f7460206f726967696e2e00d020546865206469737061746368206f726967696e20666f7220746869732063616c6c206d757374206265205f5369676e65645f2e002c2023203c7765696768743e20202d204f2831292e64202d204c696d697465642073746f726167652072656164732e60202d204f6e6520444220777269746520286576656e74292ec8202d20576569676874206f662064657269766174697665206063616c6c6020657865637574696f6e202b2031302c3030302e302023203c2f7765696768743e547375646f5f756e636865636b65645f776569676874081063616c6c5c426f783c3c542061732054726169743e3a3a43616c6c3e1c5f776569676874185765696768742839012041757468656e7469636174657320746865207375646f206b657920616e64206469737061746368657320612066756e6374696f6e2063616c6c20776974682060526f6f7460206f726967696e2e310120546869732066756e6374696f6e20646f6573206e6f7420636865636b2074686520776569676874206f66207468652063616c6c2c20616e6420696e737465616420616c6c6f777320746865b4205375646f207573657220746f20737065636966792074686520776569676874206f66207468652063616c6c2e00d020546865206469737061746368206f726967696e20666f7220746869732063616c6c206d757374206265205f5369676e65645f2e002c2023203c7765696768743e20202d204f2831292ed0202d2054686520776569676874206f6620746869732063616c6c20697320646566696e6564206279207468652063616c6c65722e302023203c2f7765696768743e1c7365745f6b6579040c6e65778c3c543a3a4c6f6f6b7570206173205374617469634c6f6f6b75703e3a3a536f757263652475012041757468656e74696361746573207468652063757272656e74207375646f206b657920616e6420736574732074686520676976656e204163636f756e7449642028606e6577602920617320746865206e6577207375646f206b65792e00d020546865206469737061746368206f726967696e20666f7220746869732063616c6c206d757374206265205f5369676e65645f2e002c2023203c7765696768743e20202d204f2831292e64202d204c696d697465642073746f726167652072656164732e44202d204f6e65204442206368616e67652e302023203c2f7765696768743e1c7375646f5f6173080c77686f8c3c543a3a4c6f6f6b7570206173205374617469634c6f6f6b75703e3a3a536f757263651063616c6c5c426f783c3c542061732054726169743e3a3a43616c6c3e2c51012041757468656e7469636174657320746865207375646f206b657920616e64206469737061746368657320612066756e6374696f6e2063616c6c207769746820605369676e656460206f726967696e2066726f6d44206120676976656e206163636f756e742e00d020546865206469737061746368206f726967696e20666f7220746869732063616c6c206d757374206265205f5369676e65645f2e002c2023203c7765696768743e20202d204f2831292e64202d204c696d697465642073746f726167652072656164732e60202d204f6e6520444220777269746520286576656e74292ec8202d20576569676874206f662064657269766174697665206063616c6c6020657865637574696f6e202b2031302c3030302e302023203c2f7765696768743e010c14537564696404384469737061746368526573756c74048c2041207375646f206a75737420746f6f6b20706c6163652e205c5b726573756c745c5d284b65794368616e67656404244163636f756e74496404010120546865205c5b7375646f65725c5d206a757374207377697463686564206964656e746974793b20746865206f6c64206b657920697320737570706c6965642e285375646f4173446f6e650410626f6f6c048c2041207375646f206a75737420746f6f6b20706c6163652e205c5b726573756c745c5d00042c526571756972655375646f04802053656e646572206d75737420626520746865205375646f206163636f756e74073854656d706c6174654d6f64756c65013854656d706c6174654d6f64756c650424536f6d657468696e6700000c753332040000010830646f5f736f6d657468696e670424736f6d657468696e670c753332085d0120416e206578616d706c6520646973706174636861626c6520746861742074616b657320612073696e676c65732076616c7565206173206120706172616d657465722c20777269746573207468652076616c756520746f51012073746f7261676520616e6420656d69747320616e206576656e742e20546869732066756e6374696f6e206d75737420626520646973706174636865642062792061207369676e65642065787472696e7369632e2c63617573655f6572726f720004dc20416e206578616d706c6520646973706174636861626c652074686174206d6179207468726f77206120637573746f6d206572726f722e01043c536f6d657468696e6753746f726564080c753332244163636f756e744964085d01204576656e7420646f63756d656e746174696f6e2073686f756c6420656e64207769746820616e20617272617920746861742070726f7669646573206465736372697074697665206e616d657320666f72206576656e747420706172616d65746572732e205b736f6d657468696e672c2077686f5d0008244e6f6e6556616c7565048c204572726f72206e616d65732073686f756c642062652064657363726970746976652e3c53746f726167654f766572666c6f7704fc204572726f72732073686f756c6420686176652068656c7066756c20646f63756d656e746174696f6e206173736f6369617465642077697468207468656d2e08041c40436865636b5370656356657273696f6e38436865636b547856657273696f6e30436865636b47656e6573697338436865636b4d6f7274616c69747928436865636b4e6f6e63652c436865636b576569676874604368617267655472616e73616374696f6e5061796d656e74" + +rpc_methods = [ + 'account_nextIndex', + 'author_hasKey', + 'author_hasSessionKeys', + 'author_insertKey', + 'author_pendingExtrinsics', + 'author_removeExtrinsic', + 'author_rotateKeys', + 'author_submitAndWatchExtrinsic', + 'author_submitExtrinsic', + 'author_unwatchExtrinsic', + 'babe_epochAuthorship', + 'chainHead_unstable_body', + 'chainHead_unstable_call', + 'chainHead_unstable_follow', + 'chainHead_unstable_genesisHash', + 'chainHead_unstable_header', + 'chainHead_unstable_stopBody', + 'chainHead_unstable_stopCall', + 'chainHead_unstable_stopStorage', + 'chainHead_unstable_storage', + 'chainHead_unstable_unfollow', + 'chainHead_unstable_unpin', + 'chainSpec_unstable_chainName', + 'chainSpec_unstable_genesisHash', + 'chainSpec_unstable_properties', + 'chain_getBlock', + 'chain_getBlockHash', + 'chain_getFinalisedHead', + 'chain_getFinalizedHead', + 'chain_getHead', + 'chain_getHeader', + 'chain_getRuntimeVersion', + 'chain_subscribeAllHeads', + 'chain_subscribeFinalisedHeads', + 'chain_subscribeFinalizedHeads', + 'chain_subscribeNewHead', + 'chain_subscribeNewHeads', + 'chain_subscribeRuntimeVersion', + 'chain_unsubscribeAllHeads', + 'chain_unsubscribeFinalisedHeads', + 'chain_unsubscribeFinalizedHeads', + 'chain_unsubscribeNewHead', + 'chain_unsubscribeNewHeads', + 'chain_unsubscribeRuntimeVersion', + 'childstate_getKeys', + 'childstate_getKeysPaged', + 'childstate_getKeysPagedAt', + 'childstate_getStorage', + 'childstate_getStorageEntries', + 'childstate_getStorageHash', + 'childstate_getStorageSize', + 'dev_getBlockStats', + 'grandpa_proveFinality', + 'grandpa_roundState', + 'grandpa_subscribeJustifications', + 'grandpa_unsubscribeJustifications', + 'mmr_generateProof', + 'mmr_root', + 'mmr_verifyProof', + 'mmr_verifyProofStateless', + 'offchain_localStorageGet', + 'offchain_localStorageSet', + 'payment_queryFeeDetails', + 'payment_queryInfo', + 'state_call', + 'state_callAt', + 'state_getChildReadProof', + 'state_getKeys', + 'state_getKeysPaged', + 'state_getKeysPagedAt', + 'state_getMetadata', + 'state_getPairs', + 'state_getReadProof', + 'state_getRuntimeVersion', + 'state_getStorage', + 'state_getStorageAt', + 'state_getStorageHash', + 'state_getStorageHashAt', + 'state_getStorageSize', + 'state_getStorageSizeAt', + 'state_queryStorage', + 'state_queryStorageAt', + 'state_subscribeRuntimeVersion', + 'state_subscribeStorage', + 'state_traceBlock', + 'state_trieMigrationStatus', + 'state_unsubscribeRuntimeVersion', + 'state_unsubscribeStorage', + 'subscribe_newHead', + 'sync_state_genSyncSpec', + 'system_accountNextIndex', + 'system_addLogFilter', + 'system_addReservedPeer', + 'system_chain', + 'system_chainType', + 'system_dryRun', + 'system_dryRunAt', + 'system_health', + 'system_localListenAddresses', + 'system_localPeerId', + 'system_name', + 'system_nodeRoles', + 'system_peers', + 'system_properties', + 'system_removeReservedPeer', + 'system_reservedPeers', + 'system_resetLogFilter', + 'system_syncState', + 'system_unstable_networkState', + 'system_version', + 'transaction_unstable_submitAndWatch', + 'transaction_unstable_unwatch', + 'unsubscribe_newHead' +] diff --git a/test/test_block.py b/test/test_block.py index 7271c6f2..3fb0a9cf 100644 --- a/test/test_block.py +++ b/test/test_block.py @@ -23,7 +23,7 @@ from substrateinterface import SubstrateInterface -from test.fixtures import metadata_node_template_hex +from test.fixtures import metadata_node_template_hex, rpc_methods from scalecodec.base import ScaleBytes from scalecodec.types import Vec, GenericAddress @@ -70,7 +70,10 @@ def mocked_request(method, params, result_handler=None): "jsonrpc": "2.0", "result": { "digest": { - "logs": ['0x066175726120afe0021000000000', '0x05617572610101567be3d55b4885ce3ac6a7b46b28adf138299acc3eb5f11ffa15c3ed0551f22b7220ec676ea947cd6c8daa6fcfa351b11e62651e6e06f5dde59bb566d36e6989'] + "logs": [ + '0x066175726120afe0021000000000', + '0x05617572610101567be3d55b4885ce3ac6a7b46b28adf138299acc3eb5f11ffa15c3ed0551f22b7220ec676ea947cd6c8daa6fcfa351b11e62651e6e06f5dde59bb566d36e6989' + ] }, "extrinsicsRoot": "0xeaa9cd48b36a88ba7cf934cdbcd8f2afc0843978912452529ace7ef2da09691d", "number": "0x67", @@ -92,7 +95,10 @@ def mocked_request(method, params, result_handler=None): ], "header": { "digest": { - "logs": ['0x06424142453402000000007c4e1f2000000000', '0x054241424501014630c672ca0561bb045d30cba349f9768560bd66cb40ca1c88fcf345f0d8d63b31d179c2cede66d584cf199a457ba436e9f621bfe0b89bf998069b3ed3d2548e'] + "logs": [ + '0x06424142453402000000007c4e1f2000000000', + '0x054241424501014630c672ca0561bb045d30cba349f9768560bd66cb40ca1c88fcf345f0d8d63b31d179c2cede66d584cf199a457ba436e9f621bfe0b89bf998069b3ed3d2548e' + ] }, "extrinsicsRoot": "0xeaa9cd48b36a88ba7cf934cdbcd8f2afc0843978912452529ace7ef2da09691d", "number": "0x67", @@ -134,14 +140,21 @@ def mocked_request(method, params, result_handler=None): "id": 1 } elif method == 'state_getStorageAt': - return {'jsonrpc': '2.0', 'result': '0x04be5ddb1579b72e84524fc29e78609e3caf42e85aa118ebfe0b0ad404b5bdd25f', 'id': 11} + return { + 'jsonrpc': '2.0', + 'result': '0x04be5ddb1579b72e84524fc29e78609e3caf42e85aa118ebfe0b0ad404b5bdd25f', + 'id': 11 + } elif method == 'chain_subscribeNewHeads': return result_handler({ "jsonrpc": "2.0", "params": { "result": { "digest": { - "logs": ['0x066175726120afe0021000000000', '0x05617572610101567be3d55b4885ce3ac6a7b46b28adf138299acc3eb5f11ffa15c3ed0551f22b7220ec676ea947cd6c8daa6fcfa351b11e62651e6e06f5dde59bb566d36e6989'] + "logs": [ + '0x066175726120afe0021000000000', + '0x05617572610101567be3d55b4885ce3ac6a7b46b28adf138299acc3eb5f11ffa15c3ed0551f22b7220ec676ea947cd6c8daa6fcfa351b11e62651e6e06f5dde59bb566d36e6989' + ] }, "extrinsicsRoot": "0xeaa9cd48b36a88ba7cf934cdbcd8f2afc0843978912452529ace7ef2da09691d", "number": "0x67", @@ -159,7 +172,7 @@ def mocked_request(method, params, result_handler=None): elif method == 'rpc_methods': return { "jsonrpc": "2.0", - "result": {'methods': ['account_nextIndex', 'author_hasKey', 'author_hasSessionKeys', 'author_insertKey', 'author_pendingExtrinsics', 'author_removeExtrinsic', 'author_rotateKeys', 'author_submitAndWatchExtrinsic', 'author_submitExtrinsic', 'author_unwatchExtrinsic', 'babe_epochAuthorship', 'chainHead_unstable_body', 'chainHead_unstable_call', 'chainHead_unstable_follow', 'chainHead_unstable_genesisHash', 'chainHead_unstable_header', 'chainHead_unstable_stopBody', 'chainHead_unstable_stopCall', 'chainHead_unstable_stopStorage', 'chainHead_unstable_storage', 'chainHead_unstable_unfollow', 'chainHead_unstable_unpin', 'chainSpec_unstable_chainName', 'chainSpec_unstable_genesisHash', 'chainSpec_unstable_properties', 'chain_getBlock', 'chain_getBlockHash', 'chain_getFinalisedHead', 'chain_getFinalizedHead', 'chain_getHead', 'chain_getHeader', 'chain_getRuntimeVersion', 'chain_subscribeAllHeads', 'chain_subscribeFinalisedHeads', 'chain_subscribeFinalizedHeads', 'chain_subscribeNewHead', 'chain_subscribeNewHeads', 'chain_subscribeRuntimeVersion', 'chain_unsubscribeAllHeads', 'chain_unsubscribeFinalisedHeads', 'chain_unsubscribeFinalizedHeads', 'chain_unsubscribeNewHead', 'chain_unsubscribeNewHeads', 'chain_unsubscribeRuntimeVersion', 'childstate_getKeys', 'childstate_getKeysPaged', 'childstate_getKeysPagedAt', 'childstate_getStorage', 'childstate_getStorageEntries', 'childstate_getStorageHash', 'childstate_getStorageSize', 'dev_getBlockStats', 'grandpa_proveFinality', 'grandpa_roundState', 'grandpa_subscribeJustifications', 'grandpa_unsubscribeJustifications', 'mmr_generateProof', 'mmr_root', 'mmr_verifyProof', 'mmr_verifyProofStateless', 'offchain_localStorageGet', 'offchain_localStorageSet', 'payment_queryFeeDetails', 'payment_queryInfo', 'state_call', 'state_callAt', 'state_getChildReadProof', 'state_getKeys', 'state_getKeysPaged', 'state_getKeysPagedAt', 'state_getMetadata', 'state_getPairs', 'state_getReadProof', 'state_getRuntimeVersion', 'state_getStorage', 'state_getStorageAt', 'state_getStorageHash', 'state_getStorageHashAt', 'state_getStorageSize', 'state_getStorageSizeAt', 'state_queryStorage', 'state_queryStorageAt', 'state_subscribeRuntimeVersion', 'state_subscribeStorage', 'state_traceBlock', 'state_trieMigrationStatus', 'state_unsubscribeRuntimeVersion', 'state_unsubscribeStorage', 'subscribe_newHead', 'sync_state_genSyncSpec', 'system_accountNextIndex', 'system_addLogFilter', 'system_addReservedPeer', 'system_chain', 'system_chainType', 'system_dryRun', 'system_dryRunAt', 'system_health', 'system_localListenAddresses', 'system_localPeerId', 'system_name', 'system_nodeRoles', 'system_peers', 'system_properties', 'system_removeReservedPeer', 'system_reservedPeers', 'system_resetLogFilter', 'system_syncState', 'system_unstable_networkState', 'system_version', 'transaction_unstable_submitAndWatch', 'transaction_unstable_unwatch', 'unsubscribe_newHead']}, + "result": {'methods': rpc_methods}, "id": 1 } @@ -268,7 +281,7 @@ def subscription_handler(obj, update_nr, subscription_id): result = self.substrate.subscribe_block_headers(subscription_handler) - self.assertEqual(f"callback: 103", result) + self.assertEqual("callback: 103", result) def test_check_requirements(self): self.assertRaises(ValueError, self.substrate.get_block, diff --git a/test/test_contracts.py b/test/test_contracts.py index 432a7997..5287586b 100644 --- a/test/test_contracts.py +++ b/test/test_contracts.py @@ -438,7 +438,8 @@ def rpc_request(self, method, params, result_handler=None): return super().rpc_request(method, params, result_handler) cls.substrate = MockedSubstrateInterface( - url=settings.KUSAMA_NODE_URL, type_registry_preset='canvas', type_registry={'types': {"ContractExecResult": "ContractExecResultTo269"}} + url=settings.KUSAMA_NODE_URL, type_registry_preset='canvas', + type_registry={'types': {"ContractExecResult": "ContractExecResultTo269"}} ) cls.keypair = Keypair.create_from_uri('//Alice') diff --git a/test/test_create_extrinsics.py b/test/test_create_extrinsics.py index 36303991..c947b09d 100644 --- a/test/test_create_extrinsics.py +++ b/test/test_create_extrinsics.py @@ -16,7 +16,6 @@ import os import unittest -from scalecodec import ScaleBytes from scalecodec.type_registry import load_type_registry_file from substrateinterface import SubstrateInterface, Keypair, ExtrinsicReceipt from substrateinterface.exceptions import SubstrateRequestException @@ -91,7 +90,7 @@ def test_create_mortal_extrinsic(self): self.fail('Should raise no funds to pay fees exception') - except SubstrateRequestException as e: + except SubstrateRequestException: # Extrinsic should be successful if account had balance, eitherwise 'Bad proof' error should be raised pass diff --git a/test/test_helper_functions.py b/test/test_helper_functions.py index f5be99cf..bc63ceeb 100644 --- a/test/test_helper_functions.py +++ b/test/test_helper_functions.py @@ -18,10 +18,11 @@ from unittest.mock import MagicMock from scalecodec import GenericExtrinsic -from scalecodec.type_registry import load_type_registry_file, load_type_registry_preset +from scalecodec.type_registry import load_type_registry_file from substrateinterface.exceptions import SubstrateRequestException from scalecodec.base import ScaleBytes from substrateinterface import SubstrateInterface, Keypair +from test.fixtures import rpc_methods from test.settings import POLKADOT_NODE_URL @@ -74,7 +75,7 @@ def mocked_request(method, params): elif method == 'rpc_methods': return { "jsonrpc": "2.0", - "result": {'methods': ['account_nextIndex', 'author_hasKey', 'author_hasSessionKeys', 'author_insertKey', 'author_pendingExtrinsics', 'author_removeExtrinsic', 'author_rotateKeys', 'author_submitAndWatchExtrinsic', 'author_submitExtrinsic', 'author_unwatchExtrinsic', 'babe_epochAuthorship', 'chainHead_unstable_body', 'chainHead_unstable_call', 'chainHead_unstable_follow', 'chainHead_unstable_genesisHash', 'chainHead_unstable_header', 'chainHead_unstable_stopBody', 'chainHead_unstable_stopCall', 'chainHead_unstable_stopStorage', 'chainHead_unstable_storage', 'chainHead_unstable_unfollow', 'chainHead_unstable_unpin', 'chainSpec_unstable_chainName', 'chainSpec_unstable_genesisHash', 'chainSpec_unstable_properties', 'chain_getBlock', 'chain_getBlockHash', 'chain_getFinalisedHead', 'chain_getFinalizedHead', 'chain_getHead', 'chain_getHeader', 'chain_getRuntimeVersion', 'chain_subscribeAllHeads', 'chain_subscribeFinalisedHeads', 'chain_subscribeFinalizedHeads', 'chain_subscribeNewHead', 'chain_subscribeNewHeads', 'chain_subscribeRuntimeVersion', 'chain_unsubscribeAllHeads', 'chain_unsubscribeFinalisedHeads', 'chain_unsubscribeFinalizedHeads', 'chain_unsubscribeNewHead', 'chain_unsubscribeNewHeads', 'chain_unsubscribeRuntimeVersion', 'childstate_getKeys', 'childstate_getKeysPaged', 'childstate_getKeysPagedAt', 'childstate_getStorage', 'childstate_getStorageEntries', 'childstate_getStorageHash', 'childstate_getStorageSize', 'dev_getBlockStats', 'grandpa_proveFinality', 'grandpa_roundState', 'grandpa_subscribeJustifications', 'grandpa_unsubscribeJustifications', 'mmr_generateProof', 'mmr_root', 'mmr_verifyProof', 'mmr_verifyProofStateless', 'offchain_localStorageGet', 'offchain_localStorageSet', 'payment_queryFeeDetails', 'payment_queryInfo', 'state_call', 'state_callAt', 'state_getChildReadProof', 'state_getKeys', 'state_getKeysPaged', 'state_getKeysPagedAt', 'state_getMetadata', 'state_getPairs', 'state_getReadProof', 'state_getRuntimeVersion', 'state_getStorage', 'state_getStorageAt', 'state_getStorageHash', 'state_getStorageHashAt', 'state_getStorageSize', 'state_getStorageSizeAt', 'state_queryStorage', 'state_queryStorageAt', 'state_subscribeRuntimeVersion', 'state_subscribeStorage', 'state_traceBlock', 'state_trieMigrationStatus', 'state_unsubscribeRuntimeVersion', 'state_unsubscribeStorage', 'subscribe_newHead', 'sync_state_genSyncSpec', 'system_accountNextIndex', 'system_addLogFilter', 'system_addReservedPeer', 'system_chain', 'system_chainType', 'system_dryRun', 'system_dryRunAt', 'system_health', 'system_localListenAddresses', 'system_localPeerId', 'system_name', 'system_nodeRoles', 'system_peers', 'system_properties', 'system_removeReservedPeer', 'system_reservedPeers', 'system_resetLogFilter', 'system_syncState', 'system_unstable_networkState', 'system_version', 'transaction_unstable_submitAndWatch', 'transaction_unstable_unwatch', 'unsubscribe_newHead']}, + "result": {'methods': rpc_methods}, "id": 1 } @@ -90,7 +91,9 @@ def mocked_request(method, params): cls.empty_substrate.rpc_request = MagicMock(side_effect=mocked_request) - cls.error_substrate = SubstrateInterface(url='wss://kusama-rpc.polkadot.io', ss58_format=2, type_registry_preset='kusama') + cls.error_substrate = SubstrateInterface( + url='wss://kusama-rpc.polkadot.io', ss58_format=2, type_registry_preset='kusama' + ) # def mocked_request(method, params): # return {'jsonrpc': '2.0', 'error': { diff --git a/test/test_init.py b/test/test_init.py index 4a181df2..ff87d055 100644 --- a/test/test_init.py +++ b/test/test_init.py @@ -87,7 +87,9 @@ def test_is_valid_ss58_address(self): ) def test_lru_cache_not_shared(self): - block_number = self.kusama_substrate.get_block_number("0xa4d873095aeae6fc1f3953f0a0085ee216bf8629342aaa92bd53f841e1052e1c") + block_number = self.kusama_substrate.get_block_number( + "0xa4d873095aeae6fc1f3953f0a0085ee216bf8629342aaa92bd53f841e1052e1c" + ) block_number2 = self.polkadot_substrate.get_block_number( "0xa4d873095aeae6fc1f3953f0a0085ee216bf8629342aaa92bd53f841e1052e1c") diff --git a/test/test_keypair.py b/test/test_keypair.py index 28ce4f8c..0c3e8f37 100644 --- a/test/test_keypair.py +++ b/test/test_keypair.py @@ -145,7 +145,7 @@ def test_verify_unsupported_crypto_type(self): def test_sign_and_verify_incorrect_signature(self): mnemonic = Keypair.generate_mnemonic() keypair = Keypair.create_from_mnemonic(mnemonic) - signature = "0x4c291bfb0bb9c1274e86d4b666d13b2ac99a0bacc04a4846fb8ea50bda114677f83c1f164af58fc184451e5140cc8160c4de626163b11451d3bbb208a1889f8a" + signature = "0x4c291bfb0bb9c1274e86d4b666d13b2ac99a0bacc04a4846fb8ea50bda114677f83c1f164af58fc184451e5140cc8160c4de626163b11451d3bbb208a1889f8a" # noqa: E501 self.assertFalse(keypair.verify("Test123", signature)) def test_sign_and_verify_invalid_signature(self): @@ -176,7 +176,7 @@ def test_sign_and_verify_ed25519(self): def test_sign_and_verify_invalid_signature_ed25519(self): mnemonic = Keypair.generate_mnemonic() keypair = Keypair.create_from_mnemonic(mnemonic, crypto_type=KeypairType.ED25519) - signature = "0x4c291bfb0bb9c1274e86d4b666d13b2ac99a0bacc04a4846fb8ea50bda114677f83c1f164af58fc184451e5140cc8160c4de626163b11451d3bbb208a1889f8a" + signature = "0x4c291bfb0bb9c1274e86d4b666d13b2ac99a0bacc04a4846fb8ea50bda114677f83c1f164af58fc184451e5140cc8160c4de626163b11451d3bbb208a1889f8a" # noqa: E501 self.assertFalse(keypair.verify("Test123", signature)) def test_create_ecdsa_keypair_private_key(self): @@ -220,7 +220,7 @@ def test_sign_and_verify_ecdsa(self): def test_sign_and_verify_invalid_signature_ecdsa(self): mnemonic = Keypair.generate_mnemonic() keypair = Keypair.create_from_mnemonic(mnemonic, crypto_type=KeypairType.ECDSA) - signature = "0x24ff874fddab207ac6cae6a5bfe6e3542bb561abc98a22d1cfd7f8396927cf6d4962e198b5d599cf598b3c14cca98ab16d12569b666e8d33899c46d0d814a58200" + signature = "0x24ff874fddab207ac6cae6a5bfe6e3542bb561abc98a22d1cfd7f8396927cf6d4962e198b5d599cf598b3c14cca98ab16d12569b666e8d33899c46d0d814a58200" # noqa: E501 self.assertFalse(keypair.verify("Test123", signature)) def test_unsupport_crypto_type(self): @@ -350,11 +350,17 @@ def test_reconstruct_path_fail(self): self.assertRaises(ValueError, extract_derive_path, '//') def test_encrypt_decrypt_message(self): - sender = Keypair.create_from_mnemonic("nominee lift horse divert crop quantum proud between pink goose attack market", crypto_type=KeypairType.ED25519) + sender = Keypair.create_from_mnemonic( + "nominee lift horse divert crop quantum proud between pink goose attack market", + crypto_type=KeypairType.ED25519 + ) recipient = Keypair(ss58_address="5DFZ8UzF5zeCLVPVRMkopNjVyxJNb1dHgGJYFDaVbm4CqNku", crypto_type=KeypairType.ED25519) message = "Violence is the last refuge of the incompetent - Isaac Asimov, Foundation" message_encrypted = sender.encrypt_message(message, recipient.public_key) - recipient = Keypair.create_from_mnemonic("almost desk skull craft chuckle bubble hollow innocent require physical purchase rabbit", crypto_type=KeypairType.ED25519) + recipient = Keypair.create_from_mnemonic( + "almost desk skull craft chuckle bubble hollow innocent require physical purchase rabbit", + crypto_type=KeypairType.ED25519 + ) sender = Keypair(ss58_address="5DYUhnXkHux1rGTDaS9ACPQekbpSR2J5SyedDQNJVrk4Tn5t", crypto_type=KeypairType.ED25519) message_decrypted = recipient.decrypt_message(message_encrypted, sender.public_key).decode("utf-8") self.assertEqual(message_decrypted, message) diff --git a/test/test_query.py b/test/test_query.py index 3c4a4ea8..a8166f19 100644 --- a/test/test_query.py +++ b/test/test_query.py @@ -15,7 +15,6 @@ # limitations under the License. import unittest -from unittest.mock import MagicMock from substrateinterface import SubstrateInterface from substrateinterface.exceptions import StorageFunctionNotFound @@ -73,7 +72,7 @@ def test_non_existing_query(self): self.assertEqual('Pallet "Unknown" not found', str(cm.exception)) def test_missing_params(self): - with self.assertRaises(ValueError) as cm: + with self.assertRaises(ValueError): self.kusama_substrate.query("System", "Account") def test_modifier_default_result(self): diff --git a/test/test_rpc_compatibility.py b/test/test_rpc_compatibility.py index 12138de5..e7b12a6d 100644 --- a/test/test_rpc_compatibility.py +++ b/test/test_rpc_compatibility.py @@ -18,9 +18,6 @@ from unittest.mock import MagicMock from scalecodec.type_registry import load_type_registry_file -from test import settings - -from scalecodec.exceptions import RemainingScaleBytesNotEmptyException from substrateinterface import SubstrateInterface @@ -73,7 +70,10 @@ def mocked_request(method, params, result_handler=None): "jsonrpc": "2.0", "result": { "digest": { - "logs": ['0x066175726120afe0021000000000', '0x05617572610101567be3d55b4885ce3ac6a7b46b28adf138299acc3eb5f11ffa15c3ed0551f22b7220ec676ea947cd6c8daa6fcfa351b11e62651e6e06f5dde59bb566d36e6989'] + "logs": [ + '0x066175726120afe0021000000000', + '0x05617572610101567be3d55b4885ce3ac6a7b46b28adf138299acc3eb5f11ffa15c3ed0551f22b7220ec676ea947cd6c8daa6fcfa351b11e62651e6e06f5dde59bb566d36e6989' + ] }, "extrinsicsRoot": "0xeaa9cd48b36a88ba7cf934cdbcd8f2afc0843978912452529ace7ef2da09691d", "number": 3158840, @@ -91,7 +91,34 @@ def mocked_request(method, params, result_handler=None): "block": { "extrinsics": ['0x280403000b695f47ff8601'], "header": { - "digest": {'logs': [{'preRuntime': ['0x6e6d6273', '0x6a3f02ac48ee3080aa304fe6c336d6c75b302e08041a5c1d6a9a30541f51b618']}, {'preRuntime': ['0x72616e64', '0xe468581da52a51330797c9f5762d98a241f28b3bde9017307e15cfc9a6ebb6741e7da1282681401b26752a04073ea98335005699817e546db343b457fcc7150cdf9edabb3a7b8e35acd6e763235c9ce415bdb0a22d98024cb6410beeb74d3903']}, {'consensus': ['0x66726f6e', '0x019ad160fc5080a49795f34607dadc267a0a0485dc0e6fa46c0ded42ac102a92813090c50b4ff02aed1ca173df1f8915d9872e47a6c3c71a0a32d36d342d6c00ab9f50a496f171bad265ab5a3512568e1234cdab03f7ee1a98ce6e489d5726deed3c125f5c342d0662ccfcea93d2c34c35f328b183af68502ea9e2a72e83522dd7f884ac7a067b4e5cfae4766fd0b2159809cbe3d1af7eb1747c1a3e675982bd9312b90c5020048fef1349759f22b20a919af96ae7270dd40614eb7345ce35beff07980cb675de6be9bafd8fd2e2322cd2fce6f24d0a23c8a68adcced46da0be3b280ead3a25348bb9e6f7a90aac0a2d8a3d8badcb94c3929a5fd898146ecfd361b39de60b7a194a6e4751aa8b54c435a7a9a6af274700b870528ff0780f6ca63ba7449d5534fb786e33900b30966970f29db6310244860409dd6af96a09f9b82946d3f47a61c3bfb21a43e257b3ddf56d07ce8bfdbcb2c277eca96ebe95a8042ec0faf5d65a20505c1562aba4bde857552766320c61fd748c260a0c334a4bfec1ffedbb288cc8bd3348e4c48bd67118ce3936e3fc67b90aeebab97dbda0f6cfeb7e']}, {'seal': ['0x6e6d6273', '0x561e0be2c6f495f326fbc1bf67943f5ff087133d42860fb1dbe8f260deb4570110e1aab58f6f4064ec1839b351987489bf027e274ae593b52c88d99ae6b92f8e']}]}, + "digest": { + 'logs': [ + { + 'preRuntime': [ + '0x6e6d6273', + '0x6a3f02ac48ee3080aa304fe6c336d6c75b302e08041a5c1d6a9a30541f51b618' + ] + }, + { + 'preRuntime': [ + '0x72616e64', + '0xe468581da52a51330797c9f5762d98a241f28b3bde9017307e15cfc9a6ebb6741e7da1282681401b26752a04073ea98335005699817e546db343b457fcc7150cdf9edabb3a7b8e35acd6e763235c9ce415bdb0a22d98024cb6410beeb74d3903' + ] + }, + { + 'consensus': [ + '0x66726f6e', + '0x019ad160fc5080a49795f34607dadc267a0a0485dc0e6fa46c0ded42ac102a92813090c50b4ff02aed1ca173df1f8915d9872e47a6c3c71a0a32d36d342d6c00ab9f50a496f171bad265ab5a3512568e1234cdab03f7ee1a98ce6e489d5726deed3c125f5c342d0662ccfcea93d2c34c35f328b183af68502ea9e2a72e83522dd7f884ac7a067b4e5cfae4766fd0b2159809cbe3d1af7eb1747c1a3e675982bd9312b90c5020048fef1349759f22b20a919af96ae7270dd40614eb7345ce35beff07980cb675de6be9bafd8fd2e2322cd2fce6f24d0a23c8a68adcced46da0be3b280ead3a25348bb9e6f7a90aac0a2d8a3d8badcb94c3929a5fd898146ecfd361b39de60b7a194a6e4751aa8b54c435a7a9a6af274700b870528ff0780f6ca63ba7449d5534fb786e33900b30966970f29db6310244860409dd6af96a09f9b82946d3f47a61c3bfb21a43e257b3ddf56d07ce8bfdbcb2c277eca96ebe95a8042ec0faf5d65a20505c1562aba4bde857552766320c61fd748c260a0c334a4bfec1ffedbb288cc8bd3348e4c48bd67118ce3936e3fc67b90aeebab97dbda0f6cfeb7e' + ] + }, + { + 'seal': [ + '0x6e6d6273', + '0x561e0be2c6f495f326fbc1bf67943f5ff087133d42860fb1dbe8f260deb4570110e1aab58f6f4064ec1839b351987489bf027e274ae593b52c88d99ae6b92f8e' + ] + } + ] + }, "extrinsicsRoot": "0xeaa9cd48b36a88ba7cf934cdbcd8f2afc0843978912452529ace7ef2da09691d", "number": "0x67", "parentHash": "0xf33015565b9978d146cdf648c498649b04c323cd35d9f55fad7d8586d4b42ea2", @@ -132,14 +159,21 @@ def mocked_request(method, params, result_handler=None): "id": 1 } elif method == 'state_getStorageAt': - return {'jsonrpc': '2.0', 'result': '0x04be5ddb1579b72e84524fc29e78609e3caf42e85aa118ebfe0b0ad404b5bdd25f', 'id': 11} + return { + 'jsonrpc': '2.0', + 'result': '0x04be5ddb1579b72e84524fc29e78609e3caf42e85aa118ebfe0b0ad404b5bdd25f', + 'id': 11 + } elif method == 'chain_subscribeNewHeads': return result_handler({ "jsonrpc": "2.0", "params": { "result": { "digest": { - "logs": ['0x066175726120afe0021000000000', '0x05617572610101567be3d55b4885ce3ac6a7b46b28adf138299acc3eb5f11ffa15c3ed0551f22b7220ec676ea947cd6c8daa6fcfa351b11e62651e6e06f5dde59bb566d36e6989'] + "logs": [ + '0x066175726120afe0021000000000', + '0x05617572610101567be3d55b4885ce3ac6a7b46b28adf138299acc3eb5f11ffa15c3ed0551f22b7220ec676ea947cd6c8daa6fcfa351b11e62651e6e06f5dde59bb566d36e6989' + ] }, "extrinsicsRoot": "0xeaa9cd48b36a88ba7cf934cdbcd8f2afc0843978912452529ace7ef2da09691d", "number": "0x67", @@ -157,7 +191,7 @@ def mocked_request(method, params, result_handler=None): elif method == 'rpc_methods': return { "jsonrpc": "2.0", - "result": {"methods": ['author_submitExtrinsic', 'author_submitAndWatchExtrinsic', 'author_unwatchExtrinsic', 'author_pendingExtrinsics', 'chain_getBlockHash', 'chain_getHeader', 'chain_getBlock', 'chain_getFinalizedHead', 'chain_subscribeNewHead', 'chain_subscribeFinalizedHeads', 'chain_unsubscribeNewHead', 'chain_subscribeNewHeads', 'chain_unsubscribeNewHeads', 'chain_unsubscribeFinalizedHeads', 'state_getRuntimeVersion', 'state_getMetadata', 'state_getStorage', 'state_getKeysPaged', 'state_queryStorageAt', 'state_call', 'state_subscribeRuntimeVersion', 'state_unsubscribeRuntimeVersion', 'state_subscribeStorage', 'state_unsubscribeStorage', 'system_localPeerId', 'system_nodeRoles', 'system_localListenAddresses', 'system_chain', 'system_properties', 'system_name', 'system_version', 'system_chainType', 'system_health', 'system_dryRun', 'system_accountNextIndex', 'payment_queryFeeDetails', 'payment_queryInfo', 'dev_newBlock', 'dev_setStorage', 'dev_timeTravel', 'dev_setHead', 'dev_dryRun', 'rpc_methods']}, + "result": {"methods": rpc_methods_compat}, "id": 1 } @@ -176,5 +210,51 @@ def test_get_chain_head(self): self.assertEqual('0xec828914eca09331dad704404479e2899a971a9b5948345dc40abca4ac818f93', block_hash) +rpc_methods_compat = [ + 'author_submitExtrinsic', + 'author_submitAndWatchExtrinsic', + 'author_unwatchExtrinsic', + 'author_pendingExtrinsics', + 'chain_getBlockHash', + 'chain_getHeader', + 'chain_getBlock', + 'chain_getFinalizedHead', + 'chain_subscribeNewHead', + 'chain_subscribeFinalizedHeads', + 'chain_unsubscribeNewHead', + 'chain_subscribeNewHeads', + 'chain_unsubscribeNewHeads', + 'chain_unsubscribeFinalizedHeads', + 'state_getRuntimeVersion', + 'state_getMetadata', + 'state_getStorage', + 'state_getKeysPaged', + 'state_queryStorageAt', + 'state_call', + 'state_subscribeRuntimeVersion', + 'state_unsubscribeRuntimeVersion', + 'state_subscribeStorage', + 'state_unsubscribeStorage', + 'system_localPeerId', + 'system_nodeRoles', + 'system_localListenAddresses', + 'system_chain', + 'system_properties', + 'system_name', + 'system_version', + 'system_chainType', + 'system_health', + 'system_dryRun', + 'system_accountNextIndex', + 'payment_queryFeeDetails', + 'payment_queryInfo', + 'dev_newBlock', + 'dev_setStorage', + 'dev_timeTravel', + 'dev_setHead', + 'dev_dryRun', + 'rpc_methods' +] + if __name__ == '__main__': unittest.main() diff --git a/test/test_runtime_call.py b/test/test_runtime_call.py index 404f792e..c45a59b5 100644 --- a/test/test_runtime_call.py +++ b/test/test_runtime_call.py @@ -15,10 +15,8 @@ # limitations under the License. import unittest -from unittest.mock import MagicMock from substrateinterface import SubstrateInterface, Keypair -from substrateinterface.exceptions import StorageFunctionNotFound from test import settings