@@ -46,36 +46,36 @@ func TestTypeRegexp(t *testing.T) {
4646 {"bool[2][2][2]" , Type {Kind : reflect .Array , T : ArrayTy , Size : 2 , Type : reflect .TypeOf ([2 ][2 ][2 ]bool {}), Elem : & Type {Kind : reflect .Array , T : ArrayTy , Size : 2 , Type : reflect .TypeOf ([2 ][2 ]bool {}), Elem : & Type {Kind : reflect .Array , T : ArrayTy , Size : 2 , Type : reflect .TypeOf ([2 ]bool {}), Elem : & Type {Kind : reflect .Bool , T : BoolTy , Type : reflect .TypeOf (bool (false )), stringKind : "bool" }, stringKind : "bool[2]" }, stringKind : "bool[2][2]" }, stringKind : "bool[2][2][2]" }},
4747 {"bool[][][]" , Type {T : SliceTy , Kind : reflect .Slice , Type : reflect .TypeOf ([][][]bool {}), Elem : & Type {T : SliceTy , Kind : reflect .Slice , Type : reflect .TypeOf ([][]bool {}), Elem : & Type {T : SliceTy , Kind : reflect .Slice , Type : reflect .TypeOf ([]bool {}), Elem : & Type {Kind : reflect .Bool , T : BoolTy , Type : reflect .TypeOf (bool (false )), stringKind : "bool" }, stringKind : "bool[]" }, stringKind : "bool[][]" }, stringKind : "bool[][][]" }},
4848 {"bool[][2][]" , Type {T : SliceTy , Kind : reflect .Slice , Type : reflect .TypeOf ([][2 ][]bool {}), Elem : & Type {Kind : reflect .Array , T : ArrayTy , Size : 2 , Type : reflect .TypeOf ([2 ][]bool {}), Elem : & Type {T : SliceTy , Kind : reflect .Slice , Type : reflect .TypeOf ([]bool {}), Elem : & Type {Kind : reflect .Bool , T : BoolTy , Type : reflect .TypeOf (bool (false )), stringKind : "bool" }, stringKind : "bool[]" }, stringKind : "bool[][2]" }, stringKind : "bool[][2][]" }},
49- {"int8" , Type {Kind : reflect .Int8 , Type : int8_t , Size : 8 , T : IntTy , stringKind : "int8" }},
50- {"int16" , Type {Kind : reflect .Int16 , Type : int16_t , Size : 16 , T : IntTy , stringKind : "int16" }},
51- {"int32" , Type {Kind : reflect .Int32 , Type : int32_t , Size : 32 , T : IntTy , stringKind : "int32" }},
52- {"int64" , Type {Kind : reflect .Int64 , Type : int64_t , Size : 64 , T : IntTy , stringKind : "int64" }},
53- {"int256" , Type {Kind : reflect .Ptr , Type : big_t , Size : 256 , T : IntTy , stringKind : "int256" }},
54- {"int8[]" , Type {Kind : reflect .Slice , T : SliceTy , Type : reflect .TypeOf ([]int8 {}), Elem : & Type {Kind : reflect .Int8 , Type : int8_t , Size : 8 , T : IntTy , stringKind : "int8" }, stringKind : "int8[]" }},
55- {"int8[2]" , Type {Kind : reflect .Array , T : ArrayTy , Size : 2 , Type : reflect .TypeOf ([2 ]int8 {}), Elem : & Type {Kind : reflect .Int8 , Type : int8_t , Size : 8 , T : IntTy , stringKind : "int8" }, stringKind : "int8[2]" }},
56- {"int16[]" , Type {Kind : reflect .Slice , T : SliceTy , Type : reflect .TypeOf ([]int16 {}), Elem : & Type {Kind : reflect .Int16 , Type : int16_t , Size : 16 , T : IntTy , stringKind : "int16" }, stringKind : "int16[]" }},
57- {"int16[2]" , Type {Size : 2 , Kind : reflect .Array , T : ArrayTy , Type : reflect .TypeOf ([2 ]int16 {}), Elem : & Type {Kind : reflect .Int16 , Type : int16_t , Size : 16 , T : IntTy , stringKind : "int16" }, stringKind : "int16[2]" }},
58- {"int32[]" , Type {Kind : reflect .Slice , T : SliceTy , Type : reflect .TypeOf ([]int32 {}), Elem : & Type {Kind : reflect .Int32 , Type : int32_t , Size : 32 , T : IntTy , stringKind : "int32" }, stringKind : "int32[]" }},
59- {"int32[2]" , Type {Kind : reflect .Array , T : ArrayTy , Size : 2 , Type : reflect .TypeOf ([2 ]int32 {}), Elem : & Type {Kind : reflect .Int32 , Type : int32_t , Size : 32 , T : IntTy , stringKind : "int32" }, stringKind : "int32[2]" }},
60- {"int64[]" , Type {Kind : reflect .Slice , T : SliceTy , Type : reflect .TypeOf ([]int64 {}), Elem : & Type {Kind : reflect .Int64 , Type : int64_t , Size : 64 , T : IntTy , stringKind : "int64" }, stringKind : "int64[]" }},
61- {"int64[2]" , Type {Kind : reflect .Array , T : ArrayTy , Size : 2 , Type : reflect .TypeOf ([2 ]int64 {}), Elem : & Type {Kind : reflect .Int64 , Type : int64_t , Size : 64 , T : IntTy , stringKind : "int64" }, stringKind : "int64[2]" }},
62- {"int256[]" , Type {Kind : reflect .Slice , T : SliceTy , Type : reflect .TypeOf ([]* big.Int {}), Elem : & Type {Kind : reflect .Ptr , Type : big_t , Size : 256 , T : IntTy , stringKind : "int256" }, stringKind : "int256[]" }},
63- {"int256[2]" , Type {Kind : reflect .Array , T : ArrayTy , Size : 2 , Type : reflect .TypeOf ([2 ]* big.Int {}), Elem : & Type {Kind : reflect .Ptr , Type : big_t , Size : 256 , T : IntTy , stringKind : "int256" }, stringKind : "int256[2]" }},
64- {"uint8" , Type {Kind : reflect .Uint8 , Type : uint8_t , Size : 8 , T : UintTy , stringKind : "uint8" }},
65- {"uint16" , Type {Kind : reflect .Uint16 , Type : uint16_t , Size : 16 , T : UintTy , stringKind : "uint16" }},
66- {"uint32" , Type {Kind : reflect .Uint32 , Type : uint32_t , Size : 32 , T : UintTy , stringKind : "uint32" }},
67- {"uint64" , Type {Kind : reflect .Uint64 , Type : uint64_t , Size : 64 , T : UintTy , stringKind : "uint64" }},
68- {"uint256" , Type {Kind : reflect .Ptr , Type : big_t , Size : 256 , T : UintTy , stringKind : "uint256" }},
69- {"uint8[]" , Type {Kind : reflect .Slice , T : SliceTy , Type : reflect .TypeOf ([]uint8 {}), Elem : & Type {Kind : reflect .Uint8 , Type : uint8_t , Size : 8 , T : UintTy , stringKind : "uint8" }, stringKind : "uint8[]" }},
70- {"uint8[2]" , Type {Kind : reflect .Array , T : ArrayTy , Size : 2 , Type : reflect .TypeOf ([2 ]uint8 {}), Elem : & Type {Kind : reflect .Uint8 , Type : uint8_t , Size : 8 , T : UintTy , stringKind : "uint8" }, stringKind : "uint8[2]" }},
71- {"uint16[]" , Type {T : SliceTy , Kind : reflect .Slice , Type : reflect .TypeOf ([]uint16 {}), Elem : & Type {Kind : reflect .Uint16 , Type : uint16_t , Size : 16 , T : UintTy , stringKind : "uint16" }, stringKind : "uint16[]" }},
72- {"uint16[2]" , Type {Kind : reflect .Array , T : ArrayTy , Size : 2 , Type : reflect .TypeOf ([2 ]uint16 {}), Elem : & Type {Kind : reflect .Uint16 , Type : uint16_t , Size : 16 , T : UintTy , stringKind : "uint16" }, stringKind : "uint16[2]" }},
73- {"uint32[]" , Type {T : SliceTy , Kind : reflect .Slice , Type : reflect .TypeOf ([]uint32 {}), Elem : & Type {Kind : reflect .Uint32 , Type : uint32_t , Size : 32 , T : UintTy , stringKind : "uint32" }, stringKind : "uint32[]" }},
74- {"uint32[2]" , Type {Kind : reflect .Array , T : ArrayTy , Size : 2 , Type : reflect .TypeOf ([2 ]uint32 {}), Elem : & Type {Kind : reflect .Uint32 , Type : uint32_t , Size : 32 , T : UintTy , stringKind : "uint32" }, stringKind : "uint32[2]" }},
75- {"uint64[]" , Type {T : SliceTy , Kind : reflect .Slice , Type : reflect .TypeOf ([]uint64 {}), Elem : & Type {Kind : reflect .Uint64 , Type : uint64_t , Size : 64 , T : UintTy , stringKind : "uint64" }, stringKind : "uint64[]" }},
76- {"uint64[2]" , Type {Kind : reflect .Array , T : ArrayTy , Size : 2 , Type : reflect .TypeOf ([2 ]uint64 {}), Elem : & Type {Kind : reflect .Uint64 , Type : uint64_t , Size : 64 , T : UintTy , stringKind : "uint64" }, stringKind : "uint64[2]" }},
77- {"uint256[]" , Type {T : SliceTy , Kind : reflect .Slice , Type : reflect .TypeOf ([]* big.Int {}), Elem : & Type {Kind : reflect .Ptr , Type : big_t , Size : 256 , T : UintTy , stringKind : "uint256" }, stringKind : "uint256[]" }},
78- {"uint256[2]" , Type {Kind : reflect .Array , T : ArrayTy , Type : reflect .TypeOf ([2 ]* big.Int {}), Size : 2 , Elem : & Type {Kind : reflect .Ptr , Type : big_t , Size : 256 , T : UintTy , stringKind : "uint256" }, stringKind : "uint256[2]" }},
49+ {"int8" , Type {Kind : reflect .Int8 , Type : int8T , Size : 8 , T : IntTy , stringKind : "int8" }},
50+ {"int16" , Type {Kind : reflect .Int16 , Type : int16T , Size : 16 , T : IntTy , stringKind : "int16" }},
51+ {"int32" , Type {Kind : reflect .Int32 , Type : int32T , Size : 32 , T : IntTy , stringKind : "int32" }},
52+ {"int64" , Type {Kind : reflect .Int64 , Type : int64T , Size : 64 , T : IntTy , stringKind : "int64" }},
53+ {"int256" , Type {Kind : reflect .Ptr , Type : bigT , Size : 256 , T : IntTy , stringKind : "int256" }},
54+ {"int8[]" , Type {Kind : reflect .Slice , T : SliceTy , Type : reflect .TypeOf ([]int8 {}), Elem : & Type {Kind : reflect .Int8 , Type : int8T , Size : 8 , T : IntTy , stringKind : "int8" }, stringKind : "int8[]" }},
55+ {"int8[2]" , Type {Kind : reflect .Array , T : ArrayTy , Size : 2 , Type : reflect .TypeOf ([2 ]int8 {}), Elem : & Type {Kind : reflect .Int8 , Type : int8T , Size : 8 , T : IntTy , stringKind : "int8" }, stringKind : "int8[2]" }},
56+ {"int16[]" , Type {Kind : reflect .Slice , T : SliceTy , Type : reflect .TypeOf ([]int16 {}), Elem : & Type {Kind : reflect .Int16 , Type : int16T , Size : 16 , T : IntTy , stringKind : "int16" }, stringKind : "int16[]" }},
57+ {"int16[2]" , Type {Size : 2 , Kind : reflect .Array , T : ArrayTy , Type : reflect .TypeOf ([2 ]int16 {}), Elem : & Type {Kind : reflect .Int16 , Type : int16T , Size : 16 , T : IntTy , stringKind : "int16" }, stringKind : "int16[2]" }},
58+ {"int32[]" , Type {Kind : reflect .Slice , T : SliceTy , Type : reflect .TypeOf ([]int32 {}), Elem : & Type {Kind : reflect .Int32 , Type : int32T , Size : 32 , T : IntTy , stringKind : "int32" }, stringKind : "int32[]" }},
59+ {"int32[2]" , Type {Kind : reflect .Array , T : ArrayTy , Size : 2 , Type : reflect .TypeOf ([2 ]int32 {}), Elem : & Type {Kind : reflect .Int32 , Type : int32T , Size : 32 , T : IntTy , stringKind : "int32" }, stringKind : "int32[2]" }},
60+ {"int64[]" , Type {Kind : reflect .Slice , T : SliceTy , Type : reflect .TypeOf ([]int64 {}), Elem : & Type {Kind : reflect .Int64 , Type : int64T , Size : 64 , T : IntTy , stringKind : "int64" }, stringKind : "int64[]" }},
61+ {"int64[2]" , Type {Kind : reflect .Array , T : ArrayTy , Size : 2 , Type : reflect .TypeOf ([2 ]int64 {}), Elem : & Type {Kind : reflect .Int64 , Type : int64T , Size : 64 , T : IntTy , stringKind : "int64" }, stringKind : "int64[2]" }},
62+ {"int256[]" , Type {Kind : reflect .Slice , T : SliceTy , Type : reflect .TypeOf ([]* big.Int {}), Elem : & Type {Kind : reflect .Ptr , Type : bigT , Size : 256 , T : IntTy , stringKind : "int256" }, stringKind : "int256[]" }},
63+ {"int256[2]" , Type {Kind : reflect .Array , T : ArrayTy , Size : 2 , Type : reflect .TypeOf ([2 ]* big.Int {}), Elem : & Type {Kind : reflect .Ptr , Type : bigT , Size : 256 , T : IntTy , stringKind : "int256" }, stringKind : "int256[2]" }},
64+ {"uint8" , Type {Kind : reflect .Uint8 , Type : uint8T , Size : 8 , T : UintTy , stringKind : "uint8" }},
65+ {"uint16" , Type {Kind : reflect .Uint16 , Type : uint16T , Size : 16 , T : UintTy , stringKind : "uint16" }},
66+ {"uint32" , Type {Kind : reflect .Uint32 , Type : uint32T , Size : 32 , T : UintTy , stringKind : "uint32" }},
67+ {"uint64" , Type {Kind : reflect .Uint64 , Type : uint64T , Size : 64 , T : UintTy , stringKind : "uint64" }},
68+ {"uint256" , Type {Kind : reflect .Ptr , Type : bigT , Size : 256 , T : UintTy , stringKind : "uint256" }},
69+ {"uint8[]" , Type {Kind : reflect .Slice , T : SliceTy , Type : reflect .TypeOf ([]uint8 {}), Elem : & Type {Kind : reflect .Uint8 , Type : uint8T , Size : 8 , T : UintTy , stringKind : "uint8" }, stringKind : "uint8[]" }},
70+ {"uint8[2]" , Type {Kind : reflect .Array , T : ArrayTy , Size : 2 , Type : reflect .TypeOf ([2 ]uint8 {}), Elem : & Type {Kind : reflect .Uint8 , Type : uint8T , Size : 8 , T : UintTy , stringKind : "uint8" }, stringKind : "uint8[2]" }},
71+ {"uint16[]" , Type {T : SliceTy , Kind : reflect .Slice , Type : reflect .TypeOf ([]uint16 {}), Elem : & Type {Kind : reflect .Uint16 , Type : uint16T , Size : 16 , T : UintTy , stringKind : "uint16" }, stringKind : "uint16[]" }},
72+ {"uint16[2]" , Type {Kind : reflect .Array , T : ArrayTy , Size : 2 , Type : reflect .TypeOf ([2 ]uint16 {}), Elem : & Type {Kind : reflect .Uint16 , Type : uint16T , Size : 16 , T : UintTy , stringKind : "uint16" }, stringKind : "uint16[2]" }},
73+ {"uint32[]" , Type {T : SliceTy , Kind : reflect .Slice , Type : reflect .TypeOf ([]uint32 {}), Elem : & Type {Kind : reflect .Uint32 , Type : uint32T , Size : 32 , T : UintTy , stringKind : "uint32" }, stringKind : "uint32[]" }},
74+ {"uint32[2]" , Type {Kind : reflect .Array , T : ArrayTy , Size : 2 , Type : reflect .TypeOf ([2 ]uint32 {}), Elem : & Type {Kind : reflect .Uint32 , Type : uint32T , Size : 32 , T : UintTy , stringKind : "uint32" }, stringKind : "uint32[2]" }},
75+ {"uint64[]" , Type {T : SliceTy , Kind : reflect .Slice , Type : reflect .TypeOf ([]uint64 {}), Elem : & Type {Kind : reflect .Uint64 , Type : uint64T , Size : 64 , T : UintTy , stringKind : "uint64" }, stringKind : "uint64[]" }},
76+ {"uint64[2]" , Type {Kind : reflect .Array , T : ArrayTy , Size : 2 , Type : reflect .TypeOf ([2 ]uint64 {}), Elem : & Type {Kind : reflect .Uint64 , Type : uint64T , Size : 64 , T : UintTy , stringKind : "uint64" }, stringKind : "uint64[2]" }},
77+ {"uint256[]" , Type {T : SliceTy , Kind : reflect .Slice , Type : reflect .TypeOf ([]* big.Int {}), Elem : & Type {Kind : reflect .Ptr , Type : bigT , Size : 256 , T : UintTy , stringKind : "uint256" }, stringKind : "uint256[]" }},
78+ {"uint256[2]" , Type {Kind : reflect .Array , T : ArrayTy , Type : reflect .TypeOf ([2 ]* big.Int {}), Size : 2 , Elem : & Type {Kind : reflect .Ptr , Type : bigT , Size : 256 , T : UintTy , stringKind : "uint256" }, stringKind : "uint256[2]" }},
7979 {"bytes32" , Type {Kind : reflect .Array , T : FixedBytesTy , Size : 32 , Type : reflect .TypeOf ([32 ]byte {}), stringKind : "bytes32" }},
8080 {"bytes[]" , Type {T : SliceTy , Kind : reflect .Slice , Type : reflect .TypeOf ([][]byte {}), Elem : & Type {Kind : reflect .Slice , Type : reflect .TypeOf ([]byte {}), T : BytesTy , stringKind : "bytes" }, stringKind : "bytes[]" }},
8181 {"bytes[2]" , Type {Kind : reflect .Array , T : ArrayTy , Size : 2 , Type : reflect .TypeOf ([2 ][]byte {}), Elem : & Type {T : BytesTy , Type : reflect .TypeOf ([]byte {}), Kind : reflect .Slice , stringKind : "bytes" }, stringKind : "bytes[2]" }},
@@ -84,9 +84,9 @@ func TestTypeRegexp(t *testing.T) {
8484 {"string" , Type {Kind : reflect .String , T : StringTy , Type : reflect .TypeOf ("" ), stringKind : "string" }},
8585 {"string[]" , Type {T : SliceTy , Kind : reflect .Slice , Type : reflect .TypeOf ([]string {}), Elem : & Type {Kind : reflect .String , Type : reflect .TypeOf ("" ), T : StringTy , stringKind : "string" }, stringKind : "string[]" }},
8686 {"string[2]" , Type {Kind : reflect .Array , T : ArrayTy , Size : 2 , Type : reflect .TypeOf ([2 ]string {}), Elem : & Type {Kind : reflect .String , T : StringTy , Type : reflect .TypeOf ("" ), stringKind : "string" }, stringKind : "string[2]" }},
87- {"address" , Type {Kind : reflect .Array , Type : address_t , Size : 20 , T : AddressTy , stringKind : "address" }},
88- {"address[]" , Type {T : SliceTy , Kind : reflect .Slice , Type : reflect .TypeOf ([]common.Address {}), Elem : & Type {Kind : reflect .Array , Type : address_t , Size : 20 , T : AddressTy , stringKind : "address" }, stringKind : "address[]" }},
89- {"address[2]" , Type {Kind : reflect .Array , T : ArrayTy , Size : 2 , Type : reflect .TypeOf ([2 ]common.Address {}), Elem : & Type {Kind : reflect .Array , Type : address_t , Size : 20 , T : AddressTy , stringKind : "address" }, stringKind : "address[2]" }},
87+ {"address" , Type {Kind : reflect .Array , Type : addressT , Size : 20 , T : AddressTy , stringKind : "address" }},
88+ {"address[]" , Type {T : SliceTy , Kind : reflect .Slice , Type : reflect .TypeOf ([]common.Address {}), Elem : & Type {Kind : reflect .Array , Type : addressT , Size : 20 , T : AddressTy , stringKind : "address" }, stringKind : "address[]" }},
89+ {"address[2]" , Type {Kind : reflect .Array , T : ArrayTy , Size : 2 , Type : reflect .TypeOf ([2 ]common.Address {}), Elem : & Type {Kind : reflect .Array , Type : addressT , Size : 20 , T : AddressTy , stringKind : "address" }, stringKind : "address[2]" }},
9090 // TODO when fixed types are implemented properly
9191 // {"fixed", Type{}},
9292 // {"fixed128x128", Type{}},
@@ -252,6 +252,9 @@ func TestTypeCheck(t *testing.T) {
252252 {"bytes20" , common.Address {}, "" },
253253 {"address" , [20 ]byte {}, "" },
254254 {"address" , common.Address {}, "" },
255+ {"bytes32[]]" , "" , "invalid arg type in abi" },
256+ {"invalidType" , "" , "unsupported arg type: invalidType" },
257+ {"invalidSlice[]" , "" , "unsupported arg type: invalidSlice" },
255258 } {
256259 typ , err := NewType (test .typ )
257260 if err != nil && len (test .err ) == 0 {
0 commit comments