Skip to content

Commit

Permalink
chore: adds more test cases and suppors tuple
Browse files Browse the repository at this point in the history
  • Loading branch information
slush committed Sep 3, 2024
1 parent 1836aa4 commit 7f540ed
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/ape/managers/converters.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import re
from collections.abc import Sequence
from collections.abc import Iterable, Sequence
from datetime import datetime, timedelta, timezone
from decimal import Decimal
from typing import Any, Union
Expand Down Expand Up @@ -76,7 +76,7 @@ class HexListConverter(ConverterAPI):
"""

def is_convertible(self, value: Any) -> bool:
return isinstance(value, list) and all(is_hex(v) or isinstance(v, bytes) for v in value)
return isinstance(value, Iterable) and all(isinstance(v, bytes) or is_hex(v) for v in value)

def convert(self, value: Any) -> bytes:
return HexBytes(b"".join(HexBytes(v) for v in value))
Expand Down
11 changes: 10 additions & 1 deletion tests/functional/test_contract_instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -992,7 +992,16 @@ def test_as_transaction(tx_type, vyper_contract_instance, owner, eth_tester_prov
assert tx.gas_limit == eth_tester_provider.max_gas


@pytest.mark.parametrize("calldata", ("0x123456", ["0x123456", "0xabcd"]))
@pytest.mark.parametrize(
"calldata",
(
"0x123456",
HexBytes("0x123456"),
["0x123456", "0xabcd"],
[HexBytes("0x123456"), "0xabcd"],
("0x123456", "0xabcd"),
),
)
def test_calldata_arg(calldata, contract_instance, owner):
tx = contract_instance.functionWithCalldata(calldata, sender=owner)
assert not tx.failed

0 comments on commit 7f540ed

Please sign in to comment.