From dbaec6419ed382dbf442ee4aaaa90b8e992fba3a Mon Sep 17 00:00:00 2001 From: Marius van der Wijden Date: Tue, 7 Apr 2020 09:35:45 +0200 Subject: [PATCH] accounts/abi: added unnamed event params test --- accounts/abi/abi_test.go | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/accounts/abi/abi_test.go b/accounts/abi/abi_test.go index 55ea0b94b2..303ee49142 100644 --- a/accounts/abi/abi_test.go +++ b/accounts/abi/abi_test.go @@ -1045,3 +1045,28 @@ func TestDoubleDuplicateMethodNames(t *testing.T) { t.Fatalf("Should not have found extra method") } } + +// TestDoubleDuplicateEventNames checks that an event with unnamed parameters is +// correctly handled +// The test runs the abi of the following contract. +// contract TestEvent { +// event send(uint256, uint256); +// } +func TestUnnamedEventParam(t *testing.T) { + abiJSON := `[{ "anonymous": false, "inputs": [{ "indexed": false,"internalType": "uint256", "name": "","type": "uint256"},{"indexed": false,"internalType": "uint256","name": "","type": "uint256"}],"name": "send","type": "event"}]` + contractAbi, err := JSON(strings.NewReader(abiJSON)) + if err != nil { + t.Fatal(err) + } + + event, ok := contractAbi.Events["send"] + if !ok { + t.Fatalf("Could not find event") + } + if event.Inputs[0].Name != "arg0" { + t.Fatalf("Could not find input") + } + if event.Inputs[1].Name != "arg1" { + t.Fatalf("Could not find input") + } +}