Catch non RescanTerminatedEarly errors when rescan is terminated with an exception (#4939)

This commit is contained in:
Chris Stewart 2023-01-05 12:40:50 -06:00 committed by GitHub
parent 7e8002f626
commit d297311814
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 5 deletions

View File

@ -37,8 +37,9 @@ object RescanState {
_isCompletedEarly.set(false)
}
completeRescanEarlyP.future.failed.foreach { case RescanTerminatedEarly =>
_isCompletedEarly.set(true)
completeRescanEarlyP.future.failed.foreach {
case RescanTerminatedEarly => _isCompletedEarly.set(true)
case scala.util.control.NonFatal(_) => //do nothing
}
/** Useful for determining if the rescan was completed

View File

@ -5,6 +5,7 @@ import org.bitcoins.core.currency._
import org.bitcoins.core.protocol.script.MultiSignatureScriptPubKey
import org.bitcoins.core.protocol.transaction.TransactionOutput
import org.bitcoins.core.wallet.fee.SatoshisPerByte
import org.bitcoins.core.wallet.rescan.RescanState.RescanStarted
import org.bitcoins.crypto.ECPublicKey
import org.bitcoins.server.BitcoinSAppConfig
import org.bitcoins.testkit.BitcoinSTestAppConfig
@ -196,9 +197,14 @@ class NeutrinoNodeWithWalletTest extends NodeTestWithCachedBitcoindNewest {
_ <-
bitcoind.getNewAddress
.flatMap(bitcoind.generateToAddress(1, _))
bitcoindHeight <- bitcoind.getBlockCount
_ <- NodeTestUtil.awaitSync(node, bitcoind)
_ <- NodeTestUtil.awaitCompactFiltersSync(node, bitcoind)
_ <- AsyncUtil.retryUntilSatisfiedF(() => {
// wait until the block is processed by the wallet
wallet
.getSyncDescriptorOpt()
.map(_.get.height == bitcoindHeight)
})
_ <- wallet.clearAllUtxos()
addresses <- wallet.listAddresses()
utxos <- wallet.listDefaultAccountUtxos()
@ -207,11 +213,12 @@ class NeutrinoNodeWithWalletTest extends NodeTestWithCachedBitcoindNewest {
rescan <- wallet.isRescanning()
_ = assert(!rescan)
_ <- wallet.fullRescanNeutrinoWallet(addressBatchSize = 7)
rescanState <- wallet.fullRescanNeutrinoWallet(addressBatchSize = 7)
_ <- AsyncUtil.awaitConditionF(condition,
maxTries = 200,
interval = 200.millis)
_ <- rescanState.asInstanceOf[RescanStarted].stop()
} yield succeed
}