github.com/klaytn/klaytn@v1.12.1/accounts/abi/packing_test.go (about)

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