rchain / rchain

Blockchain (smart contract) platform using CBC-Casper proof of stake + Rholang for concurrent execution.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Extract bonds file parser tests from GenesisTest file

tgrospic opened this issue · comments

Overview

Tests in GenesisTest (also from the first commit) file doesn't really check genesis block overall, but are mainly oriented to checking if bonds file is read with correct data or if it's missing that genesis use generated data.

One test is close which check if genesis block can be replayed correctly, but it doesn't check what important, if data on chain are created correctly with corresponding input.

it should "create a valid genesis block" in withStorage {
implicit blockStore => implicit blockDagStorage =>
withGenResources[Task] {
(
runtimeManager: RuntimeManager[Task],
genesisPath: Path,
log: LogStub[Task]
) =>
implicit val rm = runtimeManager
implicit val logEff = log
for {
genesis <- fromInputFiles()(
genesisPath,
runtimeManager,
implicitly[Concurrent[Task]],
log
)
_ <- blockDagStorage.insert(genesis, false, approved = true)
_ <- BlockStore[Task].put(genesis.blockHash, genesis)
maybePostGenesisStateHash <- InterpreterUtil
.validateBlockCheckpoint[Task](genesis)
} yield maybePostGenesisStateHash should matchPattern { case Right(Some(_)) => }
}
}

Solution

  • Extract tests for bonds parser as unit tests completely separated from the whole genesis creation logic.
  • Write new tests for genesis block without dependency to file based configuration and with checking of all relevant data expected to be created with genesis block.