Skip to content

Commit

Permalink
more abi encoding tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pipermerriam committed Jul 14, 2016
1 parent 7615ae8 commit a3b09f8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions tests/contracts/test_contract_method_abi_encoding.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

ABI_A = json.loads('[{"constant":false,"inputs":[],"name":"a","outputs":[],"type":"function"}]')
ABI_B = json.loads('[{"constant":false,"inputs":[{"name":"","type":"uint256"}],"name":"a","outputs":[],"type":"function"}]')
ABI_C = json.loads('[{"constant":false,"inputs":[],"name":"a","outputs":[],"type":"function"},{"constant":false,"inputs":[{"name":"","type":"bytes32"}],"name":"a","outputs":[],"type":"function"},{"constant":false,"inputs":[{"name":"","type":"uint256"}],"name":"a","outputs":[],"type":"function"}]')


@pytest.mark.parametrize(
Expand All @@ -13,6 +14,8 @@
(ABI_A, 'a', [], '0x12345678', '0x12345678'),
(ABI_B, 'a', [0], None, '0x0000000000000000000000000000000000000000000000000000000000000000'),
(ABI_B, 'a', [1], None, '0x0000000000000000000000000000000000000000000000000000000000000001'),
(ABI_C, 'a', [1], None, '0x0000000000000000000000000000000000000000000000000000000000000001'),
(ABI_C, 'a', ['a'], None, '0x0000000000000000000000000000000000000000000000000000000000000061'),
),
)
def test_contract_abi_encoding(web3_tester, abi, method, arguments, data, expected):
Expand Down
2 changes: 1 addition & 1 deletion web3/utils/abi.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def filter_by_encodability(arguments, contract_abi):
def check_if_arguments_can_be_encoded(types, arguments):
try:
encode_abi(types, arguments)
except EncodingError:
except (EncodingError, IndexError):
return False
else:
return True

0 comments on commit a3b09f8

Please sign in to comment.