accounts/abi: add unpack into array test

This commit is contained in:
Robert Zaremba 2017-12-01 22:32:04 +01:00 committed by Martin Holst Swende
parent 1afca33eac
commit 81d4cafb32
No known key found for this signature in database
GPG Key ID: 683B438C05A5DDF0
3 changed files with 17 additions and 2 deletions

View File

@ -18,10 +18,10 @@ package abi
import ( import (
"bytes" "bytes"
"reflect"
"encoding/hex" "encoding/hex"
"encoding/json" "encoding/json"
"math/big" "math/big"
"reflect"
"strings" "strings"
"testing" "testing"
@ -178,6 +178,16 @@ func TestEventTupleUnpack(t *testing.T) {
jsonEventPledge, jsonEventPledge,
"", "",
"Can unpack Pledge event into slice", "Can unpack Pledge event into slice",
}, {
pledgeData1,
&[3]interface{}{&common.Address{}, &bigint, &[3]byte{}},
&[3]interface{}{
&addr,
&bigintExpected2,
&[3]byte{'u', 's', 'd'}},
jsonEventPledge,
"",
"Can unpack Pledge event into an array",
}, { }, {
pledgeData1, pledgeData1,
&[]interface{}{new(int), 0, 0}, &[]interface{}{new(int), 0, 0},

View File

@ -202,4 +202,4 @@ func lengthPrefixPointsTo(index int, output []byte) (start int, length int, err
//fmt.Printf("LENGTH PREFIX INFO: \nsize: %v\noffset: %v\nstart: %v\n", length, offset, start) //fmt.Printf("LENGTH PREFIX INFO: \nsize: %v\noffset: %v\nstart: %v\n", length, offset, start)
return return
} }

View File

@ -336,6 +336,11 @@ func TestMethodMultiReturn(t *testing.T) {
&[]interface{}{&expected.Int, &expected.String}, &[]interface{}{&expected.Int, &expected.String},
"", "",
"Can unpack into a slice", "Can unpack into a slice",
}, {
&[2]interface{}{&bigint, new(string)},
&[2]interface{}{&expected.Int, &expected.String},
"",
"Can unpack into an array",
}, { }, {
&[]interface{}{new(int), new(int)}, &[]interface{}{new(int), new(int)},
&[]interface{}{&expected.Int, &expected.String}, &[]interface{}{&expected.Int, &expected.String},