MCPcopy Create free account
hub / github.com/CPChain/chain / TestEventMultiValueWithArrayUnpack

Function TestEventMultiValueWithArrayUnpack

accounts/abi/event_test.go:115–132  ·  view source on GitHub ↗

TestEventMultiValueWithArrayUnpack verifies that array fields will be counted after parsing array.

(t *testing.T)

Source from the content-addressed store, hash-verified

113
114// TestEventMultiValueWithArrayUnpack verifies that array fields will be counted after parsing array.
115func 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
134func TestEventTupleUnpack(t *testing.T) {
135

Callers

nothing calls this directly

Calls 6

JSONFunction · 0.85
packNumFunction · 0.85
WriteMethod · 0.65
BytesMethod · 0.65
EqualMethod · 0.65
UnpackMethod · 0.45

Tested by

no test coverage detected