aboutsummaryrefslogtreecommitdiffstats
path: root/accounts/abi/event_test.go
diff options
context:
space:
mode:
authorDmitry Shulyak <yashulyak@gmail.com>2017-12-20 22:09:23 +0800
committerFelix Lange <fjl@users.noreply.github.com>2017-12-20 22:09:23 +0800
commitda58afcea0525fab2d3f45f58e7e243a15407ab9 (patch)
treeaa93996ead74ae3356b90214ee706f5a00cdb888 /accounts/abi/event_test.go
parentce823c9f84a3ab46003d1167ee54ab59b01092d6 (diff)
downloadgo-tangerine-da58afcea0525fab2d3f45f58e7e243a15407ab9.tar
go-tangerine-da58afcea0525fab2d3f45f58e7e243a15407ab9.tar.gz
go-tangerine-da58afcea0525fab2d3f45f58e7e243a15407ab9.tar.bz2
go-tangerine-da58afcea0525fab2d3f45f58e7e243a15407ab9.tar.lz
go-tangerine-da58afcea0525fab2d3f45f58e7e243a15407ab9.tar.xz
go-tangerine-da58afcea0525fab2d3f45f58e7e243a15407ab9.tar.zst
go-tangerine-da58afcea0525fab2d3f45f58e7e243a15407ab9.zip
accounts/abi: update array length after parsing array (#15618)
Fixes #15617
Diffstat (limited to 'accounts/abi/event_test.go')
-rw-r--r--accounts/abi/event_test.go23
1 files changed, 23 insertions, 0 deletions
diff --git a/accounts/abi/event_test.go b/accounts/abi/event_test.go
index 7e2f13f76..a3899b4a6 100644
--- a/accounts/abi/event_test.go
+++ b/accounts/abi/event_test.go
@@ -17,11 +17,14 @@
package abi
import (
+ "bytes"
+ "reflect"
"strings"
"testing"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
+ "github.com/stretchr/testify/require"
)
func TestEventId(t *testing.T) {
@@ -54,3 +57,23 @@ func TestEventId(t *testing.T) {
}
}
}
+
+// 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"}]}]`
+ type testStruct struct {
+ Value1 [2]uint8
+ Value2 uint8
+ }
+ abi, err := JSON(strings.NewReader(definition))
+ require.NoError(t, err)
+ var b bytes.Buffer
+ var i uint8 = 1
+ for ; i <= 3; i++ {
+ b.Write(packNum(reflect.ValueOf(i)))
+ }
+ var rst testStruct
+ require.NoError(t, abi.Unpack(&rst, "test", b.Bytes()))
+ require.Equal(t, [2]uint8{1, 2}, rst.Value1)
+ require.Equal(t, uint8(3), rst.Value2)
+}