Skip to content
This repository was archived by the owner on May 23, 2023. It is now read-only.

Commit 0ab9579

Browse files
author
Jan Xie
committed
fix int type encoding in abi
1 parent f67a025 commit 0ab9579

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

ethereum/abi.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ class ValueOutOfBounds(EncodingError):
149149
def decint(n):
150150
if isinstance(n, str):
151151
n = utils.to_string(n)
152-
if is_numeric(n) and n < 2**256 and n > -2**255:
152+
if is_numeric(n) and n < 2**256 and n >= -2**255:
153153
return n
154154
elif is_numeric(n):
155155
raise EncodingError("Number out of range: %r" % n)

ethereum/tests/test_abi.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ def test_abi_encode_signed_int():
1818
assert abi.decode_abi(['int8'], abi.encode_abi(['int8'], [-1]))[0] == -1
1919

2020
def test_abi_encode_single_int():
21+
assert abi.encode_single(['int', '256', []], -2**255) == (b'\x80'+b'\x00'*31)
22+
2123
assert abi.encode_single(['int', '8', []], -128) == zpad(b'\x80', 32)
2224
with pytest.raises(abi.ValueOutOfBounds):
2325
assert abi.encode_single(['int', '8', []], -129)

0 commit comments

Comments
 (0)