diff --git a/.github/workflows/onpush.yaml b/.github/workflows/onpush.yaml index a7732a1..a0c3c48 100644 --- a/.github/workflows/onpush.yaml +++ b/.github/workflows/onpush.yaml @@ -10,7 +10,7 @@ jobs: - name: Set up python uses: actions/setup-python@v2 with: - python-version: '3.10.8' + python-version: '3.11.7' - name: Install dependencies run: | python3 -m pip install --upgrade pip setuptools wheel @@ -22,4 +22,4 @@ jobs: key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} - name: Verify changes run: | - pytest tests + python -m pytest tests diff --git a/requirements.txt b/requirements.txt index 94e521b..e84cd56 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,3 @@ -eth-utils==2.1.0 -pytest==7.1.3 -eth-hash[pycryptodome]==0.5.1 \ No newline at end of file +eth-utils==4.0.0 +pytest==8.0.2 +eth-hash[pycryptodome]==0.6.0 diff --git a/tests/__init__.py b/tests/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/tests/test_correct_entries.py b/tests/test_correct_entries.py index b6eb827..0182be7 100644 --- a/tests/test_correct_entries.py +++ b/tests/test_correct_entries.py @@ -1,13 +1,13 @@ import json +import warnings from pathlib import Path import pytest from eth_utils.address import to_checksum_address -import warnings - from validator.checker import UpdateChecker from validator.utils import get_latest_version + @pytest.fixture(name='schema_versions') def fixture_schema_version(): root_dir = infojson = Path(__file__).parents[1] @@ -51,8 +51,7 @@ def test_valid_identifiers_mappings(version, schema_versions): try: eip_pos = line.index('eip155') except ValueError: - warnings.warn(f'Non evm mapping: {line}') - continue + continue # this is not an evm token, can skip address = line[eip_pos:].split(':')[-1].strip().replace('");', '') - assert to_checksum_address(address) == address \ No newline at end of file + assert to_checksum_address(address) == address diff --git a/validator/checker.py b/validator/checker.py index 3a4d142..2f81f7c 100644 --- a/validator/checker.py +++ b/validator/checker.py @@ -5,7 +5,9 @@ import re from typing import NamedTuple, NewType, Optional, Tuple, Union + from eth_utils import is_checksum_address + from validator.utils import REGEX_ASSETS_V2, REGEX_ASSETS_V3 T_Timestamp = int @@ -252,7 +254,7 @@ def _parse_full_insert(self, insert_text: str, schema_version: int) -> AssetData """ asset_data = self._parse_asset_data(insert_text, schema_version) evm_data = { - 'foked': None, + 'forked': None, 'address': None, 'decimals': None, 'protocol': None, diff --git a/validator/utils.py b/validator/utils.py index ea47802..72bf626 100644 --- a/validator/utils.py +++ b/validator/utils.py @@ -1,6 +1,6 @@ import json -from pathlib import Path import re +from pathlib import Path def get_latest_version(): @@ -13,13 +13,13 @@ def get_latest_version(): REGEX_ASSETS_V2 = { - "assets_re": re.compile(r'.*INSERT +INTO +assets\( *identifier *, *type *, *name *, *symbol *, *started *, *swapped_for *, *coingecko *, *cryptocompare *, *details_reference *\) +VALUES\((.*?),(.*?),(.*?),(.*?),(.*?),(.*?),(.*?),(.*?),(.*?)\).*?'), - "ethereum_tokens_re": re.compile(r'.*INSERT +INTO +ethereum_tokens\( *address *, *decimals *, *protocol *\) +VALUES\((.*?),(.*?),(.*?)\).*'), - "common_asset_details_re": re.compile(r'.*INSERT +INTO +common_asset_details\( *asset_id *, *forked *\) +VALUES\((.*?),(.*?)\).*') + "assets_re": re.compile(r'.*INSERT +INTO +assets\( *identifier *, *type *, *name *, *symbol *, *started *, *swapped_for *, *coingecko *, *cryptocompare *, *details_reference *\) *VALUES\((.*?),(.*?),(.*?),(.*?),(.*?),(.*?),(.*?),(.*?),(.*?)\).*?'), + "ethereum_tokens_re": re.compile(r'.*INSERT +INTO +ethereum_tokens\( *address *, *decimals *, *protocol *\) *VALUES\((.*?),(.*?),(.*?)\).*'), + "common_asset_details_re": re.compile(r'.*INSERT +INTO +common_asset_details\( *asset_id *, *forked *\) *VALUES\((.*?),(.*?)\).*') } REGEX_ASSETS_V3 = { - "assets_re": re.compile(r'.*INSERT +INTO +assets\( *identifier *, *name *, *type *\) +VALUES\(([^\)]*?),([^\)]*?),([^\)]*?)\).*?'), - "ethereum_tokens_re": re.compile(r'.*INSERT +INTO +evm_tokens\( *identifier *, *token_kind *, *chain *, *address *, *decimals *, *protocol *\) +VALUES\(([^\)]*?),([^\)]*?),([^\)]*?),([^\)]*?),([^\)]*?),([^\)]*?)\).*'), - "common_asset_details_re": re.compile(r'.*INSERT +INTO +common_asset_details\( *identifier *, *symbol *, *coingecko *, *cryptocompare *, *forked *, *started *, *swapped_for *\) +VALUES\((.*?),(.*?),(.*?),(.*?),(.*?),([^\)]*?),([^\)]*?)\).*') -} \ No newline at end of file + "assets_re": re.compile(r'.*INSERT +INTO +assets\( *identifier *, *name *, *type *\) *VALUES\(([^,]*?),([^,]*?),([^,]*?)\).*?'), + "ethereum_tokens_re": re.compile(r'.*INSERT +INTO +evm_tokens\( *identifier *, *token_kind *, *chain *, *address *, *decimals *, *protocol *\) *VALUES\(([^,]*?),([^,]*?),([^,]*?),([^,]*?),([^,]*?),([^,]*?)\).*'), + "common_asset_details_re": re.compile(r'.*INSERT +INTO +common_asset_details\( *identifier *, *symbol *, *coingecko *, *cryptocompare *, *forked *, *started *, *swapped_for *\) *VALUES\((.*?),(.*?),(.*?),(.*?),(.*?),([^,]*?),([^,]*?)\).*') +}