From 4ef9532eca208a220ccd117d72c1fb33fe8ab72c Mon Sep 17 00:00:00 2001 From: burak33bb Date: Wed, 2 Sep 2026 04:00:21 +0300 Subject: [PATCH 1/2] fix: return bytes when decoding calldata bytes --- genlayer_py/abi/calldata/decoder.py | 2 +- tests/unit/abi/__init__.py | 0 tests/unit/abi/test_calldata.py | 15 +++++++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 tests/unit/abi/__init__.py create mode 100644 tests/unit/abi/test_calldata.py diff --git a/genlayer_py/abi/calldata/decoder.py b/genlayer_py/abi/calldata/decoder.py index c993ac8..6d9bb64 100644 --- a/genlayer_py/abi/calldata/decoder.py +++ b/genlayer_py/abi/calldata/decoder.py @@ -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:] diff --git a/tests/unit/abi/__init__.py b/tests/unit/abi/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/unit/abi/test_calldata.py b/tests/unit/abi/test_calldata.py new file mode 100644 index 0000000..78c4d90 --- /dev/null +++ b/tests/unit/abi/test_calldata.py @@ -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) From 7a1f8003ad40d2a0a6507938524eb57d9546f1b0 Mon Sep 17 00:00:00 2001 From: burak33bb Date: Wed, 2 Sep 2026 04:07:05 +0300 Subject: [PATCH 2/2] test: remove empty abi package marker --- tests/unit/abi/__init__.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 tests/unit/abi/__init__.py diff --git a/tests/unit/abi/__init__.py b/tests/unit/abi/__init__.py deleted file mode 100644 index e69de29..0000000