Skip to content

Commit

Permalink
Bump requirements, upate tests, update regexes
Browse files Browse the repository at this point in the history
Signed-off-by: Lefteris Karapetsas <[email protected]>
  • Loading branch information
LefterisJP committed Feb 26, 2024
1 parent 95f9ac3 commit a3b19d5
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 19 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/onpush.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -22,4 +22,4 @@ jobs:
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
- name: Verify changes
run: |
pytest tests
python -m pytest tests
6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
eth-utils==2.1.0
pytest==7.1.3
eth-hash[pycryptodome]==0.5.1
eth-utils==4.0.0
pytest==8.0.2
eth-hash[pycryptodome]==0.6.0
Empty file removed tests/__init__.py
Empty file.
9 changes: 4 additions & 5 deletions tests/test_correct_entries.py
Original file line number Diff line number Diff line change
@@ -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]
Expand Down Expand Up @@ -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
assert to_checksum_address(address) == address
4 changes: 3 additions & 1 deletion validator/checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
16 changes: 8 additions & 8 deletions validator/utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import json
from pathlib import Path
import re
from pathlib import Path


def get_latest_version():
Expand All @@ -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\((.*?),(.*?),(.*?),(.*?),(.*?),([^\)]*?),([^\)]*?)\).*')
}
"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\((.*?),(.*?),(.*?),(.*?),(.*?),([^,]*?),([^,]*?)\).*')
}

0 comments on commit a3b19d5

Please sign in to comment.