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" }] }
]`,
expectations: map[string]string{
"Balance": "event Balance(uint256 in)",
"Check": "event Check(address t, uint256 b)",
"Balance": "event Balance(uint256 in)",
"Check": "event Check(address t, uint256 b)",
"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" } ] }
]`
func TestMethodString(t *testing.T) {
var table = []struct {
method string
method string
expectation string
}{
{
method: "balance",
expectation:"function balance() constant returns()",
method: "balance",
expectation: "function balance() constant returns()",
},
{
method: "send",
expectation:"function send(uint256 amount) returns()",
method: "send",
expectation: "function send(uint256 amount) returns()",
},
{
method: "transfer",
expectation:"function transfer(address from, address to, uint256 value) returns(bool success)",
method: "transfer",
expectation: "function transfer(address from, address to, uint256 value) returns(bool success)",
},
}
abi, err := JSON(strings.NewReader(methoddata))
@ -56,8 +54,8 @@ func TestMethodString(t *testing.T) {
for _, test := range table {
got := abi.Methods[test.method].String()
if got != test.expectation {
t.Errorf("expected string to be %s, got %s", test.expectation, got)
}
if got != test.expectation {
t.Errorf("expected string to be %s, got %s", test.expectation, got)
}
}
}