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

Function TestBlockQueueInitialHeight

internal/statesync/block_queue_test.go:236–274  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

234}
235
236func TestBlockQueueInitialHeight(t *testing.T) {
237 peerID, err := types.NewNodeID("0011223344556677889900112233445566778899")
238 require.NoError(t, err)
239 const initialHeight int64 = 120
240
241 queue := newBlockQueue(startHeight, stopHeight, initialHeight, stopTime, 1)
242 wg := &sync.WaitGroup{}
243
244 // asynchronously fetch blocks and add it to the queue
245 for i := 0; i <= numWorkers; i++ {
246 wg.Add(1)
247 go func() {
248 for {
249 select {
250 case height := <-queue.nextHeight():
251 require.GreaterOrEqual(t, height, initialHeight)
252 queue.add(mockLBResp(t, peerID, height, endTime))
253 case <-queue.done():
254 wg.Done()
255 return
256 }
257 }
258 }()
259 }
260
261loop:
262 for {
263 select {
264 case <-queue.done():
265 wg.Wait()
266 require.NoError(t, queue.error())
267 break loop
268
269 case resp := <-queue.verifyNext():
270 require.GreaterOrEqual(t, resp.block.Height, initialHeight)
271 queue.success(resp.block.Height)
272 }
273 }
274}
275
276func mockLBResp(t *testing.T, peer types.NodeID, height int64, time time.Time) lightBlockResponse {
277 vals, pv := factory.RandValidatorSet(3, 10)

Callers

nothing calls this directly

Calls 12

NewNodeIDFunction · 0.92
newBlockQueueFunction · 0.85
mockLBRespFunction · 0.85
nextHeightMethod · 0.80
doneMethod · 0.80
errorMethod · 0.80
verifyNextMethod · 0.80
successMethod · 0.80
AddMethod · 0.65
DoneMethod · 0.65
WaitMethod · 0.65
addMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…