Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the EVM tokens for 1.33.0 that are in zksync lite bridge #133

Merged
merged 3 commits into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
56 changes: 45 additions & 11 deletions tests/test_correct_entries.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import json
import re
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 @@ -35,10 +35,12 @@ def test_valid_sql_sentences(version, schema_versions):


@pytest.mark.parametrize('version', range(1, get_latest_version() + 1))
def test_valid_identifiers_mappings(version, schema_versions):
"""Test that identifiers have checksummed addresses in multiassets mappings"""
def test_asset_collection_mappings(version, schema_versions):
"""Test that the multiassets mappings update files are valid"""
root_dir = Path(__file__).parents[1]
upgrade = root_dir / 'updates' / str(version) / 'asset_collections_mappings_updates.sql'
# keep this re in sync with the one in the main repo
multiasset_mappings_re = re.compile(r'.*INSERT +INTO +multiasset_mappings\( *collection_id *, *asset *\) *VALUES +\(([^,]*?), *"([^,]+?)"\).*?') # noqa: E501

if upgrade.exists() is False:
return
Expand All @@ -47,12 +49,44 @@ def test_valid_identifiers_mappings(version, schema_versions):
for line in f.readlines():
if '*' in line:
continue
print('---', line)
try:
eip_pos = line.index('eip155')
except ValueError:
warnings.warn(f'Non evm mapping: {line}')

mappings_match = multiasset_mappings_re.match(line)
assert mappings_match is not None
groups = mappings_match.groups()
assert len(groups) == 2

lineid = int(groups[0])
assert lineid >= 0

identifier = groups[1]
assert isinstance(identifier, str)
if identifier.startswith('eip155'):
address = identifier.split(':')[-1]
assert to_checksum_address(address) == address


@pytest.mark.parametrize('version', range(1, get_latest_version() + 1))
def test_asset_collections_updates(version, schema_versions):
"""Test that the asset collections update files are valid"""
root_dir = Path(__file__).parents[1]
upgrade = root_dir / 'updates' / str(version) / 'asset_collections_updates.sql'
# keep this re in sync with the one in the main repo
assets_collection_re = re.compile(r'.*INSERT +INTO +asset_collections\( *id *, *name *, *symbol *\) *VALUES +\(([^,]*?),([^,]*?),([^,]*?)\).*?') # noqa: E501

if upgrade.exists() is False:
return

with open(upgrade) as f:
for line in f.readlines():
if '*' in line:
continue

address = line[eip_pos:].split(':')[-1].strip().replace('");', '')
assert to_checksum_address(address) == address
collections_match = assets_collection_re.match(line)
assert collections_match is not None
groups = collections_match.groups()
assert len(groups) == 3

lineid = int(groups[0])
assert lineid >= 0
assert isinstance(groups[1], str) # collection name
assert isinstance(groups[2], str) # collection symbol
2 changes: 1 addition & 1 deletion updates/23/updates.sql
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ INSERT INTO assets(identifier, name, type) VALUES("STRK", "Starknet", "W"); INSE
INSERT INTO assets(identifier, name, type) VALUES("eip155:100/erc20:0x6C76971f98945AE98dD7d4DFcA8711ebea946eA6", "Wrapped liquid staked Ether 2.0 from Mainnet", "C"); INSERT INTO evm_tokens(identifier, token_kind, chain, address, decimals, protocol) VALUES("eip155:100/erc20:0x6C76971f98945AE98dD7d4DFcA8711ebea946eA6", "A", 100, "0x6C76971f98945AE98dD7d4DFcA8711ebea946eA6", 18, NULL); INSERT INTO common_asset_details(identifier, symbol, coingecko, cryptocompare, forked, started, swapped_for) VALUES("eip155:100/erc20:0x6C76971f98945AE98dD7d4DFcA8711ebea946eA6", "wstETH", "wrapped-steth", "WSTETH", NULL, 1675777350, NULL);
*
INSERT INTO assets(identifier, name, type) VALUES("eip155:42161/erc20:0x1509706a6c66CA549ff0cB464de88231DDBe213B", "Aura", "C"); INSERT INTO evm_tokens(identifier, token_kind, chain, address, decimals, protocol) VALUES("eip155:42161/erc20:0x1509706a6c66CA549ff0cB464de88231DDBe213B", "A", 42161, "0x1509706a6c66CA549ff0cB464de88231DDBe213B", 18, NULL); INSERT INTO common_asset_details(identifier, symbol, coingecko, cryptocompare, forked, started, swapped_for) VALUES("eip155:42161/erc20:0x1509706a6c66CA549ff0cB464de88231DDBe213B", "AURA", "aura-finance", "AURA", NULL, 1686742265, NULL);
*
*
Loading
Loading