TestEventMultiValueWithArrayUnpack verifies that array fields will be counted after parsing array.
(t *testing.T)
| 113 | |
| 114 | // TestEventMultiValueWithArrayUnpack verifies that array fields will be counted after parsing array. |
| 115 | func TestEventMultiValueWithArrayUnpack(t *testing.T) { |
| 116 | definition := `[{"name": "test", "type": "event", "inputs": [{"indexed": false, "name":"value1", "type":"uint8[2]"},{"indexed": false, "name":"value2", "type":"uint8"}]}]` |
| 117 | type testStruct struct { |
| 118 | Value1 [2]uint8 |
| 119 | Value2 uint8 |
| 120 | } |
| 121 | abi, err := JSON(strings.NewReader(definition)) |
| 122 | require.NoError(t, err) |
| 123 | var b bytes.Buffer |
| 124 | var i uint8 = 1 |
| 125 | for ; i <= 3; i++ { |
| 126 | b.Write(packNum(reflect.ValueOf(i))) |
| 127 | } |
| 128 | var rst testStruct |
| 129 | require.NoError(t, abi.Unpack(&rst, "test", b.Bytes())) |
| 130 | require.Equal(t, [2]uint8{1, 2}, rst.Value1) |
| 131 | require.Equal(t, uint8(3), rst.Value2) |
| 132 | } |
| 133 | |
| 134 | func TestEventTupleUnpack(t *testing.T) { |
| 135 |