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