Skip to content

Commit

Permalink
chore: update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bitwise-constructs committed Sep 19, 2024
1 parent 27897d6 commit 7d1fd82
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
2 changes: 2 additions & 0 deletions src/ape_ethereum/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
24 changes: 17 additions & 7 deletions tests/functional/test_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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


Expand Down

0 comments on commit 7d1fd82

Please sign in to comment.