@@ -2,18 +2,23 @@ package io.iohk.ethereum.domain
22
33import org .scalatest .flatspec .AnyFlatSpec
44import org .scalatest .matchers .should .Matchers
5-
6- import io .iohk .ethereum .Fixtures
5+ import io .iohk .ethereum .{Fixtures , ObjectGenerators }
76import 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
811
9- class BlockchainReaderSpec extends AnyFlatSpec with Matchers {
12+ class BlockchainReaderSpec extends AnyFlatSpec with Matchers with ScalaCheckPropertyChecks with SecureRandomBuilder {
1013
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
1315
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 )
1519
16- blockchainReader.getBestBlock() shouldBe Some (validBlock)
20+ blockchainReader.getBestBlock() shouldBe Some (block)
21+ }
1722 }
1823
1924}
0 commit comments