From 29c1074140e8b267d528ee0c91170f07ce1dded7 Mon Sep 17 00:00:00 2001 From: VoR0220 Date: Thu, 16 Nov 2017 15:43:32 -0500 Subject: [PATCH] accounts/abi: fix type tests Signed-off-by: VoR0220 --- accounts/abi/type_test.go | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/accounts/abi/type_test.go b/accounts/abi/type_test.go index 5e875f94a5..4e95ec97e5 100644 --- a/accounts/abi/type_test.go +++ b/accounts/abi/type_test.go @@ -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))) } } }