Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion genlayer_py/abi/calldata/decoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def impl() -> CalldataEncodable:
elif typ == consts.TYPE_BYTES:
ret_bytes = mem[:code]
mem = mem[code:]
return ret_bytes
return bytes(ret_bytes)
elif typ == consts.TYPE_STR:
ret_str = mem[:code]
mem = mem[code:]
Expand Down
15 changes: 15 additions & 0 deletions tests/unit/abi/test_calldata.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from genlayer_py.abi import calldata


def test_decode_bytes_returns_bytes():
decoded = calldata.decode(calldata.encode(b"hello"))

assert isinstance(decoded, bytes)
assert decoded == b"hello"


def test_decoded_bytes_round_trip_through_to_str():
value = b"hello"
decoded = calldata.decode(calldata.encode(value))

assert calldata.to_str(decoded) == calldata.to_str(value)