Skip to content

Commit

Permalink
test: abi
Browse files Browse the repository at this point in the history
  • Loading branch information
antazoey committed Aug 21, 2024
1 parent 38746f4 commit 729512d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
3 changes: 3 additions & 0 deletions ape_alchemy/trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ def return_value(self) -> Any:
if abi := self.root_method_abi:
return self._ecosystem.decode_returndata(abi, output_bytes)

# ABI is not known.
return output_bytes

return None

@cached_property
Expand Down
14 changes: 14 additions & 0 deletions tests/test_trace.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import pytest
from ape import chain, networks
from ethpm_types import ContractType


@pytest.fixture(autouse=True)
Expand All @@ -19,6 +20,19 @@ def test_revert_message():
def test_return_value():
txn_hash = "0xe0897d735b67893648b20085ecef16232733425329df844292d5b2774cca436b"
receipt = chain.history[txn_hash]

# Ensure the ABI is cached so we can decode the return value.
abi = [
{
"type": "function",
"name": "submit",
"stateMutability": "payable",
"inputs": [{"name": "_referral", "type": "address"}],
"outputs": [{"name": "", "type": "uint256"}],
}
]
chain.contracts[receipt.receiver] = ContractType(abi=abi)

actual = receipt.return_value
expected = 1244617160572980465
assert actual == expected

0 comments on commit 729512d

Please sign in to comment.