diff options
author | tbocek <tom@tomp2p.net> | 2016-12-11 20:33:51 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2017-01-09 17:36:32 +0800 |
commit | fc213c873d2e922a606f08a1a6323243da26dd2a (patch) | |
tree | 296b69e7acbb274e21da9abc9dfe617cf876573c | |
parent | 972f0bd3dbd4f6284e66c71b8746c35c10708ccc (diff) | |
download | go-tangerine-fc213c873d2e922a606f08a1a6323243da26dd2a.tar.gz go-tangerine-fc213c873d2e922a606f08a1a6323243da26dd2a.tar.zst go-tangerine-fc213c873d2e922a606f08a1a6323243da26dd2a.zip |
accounts/abi: added testcase to unpack []uint32
-rw-r--r-- | accounts/abi/abi_test.go | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/accounts/abi/abi_test.go b/accounts/abi/abi_test.go index 1e5ee0efe..a45bd6cc0 100644 --- a/accounts/abi/abi_test.go +++ b/accounts/abi/abi_test.go @@ -332,6 +332,30 @@ func TestUnpackSetInterfaceSlice(t *testing.T) { } } +func TestUnpackSetInterfaceArrayOutput(t *testing.T) { + var ( + var1 = new([1]uint32) + var2 = new([1]uint32) + ) + out := []interface{}{var1, var2} + abi, err := JSON(strings.NewReader(`[{"type":"function", "name":"ints", "outputs":[{"type":"uint32[1]"}, {"type":"uint32[1]"}]}]`)) + if err != nil { + t.Fatal(err) + } + marshalledReturn := append(pad([]byte{1}, 32, true), pad([]byte{2}, 32, true)...) + err = abi.Unpack(&out, "ints", marshalledReturn) + if err != nil { + t.Fatal(err) + } + + if *var1 != [1]uint32{1} { + t.Error("expected var1 to be [1], got", *var1) + } + if *var2 != [1]uint32{2} { + t.Error("expected var2 to be [2], got", *var2) + } +} + func TestPack(t *testing.T) { for i, test := range []struct { typ string |