Skip to content

Commit

Permalink
fix: Sonic ABI file names (#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
markuslevonyak authored Oct 23, 2024
1 parent 38edd9e commit 4cf5f9f
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 15 deletions.
33 changes: 18 additions & 15 deletions tests/blockchains/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -34,6 +33,8 @@

_FALLBACK_BLOCKCHAIN_NODE_URL = 'https://some2.url'

_INACTIVE_BLOCKCHAINS = [Blockchain.SOLANA]

_REQUIRED_TRANSACTION_CONFIRMATIONS = 20

_TRANSACTION_NETWORK_ID = 1
Expand Down Expand Up @@ -63,8 +64,6 @@

_TRANSACTION_ADAPTABLE_FEE_PER_GAS = int(1.1e8)

_PROTOCOL_VERSION = semantic_version.Version('0.1.0')


@dataclasses.dataclass
class Account:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down
10 changes: 10 additions & 0 deletions tests/blockchains/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
8 changes: 8 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 4cf5f9f

Please sign in to comment.