Skip to content

Commit

Permalink
fix: regression decoding boolean values (#2164)
Browse files Browse the repository at this point in the history
  • Loading branch information
antazoey authored Jul 1, 2024
1 parent 6ce3b49 commit d58c75a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/ape_ethereum/ecosystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -781,7 +781,7 @@ def decode_primitive_value(
elif isinstance(value, bytes):
return HexBytes(value)

elif isinstance(value, int):
elif isinstance(value, int) and not isinstance(value, bool):
# Wrap integers in a special type that allows us to compare
# them with currency-value strings.
return CurrencyValueComparable(value)
Expand Down
13 changes: 13 additions & 0 deletions tests/functional/test_ecosystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -757,6 +757,19 @@ def test_decode_returndata_returns_str_comparable_ints(ethereum):
assert isinstance(actual[0], CurrencyValueComparable)


def test_decode_returndata_bool(ethereum):
abi = MethodABI(
type="function",
name="view_method",
stateMutability="view",
inputs=[],
outputs=[ABIType(name="", type="bool", components=None, internal_type=None)],
)
raw_data = HexBytes("0x000000000000000000000000000000000000000000000000000000000000001")
actual = ethereum.decode_returndata(abi, raw_data)[0]
assert isinstance(actual, bool)


@pytest.mark.parametrize("tx_type", TransactionType)
def test_create_transaction_uses_network_gas_limit(tx_type, ethereum, eth_tester_provider, owner):
tx = ethereum.create_transaction(type=tx_type.value, sender=owner.address)
Expand Down

0 comments on commit d58c75a

Please sign in to comment.