MCPcopy Create free account
hub / github.com/DeAI-Artist/Linkis / TestABCIResponsesSaveLoad2

Function TestABCIResponsesSaveLoad2

state/state_test.go:132–219  ·  view source on GitHub ↗

TestResultsSaveLoad tests saving and loading ABCI results.

(t *testing.T)

Source from the content-addressed store, hash-verified

130
131// TestResultsSaveLoad tests saving and loading ABCI results.
132func TestABCIResponsesSaveLoad2(t *testing.T) {
133 tearDown, stateDB, _ := setupTestCase(t)
134 defer tearDown(t)
135 assert := assert.New(t)
136
137 stateStore := sm.NewStore(stateDB, sm.StoreOptions{
138 DiscardABCIResponses: false,
139 })
140
141 cases := [...]struct {
142 // Height is implied to equal index+2,
143 // as block 1 is created from genesis.
144 added []*abci.ResponseDeliverTx
145 expected []*abci.ResponseDeliverTx
146 }{
147 0: {
148 nil,
149 nil,
150 },
151 1: {
152 []*abci.ResponseDeliverTx{
153 {Code: 32, Data: []byte("Hello"), Log: "Huh?"},
154 },
155 []*abci.ResponseDeliverTx{
156 {Code: 32, Data: []byte("Hello")},
157 }},
158 2: {
159 []*abci.ResponseDeliverTx{
160 {Code: 383},
161 {
162 Data: []byte("Gotcha!"),
163 Events: []abci.Event{
164 {Type: "type1", Attributes: []abci.EventAttribute{{Key: []byte("a"), Value: []byte("1")}}},
165 {Type: "type2", Attributes: []abci.EventAttribute{{Key: []byte("build"), Value: []byte("stuff")}}},
166 },
167 },
168 },
169 []*abci.ResponseDeliverTx{
170 {Code: 383, Data: nil},
171 {Code: 0, Data: []byte("Gotcha!"), Events: []abci.Event{
172 {Type: "type1", Attributes: []abci.EventAttribute{{Key: []byte("a"), Value: []byte("1")}}},
173 {Type: "type2", Attributes: []abci.EventAttribute{{Key: []byte("build"), Value: []byte("stuff")}}},
174 }},
175 }},
176 3: {
177 nil,
178 nil,
179 },
180 4: {
181 []*abci.ResponseDeliverTx{nil},
182 nil,
183 },
184 }
185
186 // Query all before, this should return error.
187 for i := range cases {
188 h := int64(i + 1)
189 res, err := stateStore.LoadABCIResponses(h)

Callers

nothing calls this directly

Calls 6

LoadABCIResponsesMethod · 0.95
SaveABCIResponsesMethod · 0.95
setupTestCaseFunction · 0.85
LogMethod · 0.80
ErrorMethod · 0.65
EqualMethod · 0.65

Tested by

no test coverage detected