Skip to content

Commit

Permalink
Fix failing tests and use 1559 defaults for test params
Browse files Browse the repository at this point in the history
Fixed tests that were failing from the implementation of the new EIP-1559 fields (maxFeePerGas and maxPriorityFeePerGas). Updated most of our existing tests to use these new fields in order to encourage their use / be updated to the new standard.
  • Loading branch information
fselmo committed Jun 30, 2021
1 parent 78860fe commit 9e4149a
Show file tree
Hide file tree
Showing 7 changed files with 203 additions and 90 deletions.
1 change: 1 addition & 0 deletions newsfragments/2053.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix broken tests and use the new 1559 params for most of our test transactions.
18 changes: 18 additions & 0 deletions tests/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,24 @@
)


def pytest_collection_modifyitems(items):
"""
Certain tests have their context dirtied by other tests. We can somewhat
control when these tests are run by overriding this pytest hook and customizing
when certain tests are run. This may help a test to pass due to a cleaner context.
"""

test_names_to_append_to_start = [
'test_eth_get_logs_with_logs',
'test_eth_call_old_contract_state',
]
for index, item in enumerate(items):
test_name = item.name if "[" not in item.name else item.name[:item.name.find("[")]
if test_name in test_names_to_append_to_start:
test_item = items.pop(index)
items.insert(0, test_item)


@pytest.fixture(scope="module")
def math_contract_factory(web3):
contract_factory = web3.eth.contract(abi=MATH_ABI, bytecode=MATH_BYTECODE)
Expand Down
25 changes: 9 additions & 16 deletions tests/integration/go_ethereum/common.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# from concurrent.futures._base import (
# TimeoutError as FuturesTimeoutError,
# )
import pytest

