mirror of
https://github.com/bitcoin-s/bitcoin-s.git
synced 2025-03-03 10:46:42 +01:00
wallet: Cleanup RescanHandlingTest (#5781)
This commit is contained in:
parent
345ab017e5
commit
f6f01f333a
2 changed files with 12 additions and 7 deletions
|
@ -350,7 +350,7 @@ class RescanHandlingTest extends BitcoinSWalletTestCachedBitcoindNewest {
|
||||||
_ = assert(start.isInstanceOf[RescanState.RescanStarted])
|
_ = assert(start.isInstanceOf[RescanState.RescanStarted])
|
||||||
// try another one
|
// try another one
|
||||||
alreadyStarted <- alreadyStartedF
|
alreadyStarted <- alreadyStartedF
|
||||||
_ <- start.asInstanceOf[RescanState.RescanStarted].stop()
|
_ <- RescanState.awaitRescanDone(start)
|
||||||
} yield {
|
} yield {
|
||||||
assert(alreadyStarted == RescanState.RescanAlreadyStarted)
|
assert(alreadyStarted == RescanState.RescanAlreadyStarted)
|
||||||
}
|
}
|
||||||
|
@ -365,7 +365,7 @@ class RescanHandlingTest extends BitcoinSWalletTestCachedBitcoindNewest {
|
||||||
// start a rescan without sending payment to that address
|
// start a rescan without sending payment to that address
|
||||||
for {
|
for {
|
||||||
address <- addressNoFundsF
|
address <- addressNoFundsF
|
||||||
_ <- wallet.rescanHandling.rescanNeutrinoWallet(
|
state <- wallet.rescanHandling.rescanNeutrinoWallet(
|
||||||
startOpt = None,
|
startOpt = None,
|
||||||
endOpt = None,
|
endOpt = None,
|
||||||
addressBatchSize = 10,
|
addressBatchSize = 10,
|
||||||
|
@ -385,6 +385,7 @@ class RescanHandlingTest extends BitcoinSWalletTestCachedBitcoindNewest {
|
||||||
_ <- wallet.transactionProcessing.processBlock(block)
|
_ <- wallet.transactionProcessing.processBlock(block)
|
||||||
fundedAddresses <- wallet.addressHandling.listFundedAddresses()
|
fundedAddresses <- wallet.addressHandling.listFundedAddresses()
|
||||||
utxos <- wallet.utxoHandling.listUtxos(TxoState.ImmatureCoinbase)
|
utxos <- wallet.utxoHandling.listUtxos(TxoState.ImmatureCoinbase)
|
||||||
|
_ <- RescanState.awaitRescanDone(state)
|
||||||
} yield {
|
} yield {
|
||||||
// note 25 bitcoin reward from coinbase tx here
|
// note 25 bitcoin reward from coinbase tx here
|
||||||
// if we we move this test case in the future it may need to change
|
// if we we move this test case in the future it may need to change
|
||||||
|
@ -392,7 +393,7 @@ class RescanHandlingTest extends BitcoinSWalletTestCachedBitcoindNewest {
|
||||||
TransactionOutput(Bitcoins(25), address.scriptPubKey)
|
TransactionOutput(Bitcoins(25), address.scriptPubKey)
|
||||||
assert(
|
assert(
|
||||||
utxos.exists(_.output == expectedOutput),
|
utxos.exists(_.output == expectedOutput),
|
||||||
s"Balance must show up on utxos"
|
s"Balance must show up on utxos=$utxos expectedOutput=$expectedOutput"
|
||||||
)
|
)
|
||||||
val addressExists = fundedAddresses.exists(_._1.address == address)
|
val addressExists = fundedAddresses.exists(_._1.address == address)
|
||||||
assert(addressExists)
|
assert(addressExists)
|
||||||
|
@ -405,7 +406,7 @@ class RescanHandlingTest extends BitcoinSWalletTestCachedBitcoindNewest {
|
||||||
val bitcoind = fixture.bitcoind
|
val bitcoind = fixture.bitcoind
|
||||||
val amt = Bitcoins.one
|
val amt = Bitcoins.one
|
||||||
for {
|
for {
|
||||||
_ <- wallet.rescanHandling.rescanNeutrinoWallet(
|
rescanState1 <- wallet.rescanHandling.rescanNeutrinoWallet(
|
||||||
startOpt = None,
|
startOpt = None,
|
||||||
endOpt = None,
|
endOpt = None,
|
||||||
addressBatchSize = 10,
|
addressBatchSize = 10,
|
||||||
|
@ -413,8 +414,9 @@ class RescanHandlingTest extends BitcoinSWalletTestCachedBitcoindNewest {
|
||||||
force = false
|
force = false
|
||||||
)
|
)
|
||||||
addressNoFunds <- wallet.getNewChangeAddress()
|
addressNoFunds <- wallet.getNewChangeAddress()
|
||||||
|
_ <- RescanState.awaitRescanDone(rescanState1)
|
||||||
// rescan again
|
// rescan again
|
||||||
_ <- wallet.rescanHandling.rescanNeutrinoWallet(
|
rescanState2 <- wallet.rescanHandling.rescanNeutrinoWallet(
|
||||||
startOpt = None,
|
startOpt = None,
|
||||||
endOpt = None,
|
endOpt = None,
|
||||||
addressBatchSize = 10,
|
addressBatchSize = 10,
|
||||||
|
@ -425,6 +427,7 @@ class RescanHandlingTest extends BitcoinSWalletTestCachedBitcoindNewest {
|
||||||
tx <- bitcoind.getRawTransactionRaw(txid)
|
tx <- bitcoind.getRawTransactionRaw(txid)
|
||||||
_ <- wallet.transactionProcessing.processTransaction(tx, None)
|
_ <- wallet.transactionProcessing.processTransaction(tx, None)
|
||||||
unconfirmedBalance <- wallet.getUnconfirmedBalance()
|
unconfirmedBalance <- wallet.getUnconfirmedBalance()
|
||||||
|
_ <- RescanState.awaitRescanDone(rescanState2)
|
||||||
} yield {
|
} yield {
|
||||||
assert(unconfirmedBalance == amt)
|
assert(unconfirmedBalance == amt)
|
||||||
}
|
}
|
||||||
|
|
|
@ -181,7 +181,8 @@ case class RescanHandling(
|
||||||
): Future[Unit] = {
|
): Future[Unit] = {
|
||||||
// handle the case where there is a top level rescan failure when _starting_ the rescan
|
// handle the case where there is a top level rescan failure when _starting_ the rescan
|
||||||
rescanStateF.recoverWith { case err: Throwable =>
|
rescanStateF.recoverWith { case err: Throwable =>
|
||||||
logger.error(s"Failed to rescan wallet=${walletConfig.walletName}", err)
|
logger.error(
|
||||||
|
s"Failed to rescan wallet1=${walletConfig.walletName} err=${err.getMessage}")
|
||||||
stateDescriptorDAO
|
stateDescriptorDAO
|
||||||
.updateRescanning(false)
|
.updateRescanning(false)
|
||||||
.flatMap(_ => Future.failed(err))
|
.flatMap(_ => Future.failed(err))
|
||||||
|
@ -198,7 +199,8 @@ case class RescanHandling(
|
||||||
Future.unit
|
Future.unit
|
||||||
case err: Throwable =>
|
case err: Throwable =>
|
||||||
logger
|
logger
|
||||||
.error(s"Failed to rescan wallet=${walletConfig.walletName}", err)
|
.error(
|
||||||
|
s"Failed to rescan wallet=${walletConfig.walletName} err=${err.getMessage}")
|
||||||
stateDescriptorDAO
|
stateDescriptorDAO
|
||||||
.updateRescanning(false)
|
.updateRescanning(false)
|
||||||
.flatMap(_ => Future.failed(err))
|
.flatMap(_ => Future.failed(err))
|
||||||
|
|
Loading…
Add table
Reference in a new issue