This PR adds a test in wallet_transactiontime_rescan.py. Previously we only tested that abortrescan() returns False when no rescan was running. This change verifies that it returns True and actually interrupts a running scan.
How it works:
- spawn a daemon background thread that rescans a tail of the wallet’s chain.
- aggressively poll every 10 ms (for up to 5 s) until we see the node start scanning
- Call ‘abortrescan()’ and assert to True
- Threads are joined with short timeouts so they can’t hang teardown
Dynamic tail: If the tail of the wallets chain is too small, by the time we see “scanning=True”, the scan might already be finished (so no scan is active, and abortrescan() will be ‘False’. A fixed sized tail caused issues in ~10% of test runs (the dynamic tail was tested 200 times without an error). By starting with 10 blocks and doubling for up to 5 times, we can ensure that a suitable tail length is found so that:
- The node sets scanning=true long enough for our tight (10 ms) polls to catch it
- But still finishes in a few seconds so the test stays fast.
I’d love feedback if you have ideas for a simpler or more reliable way design this test, or if you spot any edge cases this might miss.