Skip to content

Commit 7e24a3a

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

File tree

1 file changed

+28
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)