github.com/jimmyx0x/go-ethereum@v1.10.28/accounts/abi/packing_test.go (about)

     1  // Copyright 2020 The go-ethereum Authors
     2  // This file is part of the go-ethereum library.
     3  //
     4  // The go-ethereum 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-ethereum 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-ethereum library. If not, see <http://www.gnu.org/licenses/>.
    16  
    17  package abi
    18  
    19  import (
    20  	"math/big"
    21  
    22  	"github.com/ethereum/go-ethereum/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:   "0000000000000000000000000100000000000000000000000000000000000000",
   198  		unpacked: common.Address{1},
   199  	},
   200  	{
   201  		def:      `[{"type": "address[]"}]`,
   202  		unpacked: []common.Address{{1}, {2}},
   203  		packed: "0000000000000000000000000000000000000000000000000000000000000020" +
   204  			"0000000000000000000000000000000000000000000000000000000000000002" +
   205  			"0000000000000000000000000100000000000000000000000000000000000000" +
   206  			"0000000000000000000000000200000000000000000000000000000000000000",
   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:   "0100000000000000000000000000000000000000000000000000000000000000",
   390  		unpacked: [24]byte{1},
   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: "0000000000000000000000000000000000000000000000000000000000000020" +
   667  			"0000000000000000000000000000000000000000000000000000000000000080" +
   668  			"00000000000000000000000000000000000000000000000000000000000000c0" +
   669  			"0000000000000000000000000000000000000000000000000000000000000100" +
   670  			"0000000000000000000000000000000000000000000000000000000000000140" +
   671  			"0000000000000000000000000000000000000000000000000000000000000005" +
   672  			"48656c6c6f000000000000000000000000000000000000000000000000000000" +
   673  			"0000000000000000000000000000000000000000000000000000000000000005" +
   674  			"576f726c64000000000000000000000000000000000000000000000000000000" +
   675  			"000000000000000000000000000000000000000000000000000000000000000b" +
   676  			"476f2d657468657265756d000000000000000000000000000000000000000000" +
   677  			"0000000000000000000000000000000000000000000000000000000000000008" +
   678  			"457468657265756d000000000000000000000000000000000000000000000000",
   679  		unpacked: [4]string{"Hello", "World", "Go-ethereum", "Ethereum"},
   680  	},
   681  	{
   682  		def: `[{"type": "string[]"}]`,
   683  		packed: "0000000000000000000000000000000000000000000000000000000000000020" +
   684  			"0000000000000000000000000000000000000000000000000000000000000002" +
   685  			"0000000000000000000000000000000000000000000000000000000000000040" +
   686  			"0000000000000000000000000000000000000000000000000000000000000080" +
   687  			"0000000000000000000000000000000000000000000000000000000000000008" +
   688  			"457468657265756d000000000000000000000000000000000000000000000000" +
   689  			"000000000000000000000000000000000000000000000000000000000000000b" +
   690  			"676f2d657468657265756d000000000000000000000000000000000000000000",
   691  		unpacked: []string{"Ethereum", "go-ethereum"},
   692  	},
   693  	{
   694  		def: `[{"type": "bytes[]"}]`,
   695  		packed: "0000000000000000000000000000000000000000000000000000000000000020" +
   696  			"0000000000000000000000000000000000000000000000000000000000000002" +
   697  			"0000000000000000000000000000000000000000000000000000000000000040" +
   698  			"0000000000000000000000000000000000000000000000000000000000000080" +
   699  			"0000000000000000000000000000000000000000000000000000000000000003" +
   700  			"f0f0f00000000000000000000000000000000000000000000000000000000000" +
   701  			"0000000000000000000000000000000000000000000000000000000000000003" +
   702  			"f0f0f00000000000000000000000000000000000000000000000000000000000",
   703  		unpacked: [][]byte{{0xf0, 0xf0, 0xf0}, {0xf0, 0xf0, 0xf0}},
   704  	},
   705  	{
   706  		def: `[{"type": "uint256[2][][]"}]`,
   707  		packed: "0000000000000000000000000000000000000000000000000000000000000020" +
   708  			"0000000000000000000000000000000000000000000000000000000000000002" +
   709  			"0000000000000000000000000000000000000000000000000000000000000040" +
   710  			"00000000000000000000000000000000000000000000000000000000000000e0" +
   711  			"0000000000000000000000000000000000000000000000000000000000000002" +
   712  			"0000000000000000000000000000000000000000000000000000000000000001" +
   713  			"00000000000000000000000000000000000000000000000000000000000000c8" +
   714  			"0000000000000000000000000000000000000000000000000000000000000001" +
   715  			"00000000000000000000000000000000000000000000000000000000000003e8" +
   716  			"0000000000000000000000000000000000000000000000000000000000000002" +
   717  			"0000000000000000000000000000000000000000000000000000000000000001" +
   718  			"00000000000000000000000000000000000000000000000000000000000000c8" +
   719  			"0000000000000000000000000000000000000000000000000000000000000001" +
   720  			"00000000000000000000000000000000000000000000000000000000000003e8",
   721  		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)}}},
   722  	},
   723  	// struct outputs
   724  	{
   725  		def: `[{"components": [{"name":"int1","type":"int256"},{"name":"int2","type":"int256"}], "type":"tuple"}]`,
   726  		packed: "0000000000000000000000000000000000000000000000000000000000000001" +
   727  			"0000000000000000000000000000000000000000000000000000000000000002",
   728  		unpacked: struct {
   729  			Int1 *big.Int
   730  			Int2 *big.Int
   731  		}{big.NewInt(1), big.NewInt(2)},
   732  	},
   733  	{
   734  		def:    `[{"components": [{"name":"int_one","type":"int256"}], "type":"tuple"}]`,
   735  		packed: "0000000000000000000000000000000000000000000000000000000000000001",
   736  		unpacked: struct {
   737  			IntOne *big.Int
   738  		}{big.NewInt(1)},
   739  	},
   740  	{
   741  		def:    `[{"components": [{"name":"int__one","type":"int256"}], "type":"tuple"}]`,
   742  		packed: "0000000000000000000000000000000000000000000000000000000000000001",
   743  		unpacked: struct {
   744  			IntOne *big.Int
   745  		}{big.NewInt(1)},
   746  	},
   747  	{
   748  		def:    `[{"components": [{"name":"int_one_","type":"int256"}], "type":"tuple"}]`,
   749  		packed: "0000000000000000000000000000000000000000000000000000000000000001",
   750  		unpacked: struct {
   751  			IntOne *big.Int
   752  		}{big.NewInt(1)},
   753  	},
   754  	{
   755  		def: `[{"components": [{"name":"int_one","type":"int256"}, {"name":"intone","type":"int256"}], "type":"tuple"}]`,
   756  		packed: "0000000000000000000000000000000000000000000000000000000000000001" +
   757  			"0000000000000000000000000000000000000000000000000000000000000002",
   758  		unpacked: struct {
   759  			IntOne *big.Int
   760  			Intone *big.Int
   761  		}{big.NewInt(1), big.NewInt(2)},
   762  	},
   763  	{
   764  		def:      `[{"type": "string"}]`,
   765  		unpacked: "foobar",
   766  		packed: "0000000000000000000000000000000000000000000000000000000000000020" +
   767  			"0000000000000000000000000000000000000000000000000000000000000006" +
   768  			"666f6f6261720000000000000000000000000000000000000000000000000000",
   769  	},
   770  	{
   771  		def:      `[{"type": "string[]"}]`,
   772  		unpacked: []string{"hello", "foobar"},
   773  		packed: "0000000000000000000000000000000000000000000000000000000000000020" +
   774  			"0000000000000000000000000000000000000000000000000000000000000002" + // len(array) = 2
   775  			"0000000000000000000000000000000000000000000000000000000000000040" + // offset 64 to i = 0
   776  			"0000000000000000000000000000000000000000000000000000000000000080" + // offset 128 to i = 1
   777  			"0000000000000000000000000000000000000000000000000000000000000005" + // len(str[0]) = 5
   778  			"68656c6c6f000000000000000000000000000000000000000000000000000000" + // str[0]
   779  			"0000000000000000000000000000000000000000000000000000000000000006" + // len(str[1]) = 6
   780  			"666f6f6261720000000000000000000000000000000000000000000000000000", // str[1]
   781  	},
   782  	{
   783  		def:      `[{"type": "string[2]"}]`,
   784  		unpacked: [2]string{"hello", "foobar"},
   785  		packed: "0000000000000000000000000000000000000000000000000000000000000020" +
   786  			"0000000000000000000000000000000000000000000000000000000000000040" + // offset to i = 0
   787  			"0000000000000000000000000000000000000000000000000000000000000080" + // offset to i = 1
   788  			"0000000000000000000000000000000000000000000000000000000000000005" + // len(str[0]) = 5
   789  			"68656c6c6f000000000000000000000000000000000000000000000000000000" + // str[0]
   790  			"0000000000000000000000000000000000000000000000000000000000000006" + // len(str[1]) = 6
   791  			"666f6f6261720000000000000000000000000000000000000000000000000000", // str[1]
   792  	},
   793  	{
   794  		def:      `[{"type": "bytes32[][]"}]`,
   795  		unpacked: [][][32]byte{{{1}, {2}}, {{3}, {4}, {5}}},
   796  		packed: "0000000000000000000000000000000000000000000000000000000000000020" +
   797  			"0000000000000000000000000000000000000000000000000000000000000002" + // len(array) = 2
   798  			"0000000000000000000000000000000000000000000000000000000000000040" + // offset 64 to i = 0
   799  			"00000000000000000000000000000000000000000000000000000000000000a0" + // offset 160 to i = 1
   800  			"0000000000000000000000000000000000000000000000000000000000000002" + // len(array[0]) = 2
   801  			"0100000000000000000000000000000000000000000000000000000000000000" + // array[0][0]
   802  			"0200000000000000000000000000000000000000000000000000000000000000" + // array[0][1]
   803  			"0000000000000000000000000000000000000000000000000000000000000003" + // len(array[1]) = 3
   804  			"0300000000000000000000000000000000000000000000000000000000000000" + // array[1][0]
   805  			"0400000000000000000000000000000000000000000000000000000000000000" + // array[1][1]
   806  			"0500000000000000000000000000000000000000000000000000000000000000", // array[1][2]
   807  	},
   808  	{
   809  		def:      `[{"type": "bytes32[][2]"}]`,
   810  		unpacked: [2][][32]byte{{{1}, {2}}, {{3}, {4}, {5}}},
   811  		packed: "0000000000000000000000000000000000000000000000000000000000000020" +
   812  			"0000000000000000000000000000000000000000000000000000000000000040" + // offset 64 to i = 0
   813  			"00000000000000000000000000000000000000000000000000000000000000a0" + // offset 160 to i = 1
   814  			"0000000000000000000000000000000000000000000000000000000000000002" + // len(array[0]) = 2
   815  			"0100000000000000000000000000000000000000000000000000000000000000" + // array[0][0]
   816  			"0200000000000000000000000000000000000000000000000000000000000000" + // array[0][1]
   817  			"0000000000000000000000000000000000000000000000000000000000000003" + // len(array[1]) = 3
   818  			"0300000000000000000000000000000000000000000000000000000000000000" + // array[1][0]
   819  			"0400000000000000000000000000000000000000000000000000000000000000" + // array[1][1]
   820  			"0500000000000000000000000000000000000000000000000000000000000000", // array[1][2]
   821  	},
   822  	{
   823  		def:      `[{"type": "bytes32[3][2]"}]`,
   824  		unpacked: [2][3][32]byte{{{1}, {2}, {3}}, {{3}, {4}, {5}}},
   825  		packed: "0100000000000000000000000000000000000000000000000000000000000000" + // array[0][0]
   826  			"0200000000000000000000000000000000000000000000000000000000000000" + // array[0][1]
   827  			"0300000000000000000000000000000000000000000000000000000000000000" + // array[0][2]
   828  			"0300000000000000000000000000000000000000000000000000000000000000" + // array[1][0]
   829  			"0400000000000000000000000000000000000000000000000000000000000000" + // array[1][1]
   830  			"0500000000000000000000000000000000000000000000000000000000000000", // array[1][2]
   831  	},
   832  	{
   833  		// static tuple
   834  		def: `[{"components": [{"name":"a","type":"int64"}, 
   835  		{"name":"b","type":"int256"}, 
   836  		{"name":"c","type":"int256"}, 
   837  		{"name":"d","type":"bool"},
   838  		{"name":"e","type":"bytes32[3][2]"}], "type":"tuple"}]`,
   839  		unpacked: struct {
   840  			A int64
   841  			B *big.Int
   842  			C *big.Int
   843  			D bool
   844  			E [2][3][32]byte
   845  		}{1, big.NewInt(1), big.NewInt(-1), true, [2][3][32]byte{{{1}, {2}, {3}}, {{3}, {4}, {5}}}},
   846  		packed: "0000000000000000000000000000000000000000000000000000000000000001" + // struct[a]
   847  			"0000000000000000000000000000000000000000000000000000000000000001" + // struct[b]
   848  			"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" + // struct[c]
   849  			"0000000000000000000000000000000000000000000000000000000000000001" + // struct[d]
   850  			"0100000000000000000000000000000000000000000000000000000000000000" + // struct[e] array[0][0]
   851  			"0200000000000000000000000000000000000000000000000000000000000000" + // struct[e] array[0][1]
   852  			"0300000000000000000000000000000000000000000000000000000000000000" + // struct[e] array[0][2]
   853  			"0300000000000000000000000000000000000000000000000000000000000000" + // struct[e] array[1][0]
   854  			"0400000000000000000000000000000000000000000000000000000000000000" + // struct[e] array[1][1]
   855  			"0500000000000000000000000000000000000000000000000000000000000000", // struct[e] array[1][2]
   856  	},
   857  	{
   858  		def: `[{"components": [{"name":"a","type":"string"}, 
   859  		{"name":"b","type":"int64"}, 
   860  		{"name":"c","type":"bytes"}, 
   861  		{"name":"d","type":"string[]"},
   862  		{"name":"e","type":"int256[]"},
   863  		{"name":"f","type":"address[]"}], "type":"tuple"}]`,
   864  		unpacked: struct {
   865  			A string
   866  			B int64
   867  			C []byte
   868  			D []string
   869  			E []*big.Int
   870  			F []common.Address
   871  		}{"foobar", 1, []byte{1}, []string{"foo", "bar"}, []*big.Int{big.NewInt(1), big.NewInt(-1)}, []common.Address{{1}, {2}}},
   872  		packed: "0000000000000000000000000000000000000000000000000000000000000020" + // struct a
   873  			"00000000000000000000000000000000000000000000000000000000000000c0" + // struct[a] offset
   874  			"0000000000000000000000000000000000000000000000000000000000000001" + // struct[b]
   875  			"0000000000000000000000000000000000000000000000000000000000000100" + // struct[c] offset
   876  			"0000000000000000000000000000000000000000000000000000000000000140" + // struct[d] offset
   877  			"0000000000000000000000000000000000000000000000000000000000000220" + // struct[e] offset
   878  			"0000000000000000000000000000000000000000000000000000000000000280" + // struct[f] offset
   879  			"0000000000000000000000000000000000000000000000000000000000000006" + // struct[a] length
   880  			"666f6f6261720000000000000000000000000000000000000000000000000000" + // struct[a] "foobar"
   881  			"0000000000000000000000000000000000000000000000000000000000000001" + // struct[c] length
   882  			"0100000000000000000000000000000000000000000000000000000000000000" + // []byte{1}
   883  			"0000000000000000000000000000000000000000000000000000000000000002" + // struct[d] length
   884  			"0000000000000000000000000000000000000000000000000000000000000040" + // foo offset
   885  			"0000000000000000000000000000000000000000000000000000000000000080" + // bar offset
   886  			"0000000000000000000000000000000000000000000000000000000000000003" + // foo length
   887  			"666f6f0000000000000000000000000000000000000000000000000000000000" + // foo
   888  			"0000000000000000000000000000000000000000000000000000000000000003" + // bar offset
   889  			"6261720000000000000000000000000000000000000000000000000000000000" + // bar
   890  			"0000000000000000000000000000000000000000000000000000000000000002" + // struct[e] length
   891  			"0000000000000000000000000000000000000000000000000000000000000001" + // 1
   892  			"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" + // -1
   893  			"0000000000000000000000000000000000000000000000000000000000000002" + // struct[f] length
   894  			"0000000000000000000000000100000000000000000000000000000000000000" + // common.Address{1}
   895  			"0000000000000000000000000200000000000000000000000000000000000000", // common.Address{2}
   896  	},
   897  	{
   898  		def: `[{"components": [{ "type": "tuple","components": [{"name": "a","type": "uint256"},	
   899  							{"name": "b","type": "uint256[]"}],	
   900  							"name": "a","type": "tuple"},
   901  							{"name": "b","type": "uint256[]"}],  "type": "tuple"}]`,
   902  		unpacked: struct {
   903  			A struct {
   904  				A *big.Int
   905  				B []*big.Int
   906  			}
   907  			B []*big.Int
   908  		}{
   909  			A: struct {
   910  				A *big.Int
   911  				B []*big.Int
   912  			}{big.NewInt(1), []*big.Int{big.NewInt(1), big.NewInt(2)}},
   913  			B: []*big.Int{big.NewInt(1), big.NewInt(2)}},
   914  		packed: "0000000000000000000000000000000000000000000000000000000000000020" + // struct a
   915  			"0000000000000000000000000000000000000000000000000000000000000040" + // a offset
   916  			"00000000000000000000000000000000000000000000000000000000000000e0" + // b offset
   917  			"0000000000000000000000000000000000000000000000000000000000000001" + // a.a value
   918  			"0000000000000000000000000000000000000000000000000000000000000040" + // a.b offset
   919  			"0000000000000000000000000000000000000000000000000000000000000002" + // a.b length
   920  			"0000000000000000000000000000000000000000000000000000000000000001" + // a.b[0] value
   921  			"0000000000000000000000000000000000000000000000000000000000000002" + // a.b[1] value
   922  			"0000000000000000000000000000000000000000000000000000000000000002" + // b length
   923  			"0000000000000000000000000000000000000000000000000000000000000001" + // b[0] value
   924  			"0000000000000000000000000000000000000000000000000000000000000002", // b[1] value
   925  	},
   926  
   927  	{
   928  		def: `[{"components": [{"name": "a","type": "int256"},	
   929  							{"name": "b","type": "int256[]"}],	
   930  							"name": "a","type": "tuple[]"}]`,
   931  		unpacked: []struct {
   932  			A *big.Int
   933  			B []*big.Int
   934  		}{
   935  			{big.NewInt(-1), []*big.Int{big.NewInt(1), big.NewInt(3)}},
   936  			{big.NewInt(1), []*big.Int{big.NewInt(2), big.NewInt(-1)}},
   937  		},
   938  		packed: "0000000000000000000000000000000000000000000000000000000000000020" +
   939  			"0000000000000000000000000000000000000000000000000000000000000002" + // tuple length
   940  			"0000000000000000000000000000000000000000000000000000000000000040" + // tuple[0] offset
   941  			"00000000000000000000000000000000000000000000000000000000000000e0" + // tuple[1] offset
   942  			"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" + // tuple[0].A
   943  			"0000000000000000000000000000000000000000000000000000000000000040" + // tuple[0].B offset
   944  			"0000000000000000000000000000000000000000000000000000000000000002" + // tuple[0].B length
   945  			"0000000000000000000000000000000000000000000000000000000000000001" + // tuple[0].B[0] value
   946  			"0000000000000000000000000000000000000000000000000000000000000003" + // tuple[0].B[1] value
   947  			"0000000000000000000000000000000000000000000000000000000000000001" + // tuple[1].A
   948  			"0000000000000000000000000000000000000000000000000000000000000040" + // tuple[1].B offset
   949  			"0000000000000000000000000000000000000000000000000000000000000002" + // tuple[1].B length
   950  			"0000000000000000000000000000000000000000000000000000000000000002" + // tuple[1].B[0] value
   951  			"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", // tuple[1].B[1] value
   952  	},
   953  	{
   954  		def: `[{"components": [{"name": "a","type": "int256"},	
   955  							{"name": "b","type": "int256"}],	
   956  							"name": "a","type": "tuple[2]"}]`,
   957  		unpacked: [2]struct {
   958  			A *big.Int
   959  			B *big.Int
   960  		}{
   961  			{big.NewInt(-1), big.NewInt(1)},
   962  			{big.NewInt(1), big.NewInt(-1)},
   963  		},
   964  		packed: "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" + // tuple[0].a
   965  			"0000000000000000000000000000000000000000000000000000000000000001" + // tuple[0].b
   966  			"0000000000000000000000000000000000000000000000000000000000000001" + // tuple[1].a
   967  			"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", // tuple[1].b
   968  	},
   969  	{
   970  		def: `[{"components": [{"name": "a","type": "int256[]"}],
   971  							"name": "a","type": "tuple[2]"}]`,
   972  		unpacked: [2]struct {
   973  			A []*big.Int
   974  		}{
   975  			{[]*big.Int{big.NewInt(-1), big.NewInt(1)}},
   976  			{[]*big.Int{big.NewInt(1), big.NewInt(-1)}},
   977  		},
   978  		packed: "0000000000000000000000000000000000000000000000000000000000000020" +
   979  			"0000000000000000000000000000000000000000000000000000000000000040" + // tuple[0] offset
   980  			"00000000000000000000000000000000000000000000000000000000000000c0" + // tuple[1] offset
   981  			"0000000000000000000000000000000000000000000000000000000000000020" + // tuple[0].A offset
   982  			"0000000000000000000000000000000000000000000000000000000000000002" + // tuple[0].A length
   983  			"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" + // tuple[0].A[0]
   984  			"0000000000000000000000000000000000000000000000000000000000000001" + // tuple[0].A[1]
   985  			"0000000000000000000000000000000000000000000000000000000000000020" + // tuple[1].A offset
   986  			"0000000000000000000000000000000000000000000000000000000000000002" + // tuple[1].A length
   987  			"0000000000000000000000000000000000000000000000000000000000000001" + // tuple[1].A[0]
   988  			"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", // tuple[1].A[1]
   989  	},
   990  }