Skip to content

Commit

Permalink
fix: issue getting correct error message for contract-reverts (#1979)
Browse files Browse the repository at this point in the history
  • Loading branch information
antazoey authored Apr 2, 2024
1 parent 1e399a9 commit b969106
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/ape_ethereum/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -1147,7 +1147,7 @@ def _handle_execution_reverted(
) -> ContractLogicError:

if hasattr(exception, "args") and len(exception.args) == 2:
message = exception.args[0]
message = exception.args[0].replace("execution reverted: ", "")
data = exception.args[1]
else:
message = str(exception).split(":")[-1].strip()
Expand Down
9 changes: 9 additions & 0 deletions tests/functional/geth/test_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from eth_typing import HexStr
from evmchains import PUBLIC_CHAIN_META
from hexbytes import HexBytes
from web3.exceptions import ContractLogicError as Web3ContractLogicError
from web3.exceptions import ExtraDataLengthError
from web3.middleware import geth_poa_middleware

Expand Down Expand Up @@ -489,3 +490,11 @@ def hacked_send_call(*args, **kwargs):

actual = provider._send_call.call_args[-1]["block_identifier"]
assert actual == block_id


@geth_process_test
def test_get_virtual_machine_error(geth_provider):
expected = "__EXPECTED__"
error = Web3ContractLogicError(f"execution reverted: {expected}", "0x08c379a")
actual = geth_provider.get_virtual_machine_error(error)
assert actual.message == expected

0 comments on commit b969106

Please sign in to comment.