from web3._utils.module_testing import ( # noqa: F401
Expand All @@ -20,20 +17,16 @@ def _check_web3_clientVersion(self, client_version):


class GoEthereumEthModuleTest(EthModuleTest):
# @pytest.mark.xfail(
# strict=False,
# raises=FuturesTimeoutError,
# reason='Sometimes a TimeoutError is hit when waiting for the txn to be mined',
# )
@pytest.mark.skip(reason="London TODO: crashes on [address_conversion_func1]")
@pytest.mark.xfail(
strict=False,
reason='Sometimes a TimeoutError is hit when waiting for the txn to be mined',
)
def test_eth_replace_transaction_already_mined(self, web3, unlocked_account_dual_type):
web3.geth.miner.start()
super().test_eth_replace_transaction_already_mined(web3, unlocked_account_dual_type)
web3.geth.miner.stop()

@pytest.mark.skip(reason="London TODO: pending call isn't found")
def test_eth_call_old_contract_state(self, web3, math_contract, unlocked_account):
super().test_eth_call_old_contract_state(web3, math_contract, unlocked_account)
try:
web3.geth.miner.start()
super().test_eth_replace_transaction_already_mined(web3, unlocked_account_dual_type)
finally:
web3.geth.miner.stop()

@pytest.mark.xfail(reason='eth_signTypedData has not been released in geth')
def test_eth_sign_typed_data(self, web3, unlocked_account_dual_type):
Expand Down
48 changes: 36 additions & 12 deletions tests/integration/test_ethereum_tester.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,18 +272,34 @@ def test_eth_getBlockByHash_pending(
assert block['hash'] is not None

@disable_auto_mine
@pytest.mark.xfail(reason='EIP 1559 is not implemented on eth-tester')
def test_eth_get_transaction_receipt_unmined(self, eth_tester, web3, unlocked_account):
super().test_eth_get_transaction_receipt_unmined(web3, unlocked_account)

@disable_auto_mine
def test_eth_replaceTransaction_deprecated(self, eth_tester, web3, unlocked_account):
super().test_eth_replaceTransaction_deprecated(web3, unlocked_account)
def test_eth_replace_transaction_legacy(self, eth_tester, web3, unlocked_account):
super().test_eth_replace_transaction_legacy(web3, unlocked_account)

@disable_auto_mine
@pytest.mark.xfail(reason='EIP 1559 is not implemented on eth-tester')
def test_eth_replace_transaction(self, eth_tester, web3, unlocked_account):
super().test_eth_replace_transaction(web3, unlocked_account)

@pytest.mark.xfail(reason='EIP 1559 is not implemented on eth-tester')
def test_eth_replace_transaction_underpriced(self, web3, emitter_contract_address):
super().test_eth_replace_transaction_underpriced(web3, emitter_contract_address)

@disable_auto_mine
@pytest.mark.xfail(reason='EIP 1559 is not implemented on eth-tester')
def test_eth_replaceTransaction_deprecated(self, eth_tester, web3, unlocked_account):
super().test_eth_replaceTransaction_deprecated(web3, unlocked_account)

@pytest.mark.xfail(reason='EIP 1559 is not implemented on eth-tester')
def test_eth_replace_transaction_already_mined(self, web3, emitter_contract_address):
super().test_eth_replace_transaction_already_mined(web3, emitter_contract_address)

@disable_auto_mine
@pytest.mark.xfail(reason='EIP 1559 is not implemented on eth-tester')
def test_eth_replace_transaction_incorrect_nonce(self, eth_tester, web3, unlocked_account):
super().test_eth_replace_transaction_incorrect_nonce(web3, unlocked_account)

Expand Down Expand Up @@ -429,24 +445,32 @@ def test_eth_estimate_gas_revert_without_msg(self, web3, revert_contract, unlock
web3.eth.estimate_gas(txn_params)

@pytest.mark.xfail(reason='EIP 1559 is not implemented on eth-tester')
def test_1559_default_fees(self, web3, emitter_contract_address):
super().test_1559_default_fees(web3, emitter_contract_address)
def test_eth_send_transaction(self, web3, emitter_contract_address):
super().test_eth_send_transaction(web3, emitter_contract_address)

@pytest.mark.xfail(reason='EIP 1559 is not implemented on eth-tester')
def test_eth_sendTransaction_deprecated(self, web3, emitter_contract_address):
super().test_eth_sendTransaction_deprecated(web3, emitter_contract_address)

@pytest.mark.xfail(reason='EIP 1559 is not implemented on eth-tester')
def test_eth_send_transaction_with_nonce(self, web3, emitter_contract_address):
super().test_eth_send_transaction_with_nonce(web3, emitter_contract_address)

@pytest.mark.xfail(reason='EIP 1559 is not implemented on eth-tester')
def test_1559_canonical(self, web3, emitter_contract_address):
super().test_1559_canonical(web3, emitter_contract_address)
def test_eth_send_transaction_default_fees(self, web3, emitter_contract_address):
super().test_eth_send_transaction_default_fees(web3, emitter_contract_address)

@pytest.mark.xfail(reason='EIP 1559 is not implemented on eth-tester')
def test_1559_hex_fees(self, web3, emitter_contract_address):
super().test_1559_hex_fees(web3, emitter_contract_address)
def test_eth_send_transaction_hex_fees(self, web3, emitter_contract_address):
super().test_eth_send_transaction_hex_fees(web3, emitter_contract_address)

@pytest.mark.xfail(reason='EIP 1559 is not implemented on eth-tester')
def test_1559_no_gas(self, web3, emitter_contract_address):
super().test_1559_no_gas(web3, emitter_contract_address)
def test_eth_send_transaction_no_gas(self, web3, emitter_contract_address):
super().test_eth_send_transaction_no_gas(web3, emitter_contract_address)

@pytest.mark.xfail(reason='EIP 1559 is not implemented on eth-tester')
def test_1559_no_max_fee(self, web3, emitter_contract_address):
super().test_1559_no_max_fee(web3, emitter_contract_address)
def test_eth_send_transaction_no_max_fee(self, web3, emitter_contract_address):
super().test_eth_send_transaction_no_max_fee(web3, emitter_contract_address)


class TestEthereumTesterVersionModule(VersionModuleTest):
Expand Down
Loading

0 comments on commit 9e4149a

Please sign in to comment.