github.com/core-coin/go-core/v2@v2.1.9/accounts/abi/packing_test.go (about)

     1  // Copyright 2020 by the Authors
     2  // This file is part of the go-core library.
     3  //
     4  // The go-core library is free software: you can redistribute it and/or modify
     5  // it under the terms of the GNU Lesser General Public License as published by
     6  // the Free Software Foundation, either version 3 of the License, or
     7  // (at your option) any later version.
     8  //
     9  // The go-core library is distributed in the hope that it will be useful,
    10  // but WITHOUT ANY WARRANTY; without even the implied warranty of
    11  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    12  // GNU Lesser General Public License for more details.
    13  //
    14  // You should have received a copy of the GNU Lesser General Public License
    15  // along with the go-core library. If not, see <http://www.gnu.org/licenses/>.
    16  
    17  package abi
    18  
    19  import (
    20  	"math/big"
    21  
    22  	"github.com/core-coin/go-core/v2/common"
    23  )
    24  
    25  type packUnpackTest struct {
    26  	def      string
    27  	unpacked interface{}
    28  	packed   string
    29  }
    30  
    31  var packUnpackTests = []packUnpackTest{
    32  	// Booleans
    33  	{
    34  		def:      `[{ "type": "bool" }]`,
    35  		packed:   "0000000000000000000000000000000000000000000000000000000000000001",
    36  		unpacked: true,
    37  	},
    38  	{
    39  		def:      `[{ "type": "bool" }]`,
    40  		packed:   "0000000000000000000000000000000000000000000000000000000000000000",
    41  		unpacked: false,
    42  	},
    43  	// Integers
    44  	{
    45  		def:      `[{ "type": "uint8" }]`,
    46  		unpacked: uint8(2),
    47  		packed:   "0000000000000000000000000000000000000000000000000000000000000002",
    48  	},
    49  	{
    50  		def:      `[{ "type": "uint8[]" }]`,
    51  		unpacked: []uint8{1, 2},
    52  		packed: "0000000000000000000000000000000000000000000000000000000000000020" +
    53  			"0000000000000000000000000000000000000000000000000000000000000002" +
    54  			"0000000000000000000000000000000000000000000000000000000000000001" +
    55  			"0000000000000000000000000000000000000000000000000000000000000002",
    56  	},
    57  	{
    58  		def:      `[{ "type": "uint16" }]`,
    59  		unpacked: uint16(2),
    60  		packed:   "0000000000000000000000000000000000000000000000000000000000000002",
    61  	},
    62  	{
    63  		def:      `[{ "type": "uint16[]" }]`,
    64  		unpacked: []uint16{1, 2},
    65  		packed: "0000000000000000000000000000000000000000000000000000000000000020" +
    66  			"0000000000000000000000000000000000000000000000000000000000000002" +
    67  			"0000000000000000000000000000000000000000000000000000000000000001" +
    68  			"0000000000000000000000000000000000000000000000000000000000000002",
    69  	},
    70  	{
    71  		def:      `[{"type": "uint17"}]`,
    72  		packed:   "0000000000000000000000000000000000000000000000000000000000000001",
    73  		unpacked: big.NewInt(1),
    74  	},
    75  	{
    76  		def:      `[{"type": "uint32"}]`,
    77  		packed:   "0000000000000000000000000000000000000000000000000000000000000001",
    78  		unpacked: uint32(1),
    79  	},
    80  	{
    81  		def:      `[{"type": "uint32[]"}]`,
    82  		unpacked: []uint32{1, 2},
    83  		packed: "0000000000000000000000000000000000000000000000000000000000000020" +
    84  			"0000000000000000000000000000000000000000000000000000000000000002" +
    85  			"0000000000000000000000000000000000000000000000000000000000000001" +
    86  			"0000000000000000000000000000000000000000000000000000000000000002",
    87  	},
    88  	{
    89  		def:      `[{"type": "uint64"}]`,
    90  		unpacked: uint64(2),
    91  		packed:   "0000000000000000000000000000000000000000000000000000000000000002",
    92  	},
    93  	{
    94  		def:      `[{"type": "uint64[]"}]`,
    95  		unpacked: []uint64{1, 2},
    96  		packed: "0000000000000000000000000000000000000000000000000000000000000020" +
    97  			"0000000000000000000000000000000000000000000000000000000000000002" +
    98  			"0000000000000000000000000000000000000000000000000000000000000001" +
    99  			"0000000000000000000000000000000000000000000000000000000000000002",
   100  	},
   101  	{
   102  		def:      `[{"type": "uint256"}]`,
   103  		unpacked: big.NewInt(2),
   104  		packed:   "0000000000000000000000000000000000000000000000000000000000000002",
   105  	},
   106  	{
   107  		def:      `[{"type": "uint256[]"}]`,
   108  		unpacked: []*big.Int{big.NewInt(1), big.NewInt(2)},
   109  		packed: "0000000000000000000000000000000000000000000000000000000000000020" +
   110  			"0000000000000000000000000000000000000000000000000000000000000002" +
   111  			"0000000000000000000000000000000000000000000000000000000000000001" +
   112  			"0000000000000000000000000000000000000000000000000000000000000002",
   113  	},
   114  	{
   115  		def:      `[{"type": "int8"}]`,
   116  		unpacked: int8(2),
   117  		packed:   "0000000000000000000000000000000000000000000000000000000000000002",
   118  	},
   119  	{
   120  		def:      `[{"type": "int8[]"}]`,
   121  		unpacked: []int8{1, 2},
   122  		packed: "0000000000000000000000000000000000000000000000000000000000000020" +
   123  			"0000000000000000000000000000000000000000000000000000000000000002" +
   124  			"0000000000000000000000000000000000000000000000000000000000000001" +
   125  			"0000000000000000000000000000000000000000000000000000000000000002",
   126  	},
   127  	{
   128  		def:      `[{"type": "int16"}]`,
   129  		unpacked: int16(2),
   130  		packed:   "0000000000000000000000000000000000000000000000000000000000000002",
   131  	},
   132  	{
   133  		def:      `[{"type": "int16[]"}]`,
   134  		unpacked: []int16{1, 2},
   135  		packed: "0000000000000000000000000000000000000000000000000000000000000020" +
   136  			"0000000000000000000000000000000000000000000000000000000000000002" +
   137  			"0000000000000000000000000000000000000000000000000000000000000001" +
   138  			"0000000000000000000000000000000000000000000000000000000000000002",
   139  	},
   140  	{
   141  		def:      `[{"type": "int17"}]`,
   142  		packed:   "0000000000000000000000000000000000000000000000000000000000000001",
   143  		unpacked: big.NewInt(1),
   144  	},
   145  	{
   146  		def:      `[{"type": "int32"}]`,
   147  		unpacked: int32(2),
   148  		packed:   "0000000000000000000000000000000000000000000000000000000000000002",
   149  	},
   150  	{
   151  		def:      `[{"type": "int32"}]`,
   152  		packed:   "0000000000000000000000000000000000000000000000000000000000000001",
   153  		unpacked: int32(1),
   154  	},
   155  	{
   156  		def:      `[{"type": "int32[]"}]`,
   157  		unpacked: []int32{1, 2},
   158  		packed: "0000000000000000000000000000000000000000000000000000000000000020" +
   159  			"0000000000000000000000000000000000000000000000000000000000000002" +
   160  			"0000000000000000000000000000000000000000000000000000000000000001" +
   161  			"0000000000000000000000000000000000000000000000000000000000000002",
   162  	},
   163  	{
   164  		def:      `[{"type": "int64"}]`,
   165  		unpacked: int64(2),
   166  		packed:   "0000000000000000000000000000000000000000000000000000000000000002",
   167  	},
   168  	{
   169  		def:      `[{"type": "int64[]"}]`,
   170  		unpacked: []int64{1, 2},
   171  		packed: "0000000000000000000000000000000000000000000000000000000000000020" +
   172  			"0000000000000000000000000000000000000000000000000000000000000002" +
   173  			"0000000000000000000000000000000000000000000000000000000000000001" +
   174  			"0000000000000000000000000000000000000000000000000000000000000002",
   175  	},
   176  	{
   177  		def:      `[{"type": "int256"}]`,
   178  		unpacked: big.NewInt(2),
   179  		packed:   "0000000000000000000000000000000000000000000000000000000000000002",
   180  	},
   181  	{
   182  		def:      `[{"type": "int256"}]`,
   183  		packed:   "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
   184  		unpacked: big.NewInt(-1),
   185  	},
   186  	{
   187  		def:      `[{"type": "int256[]"}]`,
   188  		unpacked: []*big.Int{big.NewInt(1), big.NewInt(2)},
   189  		packed: "0000000000000000000000000000000000000000000000000000000000000020" +
   190  			"0000000000000000000000000000000000000000000000000000000000000002" +
   191  			"0000000000000000000000000000000000000000000000000000000000000001" +
   192  			"0000000000000000000000000000000000000000000000000000000000000002",
   193  	},
   194  	// Address
   195  	{
   196  		def:      `[{"type": "address"}]`,
   197  		packed:   "0000000000000000000001000000000000000000000000000000000000000000",
   198  		unpacked: common.Address{1},
   199  	},
   200  	{
   201  		def:      `[{"type": "address[]"}]`,
   202  		unpacked: []common.Address{{1}, {2}},
   203  		packed: "0000000000000000000000000000000000000000000000000000000000000020" +
   204  			"0000000000000000000000000000000000000000000000000000000000000002" +
   205  			"0000000000000000000001000000000000000000000000000000000000000000" +
   206  			"0000000000000000000002000000000000000000000000000000000000000000",
   207  	},
   208  	// Bytes
   209  	{
   210  		def:      `[{"type": "bytes1"}]`,
   211  		unpacked: [1]byte{1},
   212  		packed:   "0100000000000000000000000000000000000000000000000000000000000000",
   213  	},
   214  	{
   215  		def:      `[{"type": "bytes2"}]`,
   216  		unpacked: [2]byte{1},
   217  		packed:   "0100000000000000000000000000000000000000000000000000000000000000",
   218  	},
   219  	{
   220  		def:      `[{"type": "bytes3"}]`,
   221  		unpacked: [3]byte{1},
   222  		packed:   "0100000000000000000000000000000000000000000000000000000000000000",
   223  	},
   224  	{
   225  		def:      `[{"type": "bytes4"}]`,
   226  		unpacked: [4]byte{1},
   227  		packed:   "0100000000000000000000000000000000000000000000000000000000000000",
   228  	},
   229  	{
   230  		def:      `[{"type": "bytes5"}]`,
   231  		unpacked: [5]byte{1},
   232  		packed:   "0100000000000000000000000000000000000000000000000000000000000000",
   233  	},
   234  	{
   235  		def:      `[{"type": "bytes6"}]`,
   236  		unpacked: [6]byte{1},
   237  		packed:   "0100000000000000000000000000000000000000000000000000000000000000",
   238  	},
   239  	{
   240  		def:      `[{"type": "bytes7"}]`,
   241  		unpacked: [7]byte{1},
   242  		packed:   "0100000000000000000000000000000000000000000000000000000000000000",
   243  	},
   244  	{
   245  		def:      `[{"type": "bytes8"}]`,
   246  		unpacked: [8]byte{1},
   247  		packed:   "0100000000000000000000000000000000000000000000000000000000000000",
   248  	},
   249  	{
   250  		def:      `[{"type": "bytes9"}]`,
   251  		unpacked: [9]byte{1},
   252  		packed:   "0100000000000000000000000000000000000000000000000000000000000000",
   253  	},
   254  	{
   255  		def:      `[{"type": "bytes10"}]`,
   256  		unpacked: [10]byte{1},
   257  		packed:   "0100000000000000000000000000000000000000000000000000000000000000",
   258  	},
   259  	{
   260  		def:      `[{"type": "bytes11"}]`,
   261  		unpacked: [11]byte{1},
   262  		packed:   "0100000000000000000000000000000000000000000000000000000000000000",
   263  	},
   264  	{
   265  		def:      `[{"type": "bytes12"}]`,
   266  		unpacked: [12]byte{1},
   267  		packed:   "0100000000000000000000000000000000000000000000000000000000000000",
   268  	},
   269  	{
   270  		def:      `[{"type": "bytes13"}]`,
   271  		unpacked: [13]byte{1},
   272  		packed:   "0100000000000000000000000000000000000000000000000000000000000000",
   273  	},
   274  	{
   275  		def:      `[{"type": "bytes14"}]`,
   276  		unpacked: [14]byte{1},
   277  		packed:   "0100000000000000000000000000000000000000000000000000000000000000",
   278  	},
   279  	{
   280  		def:      `[{"type": "bytes15"}]`,
   281  		unpacked: [15]byte{1},
   282  		packed:   "0100000000000000000000000000000000000000000000000000000000000000",
   283  	},
   284  	{
   285  		def:      `[{"type": "bytes16"}]`,
   286  		unpacked: [16]byte{1},
   287  		packed:   "0100000000000000000000000000000000000000000000000000000000000000",
   288  	},
   289  	{
   290  		def:      `[{"type": "bytes17"}]`,
   291  		unpacked: [17]byte{1},
   292  		packed:   "0100000000000000000000000000000000000000000000000000000000000000",
   293  	},
   294  	{
   295  		def:      `[{"type": "bytes18"}]`,
   296  		unpacked: [18]byte{1},
   297  		packed:   "0100000000000000000000000000000000000000000000000000000000000000",
   298  	},
   299  	{
   300  		def:      `[{"type": "bytes19"}]`,
   301  		unpacked: [19]byte{1},
   302  		packed:   "0100000000000000000000000000000000000000000000000000000000000000",
   303  	},
   304  	{
   305  		def:      `[{"type": "bytes20"}]`,
   306  		unpacked: [20]byte{1},
   307  		packed:   "0100000000000000000000000000000000000000000000000000000000000000",
   308  	},
   309  	{
   310  		def:      `[{"type": "bytes21"}]`,
   311  		unpacked: [21]byte{1},
   312  		packed:   "0100000000000000000000000000000000000000000000000000000000000000",
   313  	},
   314  	{
   315  		def:      `[{"type": "bytes22"}]`,
   316  		unpacked: [22]byte{1},
   317  		packed:   "0100000000000000000000000000000000000000000000000000000000000000",
   318  	},
   319  	{
   320  		def:      `[{"type": "bytes23"}]`,
   321  		unpacked: [23]byte{1},
   322  		packed:   "0100000000000000000000000000000000000000000000000000000000000000",
   323  	},
   324  	{
   325  		def:      `[{"type": "bytes24"}]`,
   326  		unpacked: [24]byte{1},
   327  		packed:   "0100000000000000000000000000000000000000000000000000000000000000",
   328  	},
   329  	{
   330  		def:      `[{"type": "bytes25"}]`,
   331  		unpacked: [25]byte{1},
   332  		packed:   "0100000000000000000000000000000000000000000000000000000000000000",
   333  	},
   334  	{
   335  		def:      `[{"type": "bytes26"}]`,
   336  		unpacked: [26]byte{1},
   337  		packed:   "0100000000000000000000000000000000000000000000000000000000000000",
   338  	},
   339  	{
   340  		def:      `[{"type": "bytes27"}]`,
   341  		unpacked: [27]byte{1},
   342  		packed:   "0100000000000000000000000000000000000000000000000000000000000000",
   343  	},
   344  	{
   345  		def:      `[{"type": "bytes28"}]`,
   346  		unpacked: [28]byte{1},
   347  		packed:   "0100000000000000000000000000000000000000000000000000000000000000",
   348  	},
   349  	{
   350  		def:      `[{"type": "bytes29"}]`,
   351  		unpacked: [29]byte{1},
   352  		packed:   "0100000000000000000000000000000000000000000000000000000000000000",
   353  	},
   354  	{
   355  		def:      `[{"type": "bytes30"}]`,
   356  		unpacked: [30]byte{1},
   357  		packed:   "0100000000000000000000000000000000000000000000000000000000000000",
   358  	},
   359  	{
   360  		def:      `[{"type": "bytes31"}]`,
   361  		unpacked: [31]byte{1},
   362  		packed:   "0100000000000000000000000000000000000000000000000000000000000000",
   363  	},
   364  	{
   365  		def:      `[{"type": "bytes32"}]`,
   366  		unpacked: [32]byte{1},
   367  		packed:   "0100000000000000000000000000000000000000000000000000000000000000",
   368  	},
   369  	{
   370  		def:      `[{"type": "bytes32"}]`,
   371  		packed:   "0100000000000000000000000000000000000000000000000000000000000000",
   372  		unpacked: [32]byte{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
   373  	},
   374  	{
   375  		def: `[{"type": "bytes"}]`,
   376  		packed: "0000000000000000000000000000000000000000000000000000000000000020" +
   377  			"0000000000000000000000000000000000000000000000000000000000000020" +
   378  			"0100000000000000000000000000000000000000000000000000000000000000",
   379  		unpacked: common.Hex2Bytes("0100000000000000000000000000000000000000000000000000000000000000"),
   380  	},
   381  	{
   382  		def:      `[{"type": "bytes32"}]`,
   383  		packed:   "0100000000000000000000000000000000000000000000000000000000000000",
   384  		unpacked: [32]byte{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
   385  	},
   386  	// Functions
   387  	{
   388  		def:      `[{"type": "function"}]`,
   389  		packed:   "cb27de521e43741cf785cbad450d5649187b9612018fd4fa231f000000000000",
   390  		unpacked: [26]byte{203, 39, 222, 82, 30, 67, 116, 28, 247, 133, 203, 173, 69, 13, 86, 73, 24, 123, 150, 18, 1, 143, 212, 250, 35, 31},
   391  	},
   392  	// Slice and Array
   393  	{
   394  		def: `[{"type": "uint8[]"}]`,
   395  		packed: "0000000000000000000000000000000000000000000000000000000000000020" +
   396  			"0000000000000000000000000000000000000000000000000000000000000002" +
   397  			"0000000000000000000000000000000000000000000000000000000000000001" +
   398  			"0000000000000000000000000000000000000000000000000000000000000002",
   399  		unpacked: []uint8{1, 2},
   400  	},
   401  	{
   402  		def: `[{"type": "uint8[]"}]`,
   403  		packed: "0000000000000000000000000000000000000000000000000000000000000020" +
   404  			"0000000000000000000000000000000000000000000000000000000000000000",
   405  		unpacked: []uint8{},
   406  	},
   407  	{
   408  		def: `[{"type": "uint256[]"}]`,
   409  		packed: "0000000000000000000000000000000000000000000000000000000000000020" +
   410  			"0000000000000000000000000000000000000000000000000000000000000000",
   411  		unpacked: []*big.Int{},
   412  	},
   413  	{
   414  		def: `[{"type": "uint8[2]"}]`,
   415  		packed: "0000000000000000000000000000000000000000000000000000000000000001" +
   416  			"0000000000000000000000000000000000000000000000000000000000000002",
   417  		unpacked: [2]uint8{1, 2},
   418  	},
   419  	{
   420  		def: `[{"type": "int8[2]"}]`,
   421  		packed: "0000000000000000000000000000000000000000000000000000000000000001" +
   422  			"0000000000000000000000000000000000000000000000000000000000000002",
   423  		unpacked: [2]int8{1, 2},
   424  	},
   425  	{
   426  		def: `[{"type": "int16[]"}]`,
   427  		packed: "0000000000000000000000000000000000000000000000000000000000000020" +
   428  			"0000000000000000000000000000000000000000000000000000000000000002" +
   429  			"0000000000000000000000000000000000000000000000000000000000000001" +
   430  			"0000000000000000000000000000000000000000000000000000000000000002",
   431  		unpacked: []int16{1, 2},
   432  	},
   433  	{
   434  		def: `[{"type": "int16[2]"}]`,
   435  		packed: "0000000000000000000000000000000000000000000000000000000000000001" +
   436  			"0000000000000000000000000000000000000000000000000000000000000002",
   437  		unpacked: [2]int16{1, 2},
   438  	},
   439  	{
   440  		def: `[{"type": "int32[]"}]`,
   441  		packed: "0000000000000000000000000000000000000000000000000000000000000020" +
   442  			"0000000000000000000000000000000000000000000000000000000000000002" +
   443  			"0000000000000000000000000000000000000000000000000000000000000001" +
   444  			"0000000000000000000000000000000000000000000000000000000000000002",
   445  		unpacked: []int32{1, 2},
   446  	},
   447  	{
   448  		def: `[{"type": "int32[2]"}]`,
   449  		packed: "0000000000000000000000000000000000000000000000000000000000000001" +
   450  			"0000000000000000000000000000000000000000000000000000000000000002",
   451  		unpacked: [2]int32{1, 2},
   452  	},
   453  	{
   454  		def: `[{"type": "int64[]"}]`,
   455  		packed: "0000000000000000000000000000000000000000000000000000000000000020" +
   456  			"0000000000000000000000000000000000000000000000000000000000000002" +
   457  			"0000000000000000000000000000000000000000000000000000000000000001" +
   458  			"0000000000000000000000000000000000000000000000000000000000000002",
   459  		unpacked: []int64{1, 2},
   460  	},
   461  	{
   462  		def: `[{"type": "int64[2]"}]`,
   463  		packed: "0000000000000000000000000000000000000000000000000000000000000001" +
   464  			"0000000000000000000000000000000000000000000000000000000000000002",
   465  		unpacked: [2]int64{1, 2},
   466  	},
   467  	{
   468  		def: `[{"type": "int256[]"}]`,
   469  		packed: "0000000000000000000000000000000000000000000000000000000000000020" +
   470  			"0000000000000000000000000000000000000000000000000000000000000002" +
   471  			"0000000000000000000000000000000000000000000000000000000000000001" +
   472  			"0000000000000000000000000000000000000000000000000000000000000002",
   473  		unpacked: []*big.Int{big.NewInt(1), big.NewInt(2)},
   474  	},
   475  	{
   476  		def: `[{"type": "int256[3]"}]`,
   477  		packed: "0000000000000000000000000000000000000000000000000000000000000001" +
   478  			"0000000000000000000000000000000000000000000000000000000000000002" +
   479  			"0000000000000000000000000000000000000000000000000000000000000003",
   480  		unpacked: [3]*big.Int{big.NewInt(1), big.NewInt(2), big.NewInt(3)},
   481  	},
   482  	// multi dimensional, if these pass, all types that don't require length prefix should pass
   483  	{
   484  		def: `[{"type": "uint8[][]"}]`,
   485  		packed: "0000000000000000000000000000000000000000000000000000000000000020" +
   486  			"0000000000000000000000000000000000000000000000000000000000000000",
   487  		unpacked: [][]uint8{},
   488  	},
   489  	{
   490  		def: `[{"type": "uint8[][]"}]`,
   491  		packed: "0000000000000000000000000000000000000000000000000000000000000020" +
   492  			"0000000000000000000000000000000000000000000000000000000000000002" +
   493  			"0000000000000000000000000000000000000000000000000000000000000040" +
   494  			"00000000000000000000000000000000000000000000000000000000000000a0" +
   495  			"0000000000000000000000000000000000000000000000000000000000000002" +
   496  			"0000000000000000000000000000000000000000000000000000000000000001" +
   497  			"0000000000000000000000000000000000000000000000000000000000000002" +
   498  			"0000000000000000000000000000000000000000000000000000000000000002" +
   499  			"0000000000000000000000000000000000000000000000000000000000000001" +
   500  			"0000000000000000000000000000000000000000000000000000000000000002",
   501  		unpacked: [][]uint8{{1, 2}, {1, 2}},
   502  	},
   503  	{
   504  		def: `[{"type": "uint8[][]"}]`,
   505  		packed: "0000000000000000000000000000000000000000000000000000000000000020" +
   506  			"0000000000000000000000000000000000000000000000000000000000000002" +
   507  			"0000000000000000000000000000000000000000000000000000000000000040" +
   508  			"00000000000000000000000000000000000000000000000000000000000000a0" +
   509  			"0000000000000000000000000000000000000000000000000000000000000002" +
   510  			"0000000000000000000000000000000000000000000000000000000000000001" +
   511  			"0000000000000000000000000000000000000000000000000000000000000002" +
   512  			"0000000000000000000000000000000000000000000000000000000000000003" +
   513  			"0000000000000000000000000000000000000000000000000000000000000001" +
   514  			"0000000000000000000000000000000000000000000000000000000000000002" +
   515  			"0000000000000000000000000000000000000000000000000000000000000003",
   516  		unpacked: [][]uint8{{1, 2}, {1, 2, 3}},
   517  	},
   518  	{
   519  		def: `[{"type": "uint8[2][2]"}]`,
   520  		packed: "0000000000000000000000000000000000000000000000000000000000000001" +
   521  			"0000000000000000000000000000000000000000000000000000000000000002" +
   522  			"0000000000000000000000000000000000000000000000000000000000000001" +
   523  			"0000000000000000000000000000000000000000000000000000000000000002",
   524  		unpacked: [2][2]uint8{{1, 2}, {1, 2}},
   525  	},
   526  	{
   527  		def: `[{"type": "uint8[][2]"}]`,
   528  		packed: "0000000000000000000000000000000000000000000000000000000000000020" +
   529  			"0000000000000000000000000000000000000000000000000000000000000040" +
   530  			"0000000000000000000000000000000000000000000000000000000000000060" +
   531  			"0000000000000000000000000000000000000000000000000000000000000000" +
   532  			"0000000000000000000000000000000000000000000000000000000000000000",
   533  		unpacked: [2][]uint8{{}, {}},
   534  	},
   535  	{
   536  		def: `[{"type": "uint8[][2]"}]`,
   537  		packed: "0000000000000000000000000000000000000000000000000000000000000020" +
   538  			"0000000000000000000000000000000000000000000000000000000000000040" +
   539  			"0000000000000000000000000000000000000000000000000000000000000080" +
   540  			"0000000000000000000000000000000000000000000000000000000000000001" +
   541  			"0000000000000000000000000000000000000000000000000000000000000001" +
   542  			"0000000000000000000000000000000000000000000000000000000000000001" +
   543  			"0000000000000000000000000000000000000000000000000000000000000001",
   544  		unpacked: [2][]uint8{{1}, {1}},
   545  	},
   546  	{
   547  		def: `[{"type": "uint8[2][]"}]`,
   548  		packed: "0000000000000000000000000000000000000000000000000000000000000020" +
   549  			"0000000000000000000000000000000000000000000000000000000000000000",
   550  		unpacked: [][2]uint8{},
   551  	},
   552  	{
   553  		def: `[{"type": "uint8[2][]"}]`,
   554  		packed: "0000000000000000000000000000000000000000000000000000000000000020" +
   555  			"0000000000000000000000000000000000000000000000000000000000000001" +
   556  			"0000000000000000000000000000000000000000000000000000000000000001" +
   557  			"0000000000000000000000000000000000000000000000000000000000000002",
   558  		unpacked: [][2]uint8{{1, 2}},
   559  	},
   560  	{
   561  		def: `[{"type": "uint8[2][]"}]`,
   562  		packed: "0000000000000000000000000000000000000000000000000000000000000020" +
   563  			"0000000000000000000000000000000000000000000000000000000000000002" +
   564  			"0000000000000000000000000000000000000000000000000000000000000001" +
   565  			"0000000000000000000000000000000000000000000000000000000000000002" +
   566  			"0000000000000000000000000000000000000000000000000000000000000001" +
   567  			"0000000000000000000000000000000000000000000000000000000000000002",
   568  		unpacked: [][2]uint8{{1, 2}, {1, 2}},
   569  	},
   570  	{
   571  		def: `[{"type": "uint16[]"}]`,
   572  		packed: "0000000000000000000000000000000000000000000000000000000000000020" +
   573  			"0000000000000000000000000000000000000000000000000000000000000002" +
   574  			"0000000000000000000000000000000000000000000000000000000000000001" +
   575  			"0000000000000000000000000000000000000000000000000000000000000002",
   576  		unpacked: []uint16{1, 2},
   577  	},
   578  	{
   579  		def: `[{"type": "uint16[2]"}]`,
   580  		packed: "0000000000000000000000000000000000000000000000000000000000000001" +
   581  			"0000000000000000000000000000000000000000000000000000000000000002",
   582  		unpacked: [2]uint16{1, 2},
   583  	},
   584  	{
   585  		def: `[{"type": "uint32[]"}]`,
   586  		packed: "0000000000000000000000000000000000000000000000000000000000000020" +
   587  			"0000000000000000000000000000000000000000000000000000000000000002" +
   588  			"0000000000000000000000000000000000000000000000000000000000000001" +
   589  			"0000000000000000000000000000000000000000000000000000000000000002",
   590  		unpacked: []uint32{1, 2},
   591  	},
   592  	{
   593  		def:      `[{"type": "uint32[2][3][4]"}]`,
   594  		unpacked: [4][3][2]uint32{{{1, 2}, {3, 4}, {5, 6}}, {{7, 8}, {9, 10}, {11, 12}}, {{13, 14}, {15, 16}, {17, 18}}, {{19, 20}, {21, 22}, {23, 24}}},
   595  		packed: "0000000000000000000000000000000000000000000000000000000000000001" +
   596  			"0000000000000000000000000000000000000000000000000000000000000002" +
   597  			"0000000000000000000000000000000000000000000000000000000000000003" +
   598  			"0000000000000000000000000000000000000000000000000000000000000004" +
   599  			"0000000000000000000000000000000000000000000000000000000000000005" +
   600  			"0000000000000000000000000000000000000000000000000000000000000006" +
   601  			"0000000000000000000000000000000000000000000000000000000000000007" +
   602  			"0000000000000000000000000000000000000000000000000000000000000008" +
   603  			"0000000000000000000000000000000000000000000000000000000000000009" +
   604  			"000000000000000000000000000000000000000000000000000000000000000a" +
   605  			"000000000000000000000000000000000000000000000000000000000000000b" +
   606  			"000000000000000000000000000000000000000000000000000000000000000c" +
   607  			"000000000000000000000000000000000000000000000000000000000000000d" +
   608  			"000000000000000000000000000000000000000000000000000000000000000e" +
   609  			"000000000000000000000000000000000000000000000000000000000000000f" +
   610  			"0000000000000000000000000000000000000000000000000000000000000010" +
   611  			"0000000000000000000000000000000000000000000000000000000000000011" +
   612  			"0000000000000000000000000000000000000000000000000000000000000012" +
   613  			"0000000000000000000000000000000000000000000000000000000000000013" +
   614  			"0000000000000000000000000000000000000000000000000000000000000014" +
   615  			"0000000000000000000000000000000000000000000000000000000000000015" +
   616  			"0000000000000000000000000000000000000000000000000000000000000016" +
   617  			"0000000000000000000000000000000000000000000000000000000000000017" +
   618  			"0000000000000000000000000000000000000000000000000000000000000018",
   619  	},
   620  
   621  	{
   622  		def:      `[{"type": "bytes32[]"}]`,
   623  		unpacked: [][32]byte{{1}, {2}},
   624  		packed: "0000000000000000000000000000000000000000000000000000000000000020" +
   625  			"0000000000000000000000000000000000000000000000000000000000000002" +
   626  			"0100000000000000000000000000000000000000000000000000000000000000" +
   627  			"0200000000000000000000000000000000000000000000000000000000000000",
   628  	},
   629  	{
   630  		def: `[{"type": "uint32[2]"}]`,
   631  		packed: "0000000000000000000000000000000000000000000000000000000000000001" +
   632  			"0000000000000000000000000000000000000000000000000000000000000002",
   633  		unpacked: [2]uint32{1, 2},
   634  	},
   635  	{
   636  		def: `[{"type": "uint64[]"}]`,
   637  		packed: "0000000000000000000000000000000000000000000000000000000000000020" +
   638  			"0000000000000000000000000000000000000000000000000000000000000002" +
   639  			"0000000000000000000000000000000000000000000000000000000000000001" +
   640  			"0000000000000000000000000000000000000000000000000000000000000002",
   641  		unpacked: []uint64{1, 2},
   642  	},
   643  	{
   644  		def: `[{"type": "uint64[2]"}]`,
   645  		packed: "0000000000000000000000000000000000000000000000000000000000000001" +
   646  			"0000000000000000000000000000000000000000000000000000000000000002",
   647  		unpacked: [2]uint64{1, 2},
   648  	},
   649  	{
   650  		def: `[{"type": "uint256[]"}]`,
   651  		packed: "0000000000000000000000000000000000000000000000000000000000000020" +
   652  			"0000000000000000000000000000000000000000000000000000000000000002" +
   653  			"0000000000000000000000000000000000000000000000000000000000000001" +
   654  			"0000000000000000000000000000000000000000000000000000000000000002",
   655  		unpacked: []*big.Int{big.NewInt(1), big.NewInt(2)},
   656  	},
   657  	{
   658  		def: `[{"type": "uint256[3]"}]`,
   659  		packed: "0000000000000000000000000000000000000000000000000000000000000001" +
   660  			"0000000000000000000000000000000000000000000000000000000000000002" +
   661  			"0000000000000000000000000000000000000000000000000000000000000003",
   662  		unpacked: [3]*big.Int{big.NewInt(1), big.NewInt(2), big.NewInt(3)},
   663  	},
   664  	{
   665  		def:      `[{"type": "string[4]"}]`,
   666  		packed:   "0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000000548656c6c6f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005576f726c640000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007476f2d436f7265000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004436f726500000000000000000000000000000000000000000000000000000000",
   667  		unpacked: [4]string{"Hello", "World", "Go-Core", "Core"},
   668  	},
   669  	{
   670  		def:      `[{"type": "string[]"}]`,
   671  		packed:   "00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000004436f7265000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007676f2d636f726500000000000000000000000000000000000000000000000000",
   672  		unpacked: []string{"Core", "go-core"},
   673  	},
   674  	{
   675  		def: `[{"type": "bytes[]"}]`,
   676  		packed: "0000000000000000000000000000000000000000000000000000000000000020" +
   677  			"0000000000000000000000000000000000000000000000000000000000000002" +
   678  			"0000000000000000000000000000000000000000000000000000000000000040" +
   679  			"0000000000000000000000000000000000000000000000000000000000000080" +
   680  			"0000000000000000000000000000000000000000000000000000000000000003" +
   681  			"f0f0f00000000000000000000000000000000000000000000000000000000000" +
   682  			"0000000000000000000000000000000000000000000000000000000000000003" +
   683  			"f0f0f00000000000000000000000000000000000000000000000000000000000",
   684  		unpacked: [][]byte{{0xf0, 0xf0, 0xf0}, {0xf0, 0xf0, 0xf0}},
   685  	},
   686  	{
   687  		def: `[{"type": "uint256[2][][]"}]`,
   688  		packed: "0000000000000000000000000000000000000000000000000000000000000020" +
   689  			"0000000000000000000000000000000000000000000000000000000000000002" +
   690  			"0000000000000000000000000000000000000000000000000000000000000040" +
   691  			"00000000000000000000000000000000000000000000000000000000000000e0" +
   692  			"0000000000000000000000000000000000000000000000000000000000000002" +
   693  			"0000000000000000000000000000000000000000000000000000000000000001" +
   694  			"00000000000000000000000000000000000000000000000000000000000000c8" +
   695  			"0000000000000000000000000000000000000000000000000000000000000001" +
   696  			"00000000000000000000000000000000000000000000000000000000000003e8" +
   697  			"0000000000000000000000000000000000000000000000000000000000000002" +
   698  			"0000000000000000000000000000000000000000000000000000000000000001" +
   699  			"00000000000000000000000000000000000000000000000000000000000000c8" +
   700  			"0000000000000000000000000000000000000000000000000000000000000001" +
   701  			"00000000000000000000000000000000000000000000000000000000000003e8",
   702  		unpacked: [][][2]*big.Int{{{big.NewInt(1), big.NewInt(200)}, {big.NewInt(1), big.NewInt(1000)}}, {{big.NewInt(1), big.NewInt(200)}, {big.NewInt(1), big.NewInt(1000)}}},
   703  	},
   704  	// struct outputs
   705  	{
   706  		def: `[{"components": [{"name":"int1","type":"int256"},{"name":"int2","type":"int256"}], "type":"tuple"}]`,
   707  		packed: "0000000000000000000000000000000000000000000000000000000000000001" +
   708  			"0000000000000000000000000000000000000000000000000000000000000002",
   709  		unpacked: struct {
   710  			Int1 *big.Int
   711  			Int2 *big.Int
   712  		}{big.NewInt(1), big.NewInt(2)},
   713  	},
   714  	{
   715  		def:    `[{"components": [{"name":"int_one","type":"int256"}], "type":"tuple"}]`,
   716  		packed: "0000000000000000000000000000000000000000000000000000000000000001",
   717  		unpacked: struct {
   718  			IntOne *big.Int
   719  		}{big.NewInt(1)},
   720  	},
   721  	{
   722  		def:    `[{"components": [{"name":"int__one","type":"int256"}], "type":"tuple"}]`,
   723  		packed: "0000000000000000000000000000000000000000000000000000000000000001",
   724  		unpacked: struct {
   725  			IntOne *big.Int
   726  		}{big.NewInt(1)},
   727  	},
   728  	{
   729  		def:    `[{"components": [{"name":"int_one_","type":"int256"}], "type":"tuple"}]`,
   730  		packed: "0000000000000000000000000000000000000000000000000000000000000001",
   731  		unpacked: struct {
   732  			IntOne *big.Int
   733  		}{big.NewInt(1)},
   734  	},
   735  	{
   736  		def: `[{"components": [{"name":"int_one","type":"int256"}, {"name":"intone","type":"int256"}], "type":"tuple"}]`,
   737  		packed: "0000000000000000000000000000000000000000000000000000000000000001" +
   738  			"0000000000000000000000000000000000000000000000000000000000000002",
   739  		unpacked: struct {
   740  			IntOne *big.Int
   741  			Intone *big.Int
   742  		}{big.NewInt(1), big.NewInt(2)},
   743  	},
   744  	{
   745  		def:      `[{"type": "string"}]`,
   746  		unpacked: "foobar",
   747  		packed: "0000000000000000000000000000000000000000000000000000000000000020" +
   748  			"0000000000000000000000000000000000000000000000000000000000000006" +
   749  			"666f6f6261720000000000000000000000000000000000000000000000000000",
   750  	},
   751  	{
   752  		def:      `[{"type": "string[]"}]`,
   753  		unpacked: []string{"hello", "foobar"},
   754  		packed: "0000000000000000000000000000000000000000000000000000000000000020" +
   755  			"0000000000000000000000000000000000000000000000000000000000000002" + // len(array) = 2
   756  			"0000000000000000000000000000000000000000000000000000000000000040" + // offset 64 to i = 0
   757  			"0000000000000000000000000000000000000000000000000000000000000080" + // offset 128 to i = 1
   758  			"0000000000000000000000000000000000000000000000000000000000000005" + // len(str[0]) = 5
   759  			"68656c6c6f000000000000000000000000000000000000000000000000000000" + // str[0]
   760  			"0000000000000000000000000000000000000000000000000000000000000006" + // len(str[1]) = 6
   761  			"666f6f6261720000000000000000000000000000000000000000000000000000", // str[1]
   762  	},
   763  	{
   764  		def:      `[{"type": "string[2]"}]`,
   765  		unpacked: [2]string{"hello", "foobar"},
   766  		packed: "0000000000000000000000000000000000000000000000000000000000000020" +
   767  			"0000000000000000000000000000000000000000000000000000000000000040" + // offset to i = 0
   768  			"0000000000000000000000000000000000000000000000000000000000000080" + // offset to i = 1
   769  			"0000000000000000000000000000000000000000000000000000000000000005" + // len(str[0]) = 5
   770  			"68656c6c6f000000000000000000000000000000000000000000000000000000" + // str[0]
   771  			"0000000000000000000000000000000000000000000000000000000000000006" + // len(str[1]) = 6
   772  			"666f6f6261720000000000000000000000000000000000000000000000000000", // str[1]
   773  	},
   774  	{
   775  		def:      `[{"type": "bytes32[][]"}]`,
   776  		unpacked: [][][32]byte{{{1}, {2}}, {{3}, {4}, {5}}},
   777  		packed: "0000000000000000000000000000000000000000000000000000000000000020" +
   778  			"0000000000000000000000000000000000000000000000000000000000000002" + // len(array) = 2
   779  			"0000000000000000000000000000000000000000000000000000000000000040" + // offset 64 to i = 0
   780  			"00000000000000000000000000000000000000000000000000000000000000a0" + // offset 160 to i = 1
   781  			"0000000000000000000000000000000000000000000000000000000000000002" + // len(array[0]) = 2
   782  			"0100000000000000000000000000000000000000000000000000000000000000" + // array[0][0]
   783  			"0200000000000000000000000000000000000000000000000000000000000000" + // array[0][1]
   784  			"0000000000000000000000000000000000000000000000000000000000000003" + // len(array[1]) = 3
   785  			"0300000000000000000000000000000000000000000000000000000000000000" + // array[1][0]
   786  			"0400000000000000000000000000000000000000000000000000000000000000" + // array[1][1]
   787  			"0500000000000000000000000000000000000000000000000000000000000000", // array[1][2]
   788  	},
   789  	{
   790  		def:      `[{"type": "bytes32[][2]"}]`,
   791  		unpacked: [2][][32]byte{{{1}, {2}}, {{3}, {4}, {5}}},
   792  		packed: "0000000000000000000000000000000000000000000000000000000000000020" +
   793  			"0000000000000000000000000000000000000000000000000000000000000040" + // offset 64 to i = 0
   794  			"00000000000000000000000000000000000000000000000000000000000000a0" + // offset 160 to i = 1
   795  			"0000000000000000000000000000000000000000000000000000000000000002" + // len(array[0]) = 2
   796  			"0100000000000000000000000000000000000000000000000000000000000000" + // array[0][0]
   797  			"0200000000000000000000000000000000000000000000000000000000000000" + // array[0][1]
   798  			"0000000000000000000000000000000000000000000000000000000000000003" + // len(array[1]) = 3
   799  			"0300000000000000000000000000000000000000000000000000000000000000" + // array[1][0]
   800  			"0400000000000000000000000000000000000000000000000000000000000000" + // array[1][1]
   801  			"0500000000000000000000000000000000000000000000000000000000000000", // array[1][2]
   802  	},
   803  	{
   804  		def:      `[{"type": "bytes32[3][2]"}]`,
   805  		unpacked: [2][3][32]byte{{{1}, {2}, {3}}, {{3}, {4}, {5}}},
   806  		packed: "0100000000000000000000000000000000000000000000000000000000000000" + // array[0][0]
   807  			"0200000000000000000000000000000000000000000000000000000000000000" + // array[0][1]
   808  			"0300000000000000000000000000000000000000000000000000000000000000" + // array[0][2]
   809  			"0300000000000000000000000000000000000000000000000000000000000000" + // array[1][0]
   810  			"0400000000000000000000000000000000000000000000000000000000000000" + // array[1][1]
   811  			"0500000000000000000000000000000000000000000000000000000000000000", // array[1][2]
   812  	},
   813  	{
   814  		// static tuple
   815  		def: `[{"components": [{"name":"a","type":"int64"}, 
   816  		{"name":"b","type":"int256"}, 
   817  		{"name":"c","type":"int256"}, 
   818  		{"name":"d","type":"bool"},
   819  		{"name":"e","type":"bytes32[3][2]"}], "type":"tuple"}]`,
   820  		unpacked: struct {
   821  			A int64
   822  			B *big.Int
   823  			C *big.Int
   824  			D bool
   825  			E [2][3][32]byte
   826  		}{1, big.NewInt(1), big.NewInt(-1), true, [2][3][32]byte{{{1}, {2}, {3}}, {{3}, {4}, {5}}}},
   827  		packed: "0000000000000000000000000000000000000000000000000000000000000001" + // struct[a]
   828  			"0000000000000000000000000000000000000000000000000000000000000001" + // struct[b]
   829  			"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" + // struct[c]
   830  			"0000000000000000000000000000000000000000000000000000000000000001" + // struct[d]
   831  			"0100000000000000000000000000000000000000000000000000000000000000" + // struct[e] array[0][0]
   832  			"0200000000000000000000000000000000000000000000000000000000000000" + // struct[e] array[0][1]
   833  			"0300000000000000000000000000000000000000000000000000000000000000" + // struct[e] array[0][2]
   834  			"0300000000000000000000000000000000000000000000000000000000000000" + // struct[e] array[1][0]
   835  			"0400000000000000000000000000000000000000000000000000000000000000" + // struct[e] array[1][1]
   836  			"0500000000000000000000000000000000000000000000000000000000000000", // struct[e] array[1][2]
   837  	},
   838  	{
   839  		def: `[{"components": [{"name":"a","type":"string"}, 
   840  		{"name":"b","type":"int64"}, 
   841  		{"name":"c","type":"bytes"}, 
   842  		{"name":"d","type":"string[]"},
   843  		{"name":"e","type":"int256[]"},
   844  		{"name":"f","type":"address[]"}], "type":"tuple"}]`,
   845  		unpacked: struct {
   846  			A string
   847  			B int64
   848  			C []byte
   849  			D []string
   850  			E []*big.Int
   851  			F []common.Address
   852  		}{"foobar", 1, []byte{1}, []string{"foo", "bar"}, []*big.Int{big.NewInt(1), big.NewInt(-1)}, []common.Address{{1}, {2}}},
   853  		packed: "0000000000000000000000000000000000000000000000000000000000000020" + // struct a
   854  			"00000000000000000000000000000000000000000000000000000000000000c0" + // struct[a] offset
   855  			"0000000000000000000000000000000000000000000000000000000000000001" + // struct[b]
   856  			"0000000000000000000000000000000000000000000000000000000000000100" + // struct[c] offset
   857  			"0000000000000000000000000000000000000000000000000000000000000140" + // struct[d] offset
   858  			"0000000000000000000000000000000000000000000000000000000000000220" + // struct[e] offset
   859  			"0000000000000000000000000000000000000000000000000000000000000280" + // struct[f] offset
   860  			"0000000000000000000000000000000000000000000000000000000000000006" + // struct[a] length
   861  			"666f6f6261720000000000000000000000000000000000000000000000000000" + // struct[a] "foobar"
   862  			"0000000000000000000000000000000000000000000000000000000000000001" + // struct[c] length
   863  			"0100000000000000000000000000000000000000000000000000000000000000" + // []byte{1}
   864  			"0000000000000000000000000000000000000000000000000000000000000002" + // struct[d] length
   865  			"0000000000000000000000000000000000000000000000000000000000000040" + // foo offset
   866  			"0000000000000000000000000000000000000000000000000000000000000080" + // bar offset
   867  			"0000000000000000000000000000000000000000000000000000000000000003" + // foo length
   868  			"666f6f0000000000000000000000000000000000000000000000000000000000" + // foo
   869  			"0000000000000000000000000000000000000000000000000000000000000003" + // bar offset
   870  			"6261720000000000000000000000000000000000000000000000000000000000" + // bar
   871  			"0000000000000000000000000000000000000000000000000000000000000002" + // struct[e] length
   872  			"0000000000000000000000000000000000000000000000000000000000000001" + // 1
   873  			"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" + // -1
   874  			"0000000000000000000000000000000000000000000000000000000000000002" + // struct[f] length
   875  			"0000000000000000000001000000000000000000000000000000000000000000" + // common.Address{1}
   876  			"0000000000000000000002000000000000000000000000000000000000000000", // common.Address{2}
   877  	},
   878  	{
   879  		def: `[{"components": [{ "type": "tuple","components": [{"name": "a","type": "uint256"},	
   880  							{"name": "b","type": "uint256[]"}],	
   881  							"name": "a","type": "tuple"},
   882  							{"name": "b","type": "uint256[]"}],  "type": "tuple"}]`,
   883  		unpacked: struct {
   884  			A struct {
   885  				A *big.Int
   886  				B []*big.Int
   887  			}
   888  			B []*big.Int
   889  		}{
   890  			A: struct {
   891  				A *big.Int
   892  				B []*big.Int
   893  			}{big.NewInt(1), []*big.Int{big.NewInt(1), big.NewInt(2)}},
   894  			B: []*big.Int{big.NewInt(1), big.NewInt(2)}},
   895  		packed: "0000000000000000000000000000000000000000000000000000000000000020" + // struct a
   896  			"0000000000000000000000000000000000000000000000000000000000000040" + // a offset
   897  			"00000000000000000000000000000000000000000000000000000000000000e0" + // b offset
   898  			"0000000000000000000000000000000000000000000000000000000000000001" + // a.a value
   899  			"0000000000000000000000000000000000000000000000000000000000000040" + // a.b offset
   900  			"0000000000000000000000000000000000000000000000000000000000000002" + // a.b length
   901  			"0000000000000000000000000000000000000000000000000000000000000001" + // a.b[0] value
   902  			"0000000000000000000000000000000000000000000000000000000000000002" + // a.b[1] value
   903  			"0000000000000000000000000000000000000000000000000000000000000002" + // b length
   904  			"0000000000000000000000000000000000000000000000000000000000000001" + // b[0] value
   905  			"0000000000000000000000000000000000000000000000000000000000000002", // b[1] value
   906  	},
   907  
   908  	{
   909  		def: `[{"components": [{"name": "a","type": "int256"},	
   910  							{"name": "b","type": "int256[]"}],	
   911  							"name": "a","type": "tuple[]"}]`,
   912  		unpacked: []struct {
   913  			A *big.Int
   914  			B []*big.Int
   915  		}{
   916  			{big.NewInt(-1), []*big.Int{big.NewInt(1), big.NewInt(3)}},
   917  			{big.NewInt(1), []*big.Int{big.NewInt(2), big.NewInt(-1)}},
   918  		},
   919  		packed: "0000000000000000000000000000000000000000000000000000000000000020" +
   920  			"0000000000000000000000000000000000000000000000000000000000000002" + // tuple length
   921  			"0000000000000000000000000000000000000000000000000000000000000040" + // tuple[0] offset
   922  			"00000000000000000000000000000000000000000000000000000000000000e0" + // tuple[1] offset
   923  			"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" + // tuple[0].A
   924  			"0000000000000000000000000000000000000000000000000000000000000040" + // tuple[0].B offset
   925  			"0000000000000000000000000000000000000000000000000000000000000002" + // tuple[0].B length
   926  			"0000000000000000000000000000000000000000000000000000000000000001" + // tuple[0].B[0] value
   927  			"0000000000000000000000000000000000000000000000000000000000000003" + // tuple[0].B[1] value
   928  			"0000000000000000000000000000000000000000000000000000000000000001" + // tuple[1].A
   929  			"0000000000000000000000000000000000000000000000000000000000000040" + // tuple[1].B offset
   930  			"0000000000000000000000000000000000000000000000000000000000000002" + // tuple[1].B length
   931  			"0000000000000000000000000000000000000000000000000000000000000002" + // tuple[1].B[0] value
   932  			"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", // tuple[1].B[1] value
   933  	},
   934  	{
   935  		def: `[{"components": [{"name": "a","type": "int256"},	
   936  							{"name": "b","type": "int256"}],	
   937  							"name": "a","type": "tuple[2]"}]`,
   938  		unpacked: [2]struct {
   939  			A *big.Int
   940  			B *big.Int
   941  		}{
   942  			{big.NewInt(-1), big.NewInt(1)},
   943  			{big.NewInt(1), big.NewInt(-1)},
   944  		},
   945  		packed: "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" + // tuple[0].a
   946  			"0000000000000000000000000000000000000000000000000000000000000001" + // tuple[0].b
   947  			"0000000000000000000000000000000000000000000000000000000000000001" + // tuple[1].a
   948  			"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", // tuple[1].b
   949  	},
   950  	{
   951  		def: `[{"components": [{"name": "a","type": "int256[]"}],
   952  							"name": "a","type": "tuple[2]"}]`,
   953  		unpacked: [2]struct {
   954  			A []*big.Int
   955  		}{
   956  			{[]*big.Int{big.NewInt(-1), big.NewInt(1)}},
   957  			{[]*big.Int{big.NewInt(1), big.NewInt(-1)}},
   958  		},
   959  		packed: "0000000000000000000000000000000000000000000000000000000000000020" +
   960  			"0000000000000000000000000000000000000000000000000000000000000040" + // tuple[0] offset
   961  			"00000000000000000000000000000000000000000000000000000000000000c0" + // tuple[1] offset
   962  			"0000000000000000000000000000000000000000000000000000000000000020" + // tuple[0].A offset
   963  			"0000000000000000000000000000000000000000000000000000000000000002" + // tuple[0].A length
   964  			"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" + // tuple[0].A[0]
   965  			"0000000000000000000000000000000000000000000000000000000000000001" + // tuple[0].A[1]
   966  			"0000000000000000000000000000000000000000000000000000000000000020" + // tuple[1].A offset
   967  			"0000000000000000000000000000000000000000000000000000000000000002" + // tuple[1].A length
   968  			"0000000000000000000000000000000000000000000000000000000000000001" + // tuple[1].A[0]
   969  			"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", // tuple[1].A[1]
   970  	},
   971  }