@@ -364,6 +364,55 @@ func TestUnpack(t *testing.T) {
364364 }
365365}
366366
367+ func TestUnpackSetDynamicArrayOutput (t * testing.T ) {
368+ abi , err := JSON (strings .NewReader (`[{"constant":true,"inputs":[],"name":"testDynamicFixedBytes15","outputs":[{"name":"","type":"bytes15[]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"testDynamicFixedBytes32","outputs":[{"name":"","type":"bytes32[]"}],"payable":false,"stateMutability":"view","type":"function"}]` ))
369+ if err != nil {
370+ t .Fatal (err )
371+ }
372+
373+ var (
374+ marshalledReturn32 = common .Hex2Bytes ("0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000230783132333435363738393000000000000000000000000000000000000000003078303938373635343332310000000000000000000000000000000000000000" )
375+ marshalledReturn15 = common .Hex2Bytes ("0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000230783031323334350000000000000000000000000000000000000000000000003078393837363534000000000000000000000000000000000000000000000000" )
376+
377+ out32 [][32 ]byte
378+ out15 [][15 ]byte
379+ )
380+
381+ // test 32
382+ err = abi .Unpack (& out32 , "testDynamicFixedBytes32" , marshalledReturn32 )
383+ if err != nil {
384+ t .Fatal (err )
385+ }
386+ if len (out32 ) != 2 {
387+ t .Fatalf ("expected array with 2 values, got %d" , len (out32 ))
388+ }
389+ expected := common .Hex2Bytes ("3078313233343536373839300000000000000000000000000000000000000000" )
390+ if ! bytes .Equal (out32 [0 ][:], expected ) {
391+ t .Errorf ("expected %x, got %x\n " , expected , out32 [0 ])
392+ }
393+ expected = common .Hex2Bytes ("3078303938373635343332310000000000000000000000000000000000000000" )
394+ if ! bytes .Equal (out32 [1 ][:], expected ) {
395+ t .Errorf ("expected %x, got %x\n " , expected , out32 [1 ])
396+ }
397+
398+ // test 15
399+ err = abi .Unpack (& out15 , "testDynamicFixedBytes32" , marshalledReturn15 )
400+ if err != nil {
401+ t .Fatal (err )
402+ }
403+ if len (out15 ) != 2 {
404+ t .Fatalf ("expected array with 2 values, got %d" , len (out15 ))
405+ }
406+ expected = common .Hex2Bytes ("307830313233343500000000000000" )
407+ if ! bytes .Equal (out15 [0 ][:], expected ) {
408+ t .Errorf ("expected %x, got %x\n " , expected , out15 [0 ])
409+ }
410+ expected = common .Hex2Bytes ("307839383736353400000000000000" )
411+ if ! bytes .Equal (out15 [1 ][:], expected ) {
412+ t .Errorf ("expected %x, got %x\n " , expected , out15 [1 ])
413+ }
414+ }
415+
367416type methodMultiOutput struct {
368417 Int * big.Int
369418 String string
0 commit comments