From e2973474d40b3b467f4f01427e1f0be9227941db Mon Sep 17 00:00:00 2001 From: rjl493456442 Date: Sun, 15 Mar 2020 14:30:07 +0800 Subject: [PATCH] accounts/abi: fix unit tests --- accounts/abi/abi_test.go | 10 +++++----- accounts/abi/method.go | 11 ++++++++--- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/accounts/abi/abi_test.go b/accounts/abi/abi_test.go index c3a0e6c7c9..352006cf5f 100644 --- a/accounts/abi/abi_test.go +++ b/accounts/abi/abi_test.go @@ -61,10 +61,10 @@ func TestReader(t *testing.T) { exp := ABI{ Methods: map[string]Method{ "balance": { - "balance", "balance", "view", false, false, nil, nil, + "balance", "balance", "view", false, false, false, false, nil, nil, }, "send": { - "send", "send", "", false, false, []Argument{ + "send", "send", "", false, false, false, false, []Argument{ {"amount", Uint256, false}, }, nil, }, @@ -173,7 +173,7 @@ func TestTestSlice(t *testing.T) { func TestMethodSignature(t *testing.T) { String, _ := NewType("string", "", nil) - m := Method{"foo", "foo", "", false, false, []Argument{{"bar", String, false}, {"baz", String, false}}, nil} + m := Method{"foo", "foo", "", false, false, false, false, []Argument{{"bar", String, false}, {"baz", String, false}}, nil} exp := "foo(string,string)" if m.Sig() != exp { t.Error("signature mismatch", exp, "!=", m.Sig()) @@ -185,7 +185,7 @@ func TestMethodSignature(t *testing.T) { } uintt, _ := NewType("uint256", "", nil) - m = Method{"foo", "foo", "", false, false, []Argument{{"bar", uintt, false}}, nil} + m = Method{"foo", "foo", "", false, false, false, false, []Argument{{"bar", uintt, false}}, nil} exp = "foo(uint256)" if m.Sig() != exp { t.Error("signature mismatch", exp, "!=", m.Sig()) @@ -204,7 +204,7 @@ func TestMethodSignature(t *testing.T) { {Name: "y", Type: "int256"}, }}, }) - m = Method{"foo", "foo", "", false, false, []Argument{{"s", s, false}, {"bar", String, false}}, nil} + m = Method{"foo", "foo", "", false, false, false, false, []Argument{{"s", s, false}, {"bar", String, false}}, nil} exp = "foo((int256,int256[],(int256,int256)[],(int256,int256)[2]),string)" if m.Sig() != exp { t.Error("signature mismatch", exp, "!=", m.Sig()) diff --git a/accounts/abi/method.go b/accounts/abi/method.go index 91b7c461f1..23c1004466 100644 --- a/accounts/abi/method.go +++ b/accounts/abi/method.go @@ -41,10 +41,15 @@ type Method struct { // * foo(uint,uint) // The method name of the first one will be resolved as foo while the second one // will be resolved as foo0. - Name string - RawName string // RawName is the raw method name parsed from ABI - StateMutability string // Indicates the mutability state of method + Name string + RawName string // RawName is the raw method name parsed from ABI + // StateMutability indicates the mutability state of method, + // the default value is nonpayable. It can be empty if the abi + // is generated by legacy compiler. + StateMutability string + + // Legacy indicators generated by compiler before v0.6.0 Constant bool Payable bool