Skip to content

Commit

Permalink
check unspent boxes after rollback
Browse files Browse the repository at this point in the history
  • Loading branch information
kushti committed Nov 5, 2024
1 parent 31a26a9 commit a93a4fb
Showing 1 changed file with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ package org.ergoplatform.nodeView.history.extra

import akka.actor.{ActorRef, ActorSystem, Props}
import org.ergoplatform.ErgoAddressEncoder
import org.ergoplatform.http.api.SortDirection
import org.ergoplatform.network.ErgoNodeViewSynchronizerMessages.{FullBlockApplied, Rollback}
import org.ergoplatform.nodeView.history.extra.ExtraIndexer.ReceivableMessages.Index
import org.ergoplatform.nodeView.history.extra.IndexedErgoAddressSerializer.hashErgoTree
import org.ergoplatform.nodeView.history.extra.SegmentSerializer.{boxSegmentId, txSegmentId}
import org.ergoplatform.nodeView.history.{ErgoHistory, ErgoHistoryReader}
import org.ergoplatform.nodeView.mempool.ErgoMemPool
import org.ergoplatform.settings.ErgoSettings
import org.ergoplatform.utils.ErgoCorePropertyTest
import scorex.util.{ModifierId, bytesToId}
Expand All @@ -26,7 +28,7 @@ class ExtraIndexerSpecification extends ErgoCorePropertyTest {

val HEIGHT: Int = 50
val BRANCHPOINT: Int = HEIGHT / 2
implicit val segmentThreshold: Int = 16
implicit val segmentThreshold: Int = 8

val system: ActorSystem = ActorSystem.create("indexer-test")
val indexer: ActorRef = system.actorOf(Props.create(classOf[ExtraIndexerTestActor], this))
Expand Down Expand Up @@ -186,6 +188,12 @@ class ExtraIndexerSpecification extends ErgoCorePropertyTest {
// address balances
checkAddresses(addresses) shouldBe 0

addresses.keys.foreach { addr =>
val utxos = history.typedExtraIndexById[IndexedErgoAddress](addr).get
.retrieveUtxos(history, ErgoMemPool.empty(settings), 0, 1000, SortDirection.ASC, false, Set.empty)
utxos.exists(_.isSpent) shouldBe false
}

// token indexes
checkTokens(indexedTokens) shouldBe 0

Expand Down Expand Up @@ -237,5 +245,11 @@ class ExtraIndexerSpecification extends ErgoCorePropertyTest {
cfor(0)(_ < boxIndexBefore, _ + 1) { boxNum =>
history.typedExtraIndexById[NumericBoxIndex](bytesToId(NumericBoxIndex.indexToBytes(boxNum))) shouldNot be(empty)
}

addresses2.keys.foreach { addr =>
val utxos = history.typedExtraIndexById[IndexedErgoAddress](addr).get
.retrieveUtxos(history, ErgoMemPool.empty(settings), 0, 1000, SortDirection.ASC, false, Set.empty)
utxos.exists(_.isSpent) shouldBe false
}
}
}

0 comments on commit a93a4fb

Please sign in to comment.