Skip to content

Commit 217aceb

Browse files
committed
Update the tests
1 parent 0822357 commit 217aceb

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

src/it/scala/io/iohk/ethereum/ledger/BlockImporterItSpec.scala

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,7 @@ class BlockImporterItSpec extends MockFactory with TestSetupWithVmAndValidators
104104

105105
blockImporter ! BlockImporter.Start
106106

107-
/** TODO: this should not behave like that, but instead return a proper error and revert reorganisation to the initial chain. Currently if we had a chain, and then
108-
reorganisation started and error occurred in BlockExecution.executeAndValidateBlock() we end up with a discarded main chain to the point of the common parent**/
109-
110-
"BlockImporter" should "(not) discard blocks of the main chain if the reorganisation failed" in {
107+
"BlockImporter" should "not discard blocks of the main chain if the reorganisation failed" in {
111108

112109
//ledger with not mocked blockExecution
113110
val ledger = new TestLedgerImpl(successValidators)
@@ -129,7 +126,7 @@ class BlockImporterItSpec extends MockFactory with TestSetupWithVmAndValidators
129126

130127
Thread.sleep(1000)
131128
//because the blocks are not valid, we shouldn't reorganise, but at least stay with a current chain, and the best block of the current chain is oldBlock4
132-
blockchain.getBestBlock().get shouldEqual block1
129+
blockchain.getBestBlock().get shouldEqual oldBlock4
133130
}
134131

135132
it should "return a correct new best block after reorganising longer chain to a shorter one" in {

src/test/scala/io/iohk/ethereum/ledger/BlockImportSpec.scala

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,13 +188,11 @@ class BlockImportSpec extends AnyFlatSpec with Matchers with ScalaFutures {
188188
blockchain.save(blockData2.block, blockData2.receipts, blockData2.weight, saveAsBestBlock = true)
189189
blockchain.save(blockData3.block, blockData3.receipts, blockData3.weight, saveAsBestBlock = true)
190190

191-
//saving to cache the value of the best block from the initial chain. This recreates the bug ETCM-626, where (possiby) because of the thread of execution
191+
//saving to cache the value of the best block from the initial chain. This recreates the bug ETCM-626, where (possibly) because of the thread of execution
192192
// dying before updating the storage but after updating the cache, inconsistency is created
193193
blockchain.saveBestKnownBlocks(oldBlock4.number)
194194

195-
assertThrows[NoSuchElementException] {
196-
blockchain.getBestBlock()
197-
}
195+
blockchain.getBestBlock() shouldBe None
198196
}
199197

200198
it should "handle error when trying to reorganise chain" in new EphemBlockchain {

0 commit comments

Comments
 (0)