@@ -2,8 +2,10 @@ package io.iohk.ethereum.blockchain.sync.regular
2
2
3
3
import akka .actor .ActorSystem
4
4
import akka .testkit .{TestKit , TestProbe }
5
+ import io .iohk .ethereum .domain .Block
5
6
import org .scalatest .{Matchers , WordSpecLike }
6
-
7
+ import io .iohk .ethereum .Fixtures .Blocks .ValidBlock
8
+ import io .iohk .ethereum .network .PeerId
7
9
8
10
class BlockFetcherStateSpec extends TestKit (ActorSystem ()) with WordSpecLike with Matchers {
9
11
" BlockFetcherState" when {
@@ -15,5 +17,21 @@ class BlockFetcherStateSpec extends TestKit(ActorSystem()) with WordSpecLike wit
15
17
actual.lastBlock shouldBe 0
16
18
}
17
19
}
20
+
21
+ " appending last full block" should {
22
+ " update last block" in {
23
+ val importer = TestProbe ().ref
24
+ val currentBestBlock = Block (ValidBlock .header, ValidBlock .body)
25
+ val newBestBlock = Block (ValidBlock .header.copy(number = ValidBlock .header.number + 1 ), ValidBlock .body)
26
+ val fakePeerId = PeerId (" fake" )
27
+
28
+ val currentState = BlockFetcherState .initial(importer, currentBestBlock.number)
29
+ val newState = currentState.appendNewBlock(newBestBlock, fakePeerId)
30
+ newState.lastBlock shouldEqual newBestBlock.number
31
+ newState.blockProviders(newBestBlock.number) shouldEqual fakePeerId
32
+ newState.knownTop shouldEqual newBestBlock.number
33
+ }
34
+ }
35
+
18
36
}
19
37
}
0 commit comments