@@ -320,17 +320,25 @@ class BlockFetcherSpec
320
320
321
321
handleFirstBlockBatchBodies()
322
322
323
+ // second bodies request
324
+ val secondGetBlockBodiesRequest = GetBlockBodies (secondBlocksBatch.map(_.hash))
325
+ peersClient.expectMsgPF() { case PeersClient .Request (msg, _, _) if msg == secondGetBlockBodiesRequest => ()}
326
+
323
327
// send old checkpoint block
324
328
blockFetcher ! MessageFromPeer (PV64 .NewBlock (checkpointBlock, ChainWeight (checkpointBlock.number, checkpointBlock.header.difficulty)), fakePeer.id)
325
329
326
- // Second bodies request
327
- val secondGetBlockBodiesRequest = GetBlockBodies (alternativeSecondBlocksBatch.map(_.hash))
328
- peersClient.expectMsgPF() { case PeersClient .Request (msg, _, _) if msg == secondGetBlockBodiesRequest => () }
329
-
330
- // Second bodies response
331
- val secondGetBlockBodiesResponse = BlockBodies (alternativeSecondBlocksBatch.map(_.body))
330
+ // second bodies response
331
+ val secondGetBlockBodiesResponse = BlockBodies (secondBlocksBatch.map(_.body))
332
332
peersClient.reply(PeersClient .Response (fakePeer, secondGetBlockBodiesResponse))
333
333
334
+ // third bodies request after adding checkpoint into the waiting headers queue
335
+ val thirdGetBlockBodiesRequest = GetBlockBodies (alternativeSecondBlocksBatch.map(_.hash))
336
+ peersClient.expectMsgPF() { case PeersClient .Request (msg, _, _) if msg == thirdGetBlockBodiesRequest => ()}
337
+
338
+ // third bodies response
339
+ val thirdGetBlockBodiesResponse = BlockBodies (alternativeSecondBlocksBatch.map(_.body))
340
+ peersClient.reply(PeersClient .Response (fakePeer, thirdGetBlockBodiesResponse))
341
+
334
342
// We need to wait a while in order to allow fetcher to process all the blocks
335
343
system.scheduler.scheduleOnce(Timeouts .shortTimeout) {
336
344
importer.send(blockFetcher, PickBlocks (syncConfig.blocksBatchSize * 2 ))
0 commit comments