mirror of
https://github.com/bitcoin-s/bitcoin-s.git
synced 2025-01-18 13:24:25 +01:00
Add unit test for RescanState to test recursive rescans correctly (#5786)
This commit is contained in:
parent
d5a77a2297
commit
d1618a2277
@ -68,4 +68,25 @@ class RescanStateTest extends BitcoinSAsyncTest {
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user