MCPcopy Create free account
hub / github.com/tendermint/tendermint / TestRProcessBlockSuccess

Function TestRProcessBlockSuccess

internal/blocksync/v2/processor_test.go:163–217  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

161}
162
163func TestRProcessBlockSuccess(t *testing.T) {
164 tests := []testFields{
165 {
166 name: "noop - no blocks over current height",
167 steps: []pcFsmMakeStateValues{
168 {
169 currentState: &params{}, event: rProcessBlock{},
170 wantState: &params{}, wantNextEvent: noOp,
171 },
172 },
173 },
174 {
175 name: "noop - high new blocks",
176 steps: []pcFsmMakeStateValues{
177 {
178 currentState: &params{height: 5, items: []pcBlock{{"P1", 30}, {"P2", 31}}}, event: rProcessBlock{},
179 wantState: &params{height: 5, items: []pcBlock{{"P1", 30}, {"P2", 31}}}, wantNextEvent: noOp,
180 },
181 },
182 },
183 {
184 name: "blocks H+1 and H+2 present",
185 steps: []pcFsmMakeStateValues{
186 {
187 currentState: &params{items: []pcBlock{{"P1", 1}, {"P2", 2}}}, event: rProcessBlock{},
188 wantState: &params{height: 1, items: []pcBlock{{"P2", 2}}, blocksSynced: 1},
189 wantNextEvent: pcBlockProcessed{height: 1, peerID: "P1"},
190 },
191 },
192 },
193 {
194 name: "blocks H+1 and H+2 present after draining",
195 steps: []pcFsmMakeStateValues{
196 { // some contiguous blocks - on stop check draining is set
197 currentState: &params{items: []pcBlock{{"P1", 1}, {"P2", 2}, {"P1", 4}}},
198 event: scFinishedEv{},
199 wantState: &params{items: []pcBlock{{"P1", 1}, {"P2", 2}, {"P1", 4}}, draining: true},
200 wantNextEvent: noOp,
201 },
202 {
203 event: rProcessBlock{},
204 wantState: &params{height: 1, items: []pcBlock{{"P2", 2}, {"P1", 4}}, blocksSynced: 1, draining: true},
205 wantNextEvent: pcBlockProcessed{height: 1, peerID: "P1"},
206 },
207 { // finish when H+1 or/and H+2 are missing
208 event: rProcessBlock{},
209 wantState: &params{height: 1, items: []pcBlock{{"P2", 2}, {"P1", 4}}, blocksSynced: 1, draining: true},
210 wantNextEvent: pcFinished{tmState: tmstate.State{LastBlockHeight: 1}, blocksSynced: 1},
211 },
212 },
213 },
214 }
215
216 executeProcessorTests(t, tests)
217}
218
219func TestRProcessBlockFailures(t *testing.T) {
220 tests := []testFields{

Callers

nothing calls this directly

Calls 1

executeProcessorTestsFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…