Skip to content

Commit ec59b89

Browse files
committed
Add tests for named tuple decoder
1 parent 3891f4f commit ec59b89

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
from web3._utils.abi import named_data_tree
2+
from web3._utils.abi import check_if_arguments_can_be_encoded
3+
4+
from .test_abi import TEST_FUNCTION_ABI
5+
6+
7+
def test_named_data_tree():
8+
abi = TEST_FUNCTION_ABI['inputs']
9+
inputs = (
10+
(1, [2, 3, 4], [(5, 6), (7, 8), (9, 10)]), # Value for s
11+
(11, 12), # Value for t
12+
13, # Value for a
13+
)
14+
expected = [
15+
{'s': {'a': 1, 'b': [2, 3, 4], 'c': [{'x': 5, 'y': 6}, {'x': 7, 'y': 8}, {'x': 9, 'y': 10}]}},
16+
{'t': {'x': 11, 'y': 12}},
17+
{'a': 13},
18+
]
19+
result = [named_data_tree(a, b) for a, b in zip(abi, inputs)]
20+
assert result == expected
21+
22+
merged = {key: item[key] for item in result for key in item}
23+
assert check_if_arguments_can_be_encoded(TEST_FUNCTION_ABI, (), merged)

0 commit comments

Comments
 (0)