Add unit test for RescanState to test recursive rescans correctly (#5786)

This commit is contained in:
Chris Stewart 2024-11-26 11:13:06 -06:00 committed by GitHub
parent d5a77a2297
commit d1618a2277
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -68,4 +68,25 @@ class RescanStateTest extends BitcoinSAsyncTest {
recoverToSucceededIf[RuntimeException](resultF) recoverToSucceededIf[RuntimeException](resultF)
} }
it must "handle stopping recursive rescan correctly" in {
val completeRescanEarlyP = Promise[Option[Int]]()
val recursiveRescanP = Promise[RescanState]()
val blocksMatchedF = completeRescanEarlyP.future.map(_ => Vector.empty)
val rescanState = RescanState.RescanStarted(completeRescanEarlyP,
blocksMatchedF,
recursiveRescanP)
val recursiveRescanCompleteEarlyP = Promise[Option[Int]]()
val recursiveRescanStarted = RescanState.RescanStarted(
recursiveRescanCompleteEarlyP,
recursiveRescanCompleteEarlyP.future.map(_ => Vector.empty),
Promise())
recursiveRescanP.success(recursiveRescanStarted)
for {
_ <- rescanState.stop()
_ <- recoverToSucceededIf[RescanTerminatedEarly.type](
rescanState.blocksMatchedF)
} yield succeed
}
} }