瀏覽代碼

accounts/abi: add unpack into array test

Robert Zaremba 8 年之前
父節點
當前提交
81d4cafb32
共有 3 個文件被更改,包括 17 次插入2 次删除
  1. 11 1
      accounts/abi/event_test.go
  2. 1 1
      accounts/abi/unpack.go
  3. 5 0
      accounts/abi/unpack_test.go

+ 11 - 1
accounts/abi/event_test.go

@@ -18,10 +18,10 @@ package abi
 
 import (
 	"bytes"
-	"reflect"
 	"encoding/hex"
 	"encoding/json"
 	"math/big"
+	"reflect"
 	"strings"
 	"testing"
 
@@ -178,6 +178,16 @@ func TestEventTupleUnpack(t *testing.T) {
 		jsonEventPledge,
 		"",
 		"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,
 		&[]interface{}{new(int), 0, 0},

+ 1 - 1
accounts/abi/unpack.go

@@ -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)
 	return
-}
+}

+ 5 - 0
accounts/abi/unpack_test.go

@@ -336,6 +336,11 @@ func TestMethodMultiReturn(t *testing.T) {
 		&[]interface{}{&expected.Int, &expected.String},
 		"",
 		"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{}{&expected.Int, &expected.String},