Skip to content

Commit

Permalink
added slice parser tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lmittmann committed Feb 23, 2022
1 parent 920ea66 commit 1eb62a6
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions internal/abi/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
)

var (
typeUint256, _ = abi.NewType("uint256", "", nil)
typeAddress, _ = abi.NewType("address", "", nil)
typeUint256 = abi.Type{T: abi.UintTy, Size: 256}
typeAddress = abi.Type{T: abi.AddressTy, Size: 20}
)

func TestParser(t *testing.T) {
Expand All @@ -38,6 +38,28 @@ func TestParser(t *testing.T) {
Input: "address recipient, uint256 amount",
WantArgs: abi.Arguments{{Type: typeAddress, Name: "recipient"}, {Type: typeUint256, Name: "amount"}},
},
{
Input: "uint256[]",
WantArgs: abi.Arguments{{Type: abi.Type{Elem: &typeUint256, T: abi.SliceTy}}},
},
{
Input: "uint256[][]",
WantArgs: abi.Arguments{{
Type: abi.Type{
Elem: &abi.Type{Elem: &typeUint256, T: abi.SliceTy},
T: abi.SliceTy,
},
}},
},
{
Input: "uint256[3][]",
WantArgs: abi.Arguments{{
Type: abi.Type{
Elem: &abi.Type{Elem: &typeUint256, T: abi.ArrayTy, Size: 3},
T: abi.SliceTy,
},
}},
},
{
Input: "transfer(address,uint256)",
WantArgs: abi.Arguments{{Type: typeAddress}, {Type: typeUint256}},
Expand Down

0 comments on commit 1eb62a6

Please sign in to comment.