Skip to content

Commit

Permalink
test: Include assumeutxo as a failure reason of rescanblockchain
Browse files Browse the repository at this point in the history
  • Loading branch information
fjahr committed Sep 23, 2024
1 parent 5b8faac commit fa821ad
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/wallet/rpc/transactions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)));
Expand Down
2 changes: 1 addition & 1 deletion test/functional/feature_pruning.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 3 additions & 0 deletions test/functional/wallet_assumeutxo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit fa821ad

Please sign in to comment.