From e149581818c26dcf6b32ba6e004cdda96e4b26be Mon Sep 17 00:00:00 2001 From: weimumu <934657014@qq.com> Date: Mon, 17 Dec 2018 13:24:12 +0800 Subject: [PATCH 1/2] fix bug about unpack func in accounts/abi package --- accounts/abi/unpack.go | 2 +- accounts/abi/unpack_test.go | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/accounts/abi/unpack.go b/accounts/abi/unpack.go index d5875140ccf7..a69057db1985 100644 --- a/accounts/abi/unpack.go +++ b/accounts/abi/unpack.go @@ -151,7 +151,7 @@ func forEachUnpack(t Type, output []byte, start, size int) (interface{}, error) // Arrays have packed elements, resulting in longer unpack steps. // Slices have just 32 bytes per element (pointing to the contents). elemSize := 32 - if t.T == ArrayTy { + if t.T == ArrayTy || t.T == SliceTy{ elemSize = getFullElemSize(t.Elem) } diff --git a/accounts/abi/unpack_test.go b/accounts/abi/unpack_test.go index 97552b90cff0..aa7071915c91 100644 --- a/accounts/abi/unpack_test.go +++ b/accounts/abi/unpack_test.go @@ -191,6 +191,11 @@ var unpackTests = []unpackTest{ enc: "0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002", want: [][2]uint8{{1, 2}}, }, + { + def: `[{"type": "uint8[2][]"}]`, + enc: "000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002", + want: [][2]uint8{{1,2}, {1,2}}, + }, { def: `[{"type": "uint16[]"}]`, enc: "0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002", From f69dbcac01a7048d4557f6ea8c2f4c60c54a4f15 Mon Sep 17 00:00:00 2001 From: weimumu <934657014@qq.com> Date: Mon, 17 Dec 2018 14:28:19 +0800 Subject: [PATCH 2/2] gmf --- accounts/abi/unpack.go | 2 +- accounts/abi/unpack_test.go | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/accounts/abi/unpack.go b/accounts/abi/unpack.go index a69057db1985..c3bbbb251a62 100644 --- a/accounts/abi/unpack.go +++ b/accounts/abi/unpack.go @@ -151,7 +151,7 @@ func forEachUnpack(t Type, output []byte, start, size int) (interface{}, error) // Arrays have packed elements, resulting in longer unpack steps. // Slices have just 32 bytes per element (pointing to the contents). elemSize := 32 - if t.T == ArrayTy || t.T == SliceTy{ + if t.T == ArrayTy || t.T == SliceTy { elemSize = getFullElemSize(t.Elem) } diff --git a/accounts/abi/unpack_test.go b/accounts/abi/unpack_test.go index aa7071915c91..29ed4522cf8f 100644 --- a/accounts/abi/unpack_test.go +++ b/accounts/abi/unpack_test.go @@ -192,9 +192,9 @@ var unpackTests = []unpackTest{ want: [][2]uint8{{1, 2}}, }, { - def: `[{"type": "uint8[2][]"}]`, - enc: "000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002", - want: [][2]uint8{{1,2}, {1,2}}, + def: `[{"type": "uint8[2][]"}]`, + enc: "000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002", + want: [][2]uint8{{1, 2}, {1, 2}}, }, { def: `[{"type": "uint16[]"}]`,