@@ -2,18 +2,23 @@ package io.iohk.ethereum.domain
2
2
3
3
import org .scalatest .flatspec .AnyFlatSpec
4
4
import org .scalatest .matchers .should .Matchers
5
-
6
- import io .iohk .ethereum .Fixtures
5
+ import io .iohk .ethereum .{Fixtures , ObjectGenerators }
7
6
import io .iohk .ethereum .blockchain .sync .EphemBlockchainTestSetup
7
+ import io .iohk .ethereum .network .p2p .messages .BaseETH6XMessages .NewBlock
8
+ import io .iohk .ethereum .security .SecureRandomBuilder
9
+ import org .bouncycastle .util .encoders .Hex
10
+ import org .scalatestplus .scalacheck .ScalaCheckPropertyChecks
8
11
9
- class BlockchainReaderSpec extends AnyFlatSpec with Matchers {
12
+ class BlockchainReaderSpec extends AnyFlatSpec with Matchers with ScalaCheckPropertyChecks with SecureRandomBuilder {
10
13
11
- " BlockchainReader" should " be able to get the best block after it was stored by BlockchainWriter" in new EphemBlockchainTestSetup {
12
- val validBlock = Fixtures .Blocks .ValidBlock .block
14
+ val chainId : Option [Byte ] = Hex .decode(" 3d" ).headOption
13
15
14
- blockchainWriter.save(validBlock, Nil , ChainWeight .zero, true )
16
+ " BlockchainReader" should " be able to get the best block after it was stored by BlockchainWriter" in new EphemBlockchainTestSetup {
17
+ forAll(ObjectGenerators .newBlockGen(secureRandom, chainId)) { case NewBlock (block, weight) =>
18
+ blockchainWriter.save(block, Nil , ChainWeight (0 , weight), true )
15
19
16
- blockchainReader.getBestBlock() shouldBe Some (validBlock)
20
+ blockchainReader.getBestBlock() shouldBe Some (block)
21
+ }
17
22
}
18
23
19
24
}
0 commit comments