test: check wallet rescan properly in feature_pruning
What changed, and why it matters
This commit only changes a test file. It renames a test method and adds explicit checks that a wallet finishes rescanning after restarting pruned Bitcoin nodes. There is no change to production code, no fix for a live bug, and no security-relevant behavior change in the software users run.
No action required. This is a test-only improvement and does not affect deployed Bitcoin Core nodes.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff modifies test/functional/feature_pruning.py. The wallet_test() method is renamed to test_wallet_rescan(), and after each restart that triggers a wallet rescan the test now polls getwalletinfo() until scanning is False and lastprocessedblock.height matches the expected block count. This makes the existing test more rigorous but does not alter Bitcoin Core’s runtime code.
Changed components
test/functional/feature_pruning.pyInspect captured patch +10 / −4
diff --git a/test/functional/feature_pruning.py b/test/functional/feature_pruning.py
index 5a56a28d..ddc3fc59 100755
--- a/test/functional/feature_pruning.py
+++ b/test/functional/feature_pruning.py
@@ -346,16 +346,22 @@ class PruneTest(BitcoinTestFramework):
self.log.info("Success")
- def wallet_test(self):
+ def test_wallet_rescan(self):
# check that the pruning node's wallet is still in good shape
self.log.info("Stop and start pruning node to trigger wallet rescan")
self.restart_node(2, extra_args=["-prune=550"])
- self.log.info("Success")
+
+ wallet_info = self.nodes[2].getwalletinfo()
+ self.wait_until(lambda: wallet_info["scanning"] == False)
+ self.wait_until(lambda: wallet_info["lastprocessedblock"]["height"] == self.nodes[2].getblockcount())
# check that wallet loads successfully when restarting a pruned node after IBD.
# this was reported to fail in #7494.
self.restart_node(5, extra_args=["-prune=550", "-blockfilterindex=1"]) # restart to trigger rescan
- self.log.info("Success")
+
+ wallet_info = self.nodes[5].getwalletinfo()
+ self.wait_until(lambda: wallet_info["scanning"] == False)
+ self.wait_until(lambda: wallet_info["lastprocessedblock"]["height"] == self.nodes[0].getblockcount())
def run_test(self):
self.log.info("Warning! This test requires 4GB of disk space")
@@ -469,7 +475,7 @@ class PruneTest(BitcoinTestFramework):
if self.is_wallet_compiled():
self.log.info("Test wallet re-scan")
- self.wallet_test()
+ self.test_wallet_rescan()
self.log.info("Test it's not possible to rescan beyond pruned data")
self.test_rescan_blockchain()
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.