From 7d1fd827989667b80cedcac1885e06464346b3f1 Mon Sep 17 00:00:00 2001 From: slush Date: Thu, 19 Sep 2024 15:04:14 -0500 Subject: [PATCH] chore: update tests --- src/ape_ethereum/provider.py | 2 ++ tests/functional/test_provider.py | 24 +++++++++++++++++------- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/ape_ethereum/provider.py b/src/ape_ethereum/provider.py index 3e695e70ec..89aee224f8 100644 --- a/src/ape_ethereum/provider.py +++ b/src/ape_ethereum/provider.py @@ -647,6 +647,8 @@ def get_receipt( data = { "block_number": -1, "required_confirmations": required_confirmations, + "txn_hash": txn_hash, + "status": TransactionStatusEnum.NO_ERROR, **txn, } receipt = self._create_receipt(**data) diff --git a/tests/functional/test_provider.py b/tests/functional/test_provider.py index 70e84785d3..c56f008ed1 100644 --- a/tests/functional/test_provider.py +++ b/tests/functional/test_provider.py @@ -9,7 +9,7 @@ from eth_utils import ValidationError, to_hex from hexbytes import HexBytes from requests import HTTPError -from web3.exceptions import ContractPanicError +from web3.exceptions import ContractPanicError, TimeExhausted from ape import convert from ape.exceptions import ( @@ -128,15 +128,25 @@ def test_get_receipt_exists_with_timeout(eth_tester_provider, vyper_contract_ins assert receipt_from_provider.receiver == vyper_contract_instance.address -def test_get_receipt_for_private_bypasses_confirmations( - eth_tester_provider, vyper_contract_instance, owner +def test_get_receipt_ignores_timeout_when_private( + eth_tester_provider, mock_web3, vyper_contract_instance, owner ): receipt_from_invoke = vyper_contract_instance.setNumber(888, sender=owner) - receipt_from_provider = eth_tester_provider.get_receipt( - receipt_from_invoke.txn_hash, timeout=0, private=True - ) + + real_web3 = eth_tester_provider._web3 + # mock_web3.eth = real_web3.eth + + mock_web3.eth.wait_for_transaction_receipt.side_effect = TimeExhausted + eth_tester_provider._web3 = mock_web3 + try: + receipt_from_provider = eth_tester_provider.get_receipt( + receipt_from_invoke.txn_hash, timeout=5, private=True + ) + + finally: + eth_tester_provider._web3 = real_web3 + assert receipt_from_provider.txn_hash == receipt_from_invoke.txn_hash - assert receipt_from_provider.receiver == vyper_contract_instance.address assert not receipt_from_provider.confirmed