This commit is contained in:
Alex T 2018-11-06 10:47:17 +02:00
parent 5a59cc0eea
commit 212b107860
2 changed files with 12 additions and 14 deletions

View file

@ -123,8 +123,8 @@ func TestEventString(t *testing.T) {
{ "type" : "event", "name" : "Transfer", "inputs": [{ "name": "from", "type": "address", "indexed": true }, { "name": "to", "type": "address", "indexed": true }, { "name": "value", "type": "uint256" }] } { "type" : "event", "name" : "Transfer", "inputs": [{ "name": "from", "type": "address", "indexed": true }, { "name": "to", "type": "address", "indexed": true }, { "name": "value", "type": "uint256" }] }
]`, ]`,
expectations: map[string]string{ expectations: map[string]string{
"Balance": "event Balance(uint256 in)", "Balance": "event Balance(uint256 in)",
"Check": "event Check(address t, uint256 b)", "Check": "event Check(address t, uint256 b)",
"Transfer": "event Transfer(address indexed from, address indexed to, uint256 value)", "Transfer": "event Transfer(address indexed from, address indexed to, uint256 value)",
}, },
}, },

View file

@ -28,25 +28,23 @@ const methoddata = `
{ "type" : "function", "name" : "transfer", "constant" : false, "inputs" : [ { "name" : "from", "type" : "address" }, { "name" : "to", "type" : "address" }, { "name" : "value", "type" : "uint256" } ], "outputs" : [ { "name" : "success", "type" : "bool" } ] } { "type" : "function", "name" : "transfer", "constant" : false, "inputs" : [ { "name" : "from", "type" : "address" }, { "name" : "to", "type" : "address" }, { "name" : "value", "type" : "uint256" } ], "outputs" : [ { "name" : "success", "type" : "bool" } ] }
]` ]`
func TestMethodString(t *testing.T) { func TestMethodString(t *testing.T) {
var table = []struct { var table = []struct {
method string method string
expectation string expectation string
}{ }{
{ {
method: "balance", method: "balance",
expectation:"function balance() constant returns()", expectation: "function balance() constant returns()",
}, },
{ {
method: "send", method: "send",
expectation:"function send(uint256 amount) returns()", expectation: "function send(uint256 amount) returns()",
}, },
{ {
method: "transfer", method: "transfer",
expectation:"function transfer(address from, address to, uint256 value) returns(bool success)", expectation: "function transfer(address from, address to, uint256 value) returns(bool success)",
}, },
} }
abi, err := JSON(strings.NewReader(methoddata)) abi, err := JSON(strings.NewReader(methoddata))
@ -56,8 +54,8 @@ func TestMethodString(t *testing.T) {
for _, test := range table { for _, test := range table {
got := abi.Methods[test.method].String() got := abi.Methods[test.method].String()
if got != test.expectation { if got != test.expectation {
t.Errorf("expected string to be %s, got %s", test.expectation, got) t.Errorf("expected string to be %s, got %s", test.expectation, got)
} }
} }
} }