Skip to content

Commit

Permalink
test: more test invest
Browse files Browse the repository at this point in the history
  • Loading branch information
antazoey committed Sep 28, 2023
1 parent a440b22 commit c96295f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
13 changes: 12 additions & 1 deletion tests/functional/test_accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from ape.types.signatures import recover_signer
from ape.utils.testing import DEFAULT_NUMBER_OF_TEST_ACCOUNTS
from ape_ethereum.ecosystem import ProxyType
from ape_ethereum.transactions import TransactionType
from ape_test.accounts import TestAccount
from tests.conftest import explorer_test

Expand Down Expand Up @@ -502,7 +503,7 @@ def test_declare(contract_container, sender):
@pytest.mark.parametrize(
"tx_type,params", [(0, ["gas_price"]), (2, ["max_fee", "max_priority_fee"])]
)
def test_prepare_transaction(sender, ethereum, tx_type, params):
def test_prepare_transaction_using_auto_gas(sender, ethereum, tx_type, params):
def clear_network_property_cached():
for field in ("gas_limit", "auto_gas_multiplier"):
if field in tx.provider.network.__dict__:
Expand Down Expand Up @@ -551,3 +552,13 @@ def clear_network_property_cached():
finally:
tx.provider.network.config.local.gas_limit = original_limit
clear_network_property_cached()


@pytest.mark.parametrize("type_", (TransactionType.STATIC, TransactionType.DYNAMIC))
def test_prepare_transaction_and_call_using_max_gas(type_, ethereum, sender, eth_tester_provider):
tx = ethereum.create_transaction(type=type_.value)
tx = sender.prepare_transaction(tx)
assert tx.gas_limit == eth_tester_provider.max_gas, "Test setup failed - gas limit unexpected."

actual = sender.call(tx)
assert not actual.failed
8 changes: 7 additions & 1 deletion tests/functional/test_contract_instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
MethodNonPayableError,
)
from ape.types import AddressType
from ape_ethereum.transactions import TransactionStatusEnum
from ape_ethereum.transactions import TransactionStatusEnum, TransactionType

MATCH_TEST_CONTRACT = re.compile(r"<TestContract((Sol)|(Vy))")

Expand Down Expand Up @@ -871,3 +871,9 @@ def test_sending_funds_to_non_payable_constructor_by_accountDeploy(
match="Sending funds to a non-payable constructor.",
):
owner.deploy(solidity_contract_container, 1, value="1 ether")


@pytest.mark.parametrize("type_", TransactionType)
def test_as_transaction(type_, vyper_contract_instance, owner, eth_tester_provider):
tx = vyper_contract_instance.setNumber.as_transaction(987, sender=owner, type=type_.value)
assert tx.gas_limit == eth_tester_provider.max_gas
2 changes: 1 addition & 1 deletion tests/functional/test_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ def test_get_code(eth_tester_provider, vyper_contract_instance):


@pytest.mark.parametrize("type_", TransactionType)
def test_prepare_static_tx_with_max_gas(type_, eth_tester_provider, ethereum, owner):
def test_prepare_tx_with_max_gas(type_, eth_tester_provider, ethereum, owner):
tx = ethereum.create_transaction(type=type_.value, sender=owner.address)
tx.gas_limit = None # Undo set from validator
assert tx.gas_limit is None, "Test setup failed - couldn't clear tx gas limit."
Expand Down

0 comments on commit c96295f

Please sign in to comment.