From 813ee4a94bcdef2b24d54ce80b70225be853d482 Mon Sep 17 00:00:00 2001 From: Marius van der Wijden Date: Tue, 7 Apr 2020 12:05:03 +0200 Subject: [PATCH] accounts/abi: added type test --- accounts/abi/abi_test.go | 1 - accounts/abi/type_test.go | 25 +++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/accounts/abi/abi_test.go b/accounts/abi/abi_test.go index c2dde1df47..a07ba0dea9 100644 --- a/accounts/abi/abi_test.go +++ b/accounts/abi/abi_test.go @@ -179,7 +179,6 @@ func TestReader(t *testing.T) { t.Error(err) } - // deep equal fails for some reason for name, expM := range exp.Methods { gotM, exist := abi.Methods[name] if !exist { diff --git a/accounts/abi/type_test.go b/accounts/abi/type_test.go index a2c78dc2e0..627185ed98 100644 --- a/accounts/abi/type_test.go +++ b/accounts/abi/type_test.go @@ -306,3 +306,28 @@ func TestTypeCheck(t *testing.T) { } } } + +func TestInternalType(t *testing.T) { + components := []ArgumentMarshaling{{Name: "a", Type: "int64"}} + internalType := "struct a.b[]" + kind := Type{ + Kind: reflect.Struct, + T: TupleTy, + Type: reflect.TypeOf(struct { + A int64 `json:"a"` + }{}), + stringKind: "(int64)", + TupleRawName: "ab[]", + TupleElems: []*Type{{Kind: reflect.Int64, T: IntTy, Type: reflect.TypeOf(int64(0)), Size: 64, stringKind: "int64"}}, + TupleRawNames: []string{"a"}, + } + + blob := "tuple" + typ, err := NewType(blob, internalType, components) + if err != nil { + t.Errorf("type %q: failed to parse type string: %v", blob, err) + } + if !reflect.DeepEqual(typ, kind) { + t.Errorf("type %q: parsed type mismatch:\nGOT %s\nWANT %s ", blob, spew.Sdump(typeWithoutStringer(typ)), spew.Sdump(typeWithoutStringer(kind))) + } +}