accounts/abi: fix unit tests

This commit is contained in:
rjl493456442 2020-03-15 14:30:07 +08:00
parent 763de1e1ce
commit e2973474d4
2 changed files with 13 additions and 8 deletions

View file

@ -61,10 +61,10 @@ func TestReader(t *testing.T) {
exp := ABI{ exp := ABI{
Methods: map[string]Method{ Methods: map[string]Method{
"balance": { "balance": {
"balance", "balance", "view", false, false, nil, nil, "balance", "balance", "view", false, false, false, false, nil, nil,
}, },
"send": { "send": {
"send", "send", "", false, false, []Argument{ "send", "send", "", false, false, false, false, []Argument{
{"amount", Uint256, false}, {"amount", Uint256, false},
}, nil, }, nil,
}, },
@ -173,7 +173,7 @@ func TestTestSlice(t *testing.T) {
func TestMethodSignature(t *testing.T) { func TestMethodSignature(t *testing.T) {
String, _ := NewType("string", "", nil) 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)" exp := "foo(string,string)"
if m.Sig() != exp { if m.Sig() != exp {
t.Error("signature mismatch", exp, "!=", m.Sig()) t.Error("signature mismatch", exp, "!=", m.Sig())
@ -185,7 +185,7 @@ func TestMethodSignature(t *testing.T) {
} }
uintt, _ := NewType("uint256", "", nil) 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)" exp = "foo(uint256)"
if m.Sig() != exp { if m.Sig() != exp {
t.Error("signature mismatch", exp, "!=", m.Sig()) t.Error("signature mismatch", exp, "!=", m.Sig())
@ -204,7 +204,7 @@ func TestMethodSignature(t *testing.T) {
{Name: "y", Type: "int256"}, {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)" exp = "foo((int256,int256[],(int256,int256)[],(int256,int256)[2]),string)"
if m.Sig() != exp { if m.Sig() != exp {
t.Error("signature mismatch", exp, "!=", m.Sig()) t.Error("signature mismatch", exp, "!=", m.Sig())

View file

@ -43,8 +43,13 @@ type Method struct {
// will be resolved as foo0. // will be resolved as foo0.
Name string Name string
RawName string // RawName is the raw method name parsed from ABI RawName string // RawName is the raw method name parsed from ABI
StateMutability string // Indicates the mutability state of method
// 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 Constant bool
Payable bool Payable bool