@@ -320,17 +320,25 @@ class BlockFetcherSpec
320320
321321 handleFirstBlockBatchBodies()
322322
323+ // second bodies request
324+ val secondGetBlockBodiesRequest = GetBlockBodies (secondBlocksBatch.map(_.hash))
325+ peersClient.expectMsgPF() { case PeersClient .Request (msg, _, _) if msg == secondGetBlockBodiesRequest => ()}
326+
323327 // send old checkpoint block
324328 blockFetcher ! MessageFromPeer (PV64 .NewBlock (checkpointBlock, ChainWeight (checkpointBlock.number, checkpointBlock.header.difficulty)), fakePeer.id)
325329
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))
332332 peersClient.reply(PeersClient .Response (fakePeer, secondGetBlockBodiesResponse))
333333
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+
334342 // We need to wait a while in order to allow fetcher to process all the blocks
335343 system.scheduler.scheduleOnce(Timeouts .shortTimeout) {
336344 importer.send(blockFetcher, PickBlocks (syncConfig.blocksBatchSize * 2 ))
0 commit comments