From 4cf5f9f19aeaaf3340bc85b19f4bd936581a7858 Mon Sep 17 00:00:00 2001 From: Markus Levonyak <59229275+markuslevonyak@users.noreply.github.com> Date: Wed, 23 Oct 2024 12:08:41 +0000 Subject: [PATCH] fix: Sonic ABI file names (#52) --- ...rwarder.abi => sonic_pantos_forwarder.abi} | 0 ...om_pantos_hub.abi => sonic_pantos_hub.abi} | 0 ...antos_token.abi => sonic_pantos_token.abi} | 0 ...ard_token.abi => sonic_standard_token.abi} | 0 tests/blockchains/conftest.py | 33 ++++++++++--------- tests/blockchains/test_base.py | 10 ++++++ tests/conftest.py | 8 +++++ 7 files changed, 36 insertions(+), 15 deletions(-) rename pantos/common/blockchains/contracts/v0_1_0/{fantom_pantos_forwarder.abi => sonic_pantos_forwarder.abi} (100%) rename pantos/common/blockchains/contracts/v0_1_0/{fantom_pantos_hub.abi => sonic_pantos_hub.abi} (100%) rename pantos/common/blockchains/contracts/v0_1_0/{fantom_pantos_token.abi => sonic_pantos_token.abi} (100%) rename pantos/common/blockchains/contracts/v0_1_0/{fantom_standard_token.abi => sonic_standard_token.abi} (100%) create mode 100644 tests/conftest.py diff --git a/pantos/common/blockchains/contracts/v0_1_0/fantom_pantos_forwarder.abi b/pantos/common/blockchains/contracts/v0_1_0/sonic_pantos_forwarder.abi similarity index 100% rename from pantos/common/blockchains/contracts/v0_1_0/fantom_pantos_forwarder.abi rename to pantos/common/blockchains/contracts/v0_1_0/sonic_pantos_forwarder.abi diff --git a/pantos/common/blockchains/contracts/v0_1_0/fantom_pantos_hub.abi b/pantos/common/blockchains/contracts/v0_1_0/sonic_pantos_hub.abi similarity index 100% rename from pantos/common/blockchains/contracts/v0_1_0/fantom_pantos_hub.abi rename to pantos/common/blockchains/contracts/v0_1_0/sonic_pantos_hub.abi diff --git a/pantos/common/blockchains/contracts/v0_1_0/fantom_pantos_token.abi b/pantos/common/blockchains/contracts/v0_1_0/sonic_pantos_token.abi similarity index 100% rename from pantos/common/blockchains/contracts/v0_1_0/fantom_pantos_token.abi rename to pantos/common/blockchains/contracts/v0_1_0/sonic_pantos_token.abi diff --git a/pantos/common/blockchains/contracts/v0_1_0/fantom_standard_token.abi b/pantos/common/blockchains/contracts/v0_1_0/sonic_standard_token.abi similarity index 100% rename from pantos/common/blockchains/contracts/v0_1_0/fantom_standard_token.abi rename to pantos/common/blockchains/contracts/v0_1_0/sonic_standard_token.abi diff --git a/tests/blockchains/conftest.py b/tests/blockchains/conftest.py index 8452d21..34e770a 100644 --- a/tests/blockchains/conftest.py +++ b/tests/blockchains/conftest.py @@ -5,7 +5,6 @@ import uuid import pytest -import semantic_version # type: ignore from pantos.common.blockchains.base import BlockchainUtilities from pantos.common.blockchains.base import VersionedContractAbi @@ -34,6 +33,8 @@ _FALLBACK_BLOCKCHAIN_NODE_URL = 'https://some2.url' +_INACTIVE_BLOCKCHAINS = [Blockchain.SOLANA] + _REQUIRED_TRANSACTION_CONFIRMATIONS = 20 _TRANSACTION_NETWORK_ID = 1 @@ -63,8 +64,6 @@ _TRANSACTION_ADAPTABLE_FEE_PER_GAS = int(1.1e8) -_PROTOCOL_VERSION = semantic_version.Version('0.1.0') - @dataclasses.dataclass class Account: @@ -92,6 +91,15 @@ def blockchain(request): return request.param +@pytest.fixture( + scope='package', params=[ + blockchain for blockchain in Blockchain + if blockchain not in _INACTIVE_BLOCKCHAINS + ]) +def active_blockchain(request): + return request.param + + @pytest.fixture(scope='package') def average_block_time(): return _AVERAGE_BLOCK_TIME @@ -178,26 +186,21 @@ def transaction_adaptable_fee_per_gas(): return _TRANSACTION_ADAPTABLE_FEE_PER_GAS -@pytest.fixture(scope='package') -def protocol_version(): - return _PROTOCOL_VERSION - - @pytest.fixture(scope='package', params=ContractAbi) -def transaction_versioned_contract_abi(request, protocol_version): +def versioned_contract_abi(request, protocol_version): return VersionedContractAbi(request.param, protocol_version) @pytest.fixture def transaction_submission_request(transaction_contract_address, - transaction_versioned_contract_abi, + versioned_contract_abi, transaction_function_selector, transaction_function_args, transaction_gas, transaction_min_adaptable_fee_per_gas, transaction_max_total_fee_per_gas, transaction_amount, transaction_nonce): return BlockchainUtilities.TransactionSubmissionRequest( - transaction_contract_address, transaction_versioned_contract_abi, + transaction_contract_address, versioned_contract_abi, transaction_function_selector, transaction_function_args, transaction_gas, transaction_min_adaptable_fee_per_gas, transaction_max_total_fee_per_gas, transaction_amount, @@ -213,13 +216,13 @@ def transaction_submission_response(transaction_id, @pytest.fixture def transaction_resubmission_request( - transaction_contract_address, transaction_versioned_contract_abi, + transaction_contract_address, versioned_contract_abi, transaction_function_selector, transaction_function_args, transaction_gas, transaction_min_adaptable_fee_per_gas, transaction_max_total_fee_per_gas, transaction_amount, transaction_nonce, transaction_adaptable_fee_increase_factor): return BlockchainUtilities.TransactionResubmissionRequest( - transaction_contract_address, transaction_versioned_contract_abi, + transaction_contract_address, versioned_contract_abi, transaction_function_selector, transaction_function_args, transaction_gas, transaction_min_adaptable_fee_per_gas, transaction_max_total_fee_per_gas, transaction_amount, @@ -240,14 +243,14 @@ def transaction_resubmission_response(transaction_id, @pytest.fixture def transaction_submission_start_request( - transaction_contract_address, transaction_versioned_contract_abi, + transaction_contract_address, versioned_contract_abi, transaction_function_selector, transaction_function_args, transaction_gas, transaction_min_adaptable_fee_per_gas, transaction_max_total_fee_per_gas, transaction_amount, transaction_nonce, transaction_adaptable_fee_increase_factor, transaction_blocks_until_resubmission): return BlockchainUtilities.TransactionSubmissionStartRequest( - transaction_contract_address, transaction_versioned_contract_abi, + transaction_contract_address, versioned_contract_abi, transaction_function_selector, transaction_function_args, transaction_gas, transaction_min_adaptable_fee_per_gas, transaction_max_total_fee_per_gas, transaction_amount, diff --git a/tests/blockchains/test_base.py b/tests/blockchains/test_base.py index 2eb50f3..692bc4e 100644 --- a/tests/blockchains/test_base.py +++ b/tests/blockchains/test_base.py @@ -229,6 +229,16 @@ def test_load_contract_abi_error(mock_get_error_class, mock_get_file_name, blockchain_utilities.load_contract_abi(versioned_contract_abi) +def test_load_contract_abi_file_existence(blockchain_utilities, + active_blockchain, + versioned_contract_abi): + with unittest.mock.patch.object(blockchain_utilities, 'get_blockchain', + return_value=active_blockchain): + contract_abi = blockchain_utilities.load_contract_abi( + versioned_contract_abi) + assert len(contract_abi) > 0 + + @pytest.mark.parametrize('underpriced_submissions', [0, 1, 10]) @pytest.mark.parametrize('min_adaptable_fee_per_gas', [0, int(1e6), int(1e9)]) @unittest.mock.patch.object(BlockchainUtilities, 'submit_transaction') diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 0000000..8b7e96d --- /dev/null +++ b/tests/conftest.py @@ -0,0 +1,8 @@ +import pytest + +from pantos.common.protocol import get_supported_protocol_versions + + +@pytest.fixture(scope='session', params=get_supported_protocol_versions()) +def protocol_version(request): + return request.param