mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-17 01:13:45 +00:00
accounts/abi: fix type tests
Signed-off-by: VoR0220 <catalanor0220@gmail.com>
This commit is contained in:
parent
b7583393da
commit
29c1074140
1 changed files with 10 additions and 15 deletions
|
|
@ -107,19 +107,6 @@ func TestTypeRegexp(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
// Sample structs for struct parsing test
|
||||
|
||||
type (
|
||||
S struct {
|
||||
A *big.Int
|
||||
B []*big.Int
|
||||
C []struct {
|
||||
X *big.Int
|
||||
Y *big.Int
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
func TestStructParse(t *testing.T) {
|
||||
|
||||
for i, test := range []struct {
|
||||
|
|
@ -128,7 +115,15 @@ func TestStructParse(t *testing.T) {
|
|||
}{
|
||||
{
|
||||
unmarshalArg{Name: "s", Type: "tuple", Components: []unmarshalArg{unmarshalArg{Name: "a", Type: "uint256"}, unmarshalArg{Name: "b", Type: "uint256[]"}, unmarshalArg{Name: "c", Type: "tuple[]", Components: []unmarshalArg{unmarshalArg{Name: "x", Type: "uint256"}, unmarshalArg{Name: "y", Type: "uint256"}}}}},
|
||||
Type{Kind: reflect.Struct, T: StructTy, Type: reflect.TypeOf(S{}), stringKind: "(uint256,uint256[],(uint256,uint256)[])"},
|
||||
Type{Kind: reflect.Struct, T: StructTy, Type: reflect.TypeOf(
|
||||
struct {
|
||||
A *big.Int `json:"a"`
|
||||
B []*big.Int `json:"b"`
|
||||
C []struct {
|
||||
X *big.Int `json:"x"`
|
||||
Y *big.Int `json:"y"`
|
||||
} `json:"c"`
|
||||
}{}), stringKind: "(uint256,uint256[],(uint256,uint256)[])"},
|
||||
},
|
||||
} {
|
||||
newStruct, err := ParseStructType(test.input.Name, test.input.Components...)
|
||||
|
|
@ -136,7 +131,7 @@ func TestStructParse(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
if !reflect.DeepEqual(newStruct, test.expectedOutput) {
|
||||
t.Errorf("test %v: parsed type mismatch:\nGOT %v\nWANT %v ", i, newStruct, test.expectedOutput)
|
||||
t.Errorf("test %v: parsed type mismatch:\nGOT %v\nWANT %v ", i, spew.Sdump(typeWithoutStringer(newStruct)), spew.Sdump(typeWithoutStringer(test.expectedOutput)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue