Skip to content

Commit

Permalink
Improve readability of a test
Browse files Browse the repository at this point in the history
  • Loading branch information
vsuharnikov committed Dec 27, 2024
1 parent 415ab40 commit fa38130
Showing 1 changed file with 18 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,25 +133,30 @@ class LightNodeBlockFieldsTest extends PropSpec with WithMiner {
)
def appendBlock(ref: Option[ByteStr]) = append(miner.forgeBlock(defaultSigner, ref).explicitGet()._1).explicitGet()
def appendMicro() = {
d.utxPool.putIfNew(transfer()).resultE.explicitGet()
// A transfer sender and a block generator are same
d.utxPool.putIfNew(transfer(from = defaultSigner)).resultE.explicitGet()
microBlockMiner.generateOneMicroBlockTask(defaultSigner, d.lastBlock, Unlimited, 0).runSyncUnsafe()
}

appendBlock(None)
val blockId1 = d.lastBlockId
appendMicro()
withClue("Discard the latest micro block and referencing to a key block: ") {
appendBlock(None)
val keyBlockId = d.lastBlockId

// rollback to a key block before micro block
appendBlock(Some(blockId1))
d.lastBlock.header.reference shouldBe blockId1
appendMicro()
appendBlock(Some(keyBlockId))

appendMicro()
val blockId2 = d.lastBlockId
appendMicro()
d.lastBlock.header.reference shouldBe keyBlockId
}

withClue("Discard the latest micro block and referencing to a previous: ") {
appendMicro()
val previousMicroBlockId = d.lastBlockId

// rollback to a micro block before another micro block
appendBlock(Some(blockId2))
d.lastBlock.header.reference shouldBe blockId2
appendMicro()
appendBlock(Some(previousMicroBlockId))

d.lastBlock.header.reference shouldBe previousMicroBlockId
}
}
}

Expand Down

0 comments on commit fa38130

Please sign in to comment.