Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 319a795

Browse files
committedMar 12, 2024
Add regression test for tuple parsing
1 parent 9beac09 commit 319a795

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed
 

‎test/abi/function_selector_test.exs

+32
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,38 @@ defmodule ABI.FunctionSelectorTest do
345345
assert expected_type == selector.types
346346
end
347347

348+
test "parses fixed 2D array of tuples" do
349+
function = %{
350+
"inputs" => [],
351+
"name" => "createTupleArray",
352+
"outputs" => [
353+
%{
354+
"components" => [
355+
%{
356+
"internalType" => "uint256",
357+
"name" => "element1",
358+
"type" => "uint256"
359+
},
360+
%{"internalType" => "bool", "name" => "element2", "type" => "bool"}
361+
],
362+
"internalType" => "struct StorageB.MyTuple[2][]",
363+
"name" => "",
364+
"type" => "tuple[2][]"
365+
}
366+
],
367+
"stateMutability" => "pure",
368+
"type" => "function"
369+
}
370+
371+
expected = [
372+
array: {:array, {:tuple, [{:uint, 256}, :bool]}, 2}
373+
]
374+
375+
selector = FunctionSelector.parse_specification_item(function)
376+
377+
assert expected == selector.returns
378+
end
379+
348380
test "with stateMutability set" do
349381
~w(pure view nonpayable payable)
350382
|> Enum.zip(~w(pure view non_payable payable)a)

0 commit comments

Comments
 (0)
Please sign in to comment.