From fa821ad0cc143b9290a1ad3484d0b8b6d461f75f Mon Sep 17 00:00:00 2001 From: Fabian Jahr Date: Mon, 23 Sep 2024 21:05:37 +0200 Subject: [PATCH] test: Include assumeutxo as a failure reason of rescanblockchain --- src/wallet/rpc/transactions.cpp | 4 ++-- test/functional/feature_pruning.py | 2 +- test/functional/wallet_assumeutxo.py | 3 +++ 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/wallet/rpc/transactions.cpp b/src/wallet/rpc/transactions.cpp index 61cf36a6c100e7..5839eb7d779eb0 100644 --- a/src/wallet/rpc/transactions.cpp +++ b/src/wallet/rpc/transactions.cpp @@ -909,9 +909,9 @@ RPCHelpMan rescanblockchain() } } - // We can't rescan beyond non-pruned blocks, stop and throw an error + // We can't rescan unavailable blocks, stop and throw an error if (!pwallet->chain().hasBlocks(pwallet->GetLastBlockHash(), start_height, stop_height)) { - throw JSONRPCError(RPC_MISC_ERROR, "Can't rescan beyond pruned data. Use RPC call getblockchaininfo to determine your pruned height."); + throw JSONRPCError(RPC_MISC_ERROR, "Failed to rescan unavailable blocks. This may be caused by pruning or an in-progress assumeutxo background sync. Use RPC call getblockchaininfo to determine your pruned height or check your logs for assumeutxo progress."); } CHECK_NONFATAL(pwallet->chain().findAncestorByHeight(pwallet->GetLastBlockHash(), start_height, FoundBlock().hash(start_block))); diff --git a/test/functional/feature_pruning.py b/test/functional/feature_pruning.py index 8d924282cfc588..633f5b7359da2b 100755 --- a/test/functional/feature_pruning.py +++ b/test/functional/feature_pruning.py @@ -138,7 +138,7 @@ def test_invalid_command_line_options(self): def test_rescan_blockchain(self): self.restart_node(0, ["-prune=550"]) - assert_raises_rpc_error(-1, "Can't rescan beyond pruned data. Use RPC call getblockchaininfo to determine your pruned height.", self.nodes[0].rescanblockchain) + assert_raises_rpc_error(-1, "Failed to rescan unavailable blocks. This may be caused by pruning or an in-progress assumeutxo background sync. Use RPC call getblockchaininfo to determine your pruned height or check your logs for assumeutxo progress.", self.nodes[0].rescanblockchain) def test_height_min(self): assert os.path.isfile(os.path.join(self.prunedir, "blk00000.dat")), "blk00000.dat is missing, pruning too early" diff --git a/test/functional/wallet_assumeutxo.py b/test/functional/wallet_assumeutxo.py index 681dc58ae881b2..2712722d64a6b3 100755 --- a/test/functional/wallet_assumeutxo.py +++ b/test/functional/wallet_assumeutxo.py @@ -148,6 +148,9 @@ def run_test(self): assert_equal(result[0]['error']['code'], -1) assert_equal(result[0]['error']['message'], expected_error_message) + self.log.info("Test that rescanning blocks from before the snapshot fails when blocks are not available from the background sync yet") + assert_raises_rpc_error(-1, "Failed to rescan unavailable blocks. This may be caused by pruning or an in-progress assumeutxo background sync. Use RPC call getblockchaininfo to determine your pruned height or check your logs for assumeutxo progress.", n1.rescanblockchain, 100) + PAUSE_HEIGHT = FINAL_HEIGHT - 40 self.log.info("Restarting node to stop at height %d", PAUSE_HEIGHT)