aboutsummaryrefslogtreecommitdiffstats
path: root/accounts/abi/abi_test.go
diff options
context:
space:
mode:
authorRJ <rj@erisindustries.com>2016-11-04 06:25:19 +0800
committerJeffrey Wilcke <jeffrey@ethereum.org>2016-11-04 06:25:19 +0800
commit2ad5dba50a65e7471d24da7a258087ff97e00f36 (patch)
tree2e9895224048875544eaa922b924b97257ba72e8 /accounts/abi/abi_test.go
parented2bc7fbe9a30c1861cffdd7d0fd570847a2ae0c (diff)
downloadgo-tangerine-2ad5dba50a65e7471d24da7a258087ff97e00f36.tar
go-tangerine-2ad5dba50a65e7471d24da7a258087ff97e00f36.tar.gz
go-tangerine-2ad5dba50a65e7471d24da7a258087ff97e00f36.tar.bz2
go-tangerine-2ad5dba50a65e7471d24da7a258087ff97e00f36.tar.lz
go-tangerine-2ad5dba50a65e7471d24da7a258087ff97e00f36.tar.xz
go-tangerine-2ad5dba50a65e7471d24da7a258087ff97e00f36.tar.zst
go-tangerine-2ad5dba50a65e7471d24da7a258087ff97e00f36.zip
accounts/abi: differentiate between static and dynamic arrays (#3121)
solves #3119 Signed-off-by: VoR0220 <rj@erisindustries.com>
Diffstat (limited to 'accounts/abi/abi_test.go')
-rw-r--r--accounts/abi/abi_test.go25
1 files changed, 21 insertions, 4 deletions
diff --git a/accounts/abi/abi_test.go b/accounts/abi/abi_test.go
index 7916e595d..85e25f9ea 100644
--- a/accounts/abi/abi_test.go
+++ b/accounts/abi/abi_test.go
@@ -357,8 +357,6 @@ func TestMethodPack(t *testing.T) {
}
sig := abi.Methods["slice"].Id()
- sig = append(sig, common.LeftPadBytes([]byte{32}, 32)...)
- sig = append(sig, common.LeftPadBytes([]byte{2}, 32)...)
sig = append(sig, common.LeftPadBytes([]byte{1}, 32)...)
sig = append(sig, common.LeftPadBytes([]byte{2}, 32)...)
@@ -406,8 +404,6 @@ func TestMethodPack(t *testing.T) {
}
sig = abi.Methods["slice256"].Id()
- sig = append(sig, common.LeftPadBytes([]byte{32}, 32)...)
- sig = append(sig, common.LeftPadBytes([]byte{2}, 32)...)
sig = append(sig, common.LeftPadBytes([]byte{1}, 32)...)
sig = append(sig, common.LeftPadBytes([]byte{2}, 32)...)
@@ -931,6 +927,7 @@ func TestUnmarshal(t *testing.T) {
{ "name" : "bytes", "constant" : false, "outputs": [ { "type": "bytes" } ] },
{ "name" : "fixed", "constant" : false, "outputs": [ { "type": "bytes32" } ] },
{ "name" : "multi", "constant" : false, "outputs": [ { "type": "bytes" }, { "type": "bytes" } ] },
+ { "name" : "intArraySingle", "constant" : false, "outputs": [ { "type": "uint256[3]" } ] },
{ "name" : "addressSliceSingle", "constant" : false, "outputs": [ { "type": "address[]" } ] },
{ "name" : "addressSliceDouble", "constant" : false, "outputs": [ { "name": "a", "type": "address[]" }, { "name": "b", "type": "address[]" } ] },
{ "name" : "mixedBytes", "constant" : true, "outputs": [ { "name": "a", "type": "bytes" }, { "name": "b", "type": "bytes32" } ] }]`
@@ -1083,6 +1080,26 @@ func TestUnmarshal(t *testing.T) {
t.Errorf("expected %x, got %x", fixed, out[1])
}
+ buff.Reset()
+ buff.Write(common.Hex2Bytes("0000000000000000000000000000000000000000000000000000000000000001"))
+ buff.Write(common.Hex2Bytes("0000000000000000000000000000000000000000000000000000000000000002"))
+ buff.Write(common.Hex2Bytes("0000000000000000000000000000000000000000000000000000000000000003"))
+ // marshal int array
+ var intArray [3]*big.Int
+ err = abi.Unpack(&intArray, "intArraySingle", buff.Bytes())
+ if err != nil {
+ t.Error(err)
+ }
+ var testAgainstIntArray [3]*big.Int
+ testAgainstIntArray[0] = big.NewInt(1)
+ testAgainstIntArray[1] = big.NewInt(2)
+ testAgainstIntArray[2] = big.NewInt(3)
+
+ for i, Int := range intArray {
+ if Int.Cmp(testAgainstIntArray[i]) != 0 {
+ t.Errorf("expected %v, got %v", testAgainstIntArray[i], Int)
+ }
+ }
// marshal address slice
buff.Reset()
buff.Write(common.Hex2Bytes("0000000000000000000000000000000000000000000000000000000000000020")) // offset