github.com/ava-labs/subnet-evm@v0.6.4/accounts/abi/packing_test.go (about)

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