Skip to content

Commit

Permalink
test: add test
Browse files Browse the repository at this point in the history
  • Loading branch information
antazoey committed Aug 8, 2024
1 parent aae4ee8 commit e442e24
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/ape_ethereum/trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,8 @@ def _return_value_from_enriched_calltree(self) -> Any:

# If enriching too much, Ethereum places regular values in a key
# named "unenriched_return_values".
if unenriched_return_values := calltree.get("unenriched_return_values"):
return unenriched_return_values
if "unenriched_return_values" in calltree:
return calltree["unenriched_return_values"]

if raw_return_data := calltree.get("returndata"):
if abi := self.root_method_abi:
Expand Down
14 changes: 14 additions & 0 deletions tests/functional/test_trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,20 @@ def test_revert_message_empty(owner):
assert trace.revert_message is None


def test_return_value_never_enriched(owner, solidity_contract_instance):
tx = solidity_contract_instance.setNumber(7234721, sender=owner)
trace = TransactionTrace.model_validate({"transaction_hash": tx.txn_hash})

# Hack in criteria to cause it to look for a revert message more.
returndata = "0x0000000000000000000000000000000000000000000000bdbc41e0348b300000"
trace._enriched_calltree = {"failed": True, "returndata": returndata}

actual = trace.return_value
expected = 3500000000000000000000 # returndata as an int.
assert actual == expected



def test_enriched_calltree_adds_missing_gas(simple_trace_cls):
compute_gas = 1234
base_gas = 21_000
Expand Down

0 comments on commit e442e24

Please sign in to comment.