diff options
author | tzapu <alex@tzapu.com> | 2018-12-13 22:12:19 +0800 |
---|---|---|
committer | Guillaume Ballet <gballet@gmail.com> | 2018-12-13 22:12:19 +0800 |
commit | e79821cabeda5c6907f03073d11fe6d83367f494 (patch) | |
tree | 7b110c169ba6d55f435b9e555d7447e72537b732 /accounts/abi/event_test.go | |
parent | e57e4571d3382c504a01f87be654d984f26e2dd1 (diff) | |
download | go-tangerine-e79821cabeda5c6907f03073d11fe6d83367f494.tar.gz go-tangerine-e79821cabeda5c6907f03073d11fe6d83367f494.tar.zst go-tangerine-e79821cabeda5c6907f03073d11fe6d83367f494.zip |
accounts/abi: argument type and name were reversed (#17947)
argument type and name were reversed
Diffstat (limited to 'accounts/abi/event_test.go')
-rw-r--r-- | accounts/abi/event_test.go | 41 |
1 files changed, 37 insertions, 4 deletions
diff --git a/accounts/abi/event_test.go b/accounts/abi/event_test.go index 3bfdd7c0a..e735cceb8 100644 --- a/accounts/abi/event_test.go +++ b/accounts/abi/event_test.go @@ -87,12 +87,12 @@ func TestEventId(t *testing.T) { }{ { definition: `[ - { "type" : "event", "name" : "balance", "inputs": [{ "name" : "in", "type": "uint256" }] }, - { "type" : "event", "name" : "check", "inputs": [{ "name" : "t", "type": "address" }, { "name": "b", "type": "uint256" }] } + { "type" : "event", "name" : "Balance", "inputs": [{ "name" : "in", "type": "uint256" }] }, + { "type" : "event", "name" : "Check", "inputs": [{ "name" : "t", "type": "address" }, { "name": "b", "type": "uint256" }] } ]`, expectations: map[string]common.Hash{ - "balance": crypto.Keccak256Hash([]byte("balance(uint256)")), - "check": crypto.Keccak256Hash([]byte("check(address,uint256)")), + "Balance": crypto.Keccak256Hash([]byte("Balance(uint256)")), + "Check": crypto.Keccak256Hash([]byte("Check(address,uint256)")), }, }, } @@ -111,6 +111,39 @@ func TestEventId(t *testing.T) { } } +func TestEventString(t *testing.T) { + var table = []struct { + definition string + expectations map[string]string + }{ + { + definition: `[ + { "type" : "event", "name" : "Balance", "inputs": [{ "name" : "in", "type": "uint256" }] }, + { "type" : "event", "name" : "Check", "inputs": [{ "name" : "t", "type": "address" }, { "name": "b", "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{ + "Balance": "event Balance(uint256 in)", + "Check": "event Check(address t, uint256 b)", + "Transfer": "event Transfer(address indexed from, address indexed to, uint256 value)", + }, + }, + } + + for _, test := range table { + abi, err := JSON(strings.NewReader(test.definition)) + if err != nil { + t.Fatal(err) + } + + for name, event := range abi.Events { + if event.String() != test.expectations[name] { + t.Errorf("expected string to be %s, got %s", test.expectations[name], event.String()) + } + } + } +} + // TestEventMultiValueWithArrayUnpack verifies that array fields will be counted after parsing array. func TestEventMultiValueWithArrayUnpack(t *testing.T) { definition := `[{"name": "test", "type": "event", "inputs": [{"indexed": false, "name":"value1", "type":"uint8[2]"},{"indexed": false, "name":"value2", "type":"uint8"}]}]` |