test: add coverage for importdescriptors errors when using assumeutxo
What changed, and why it matters
This commit only adds a new test case to Bitcoin Core's test suite. It checks that the wallet's importdescriptors RPC returns a specific error message when used during an in-progress assumeutxo background sync. There is no change to production code, no bug fix, and no security vulnerability being introduced or patched.
No security action needed. This is a routine test-coverage commit and can be reviewed as normal QA.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff modifies test/functional/wallet_assumeutxo.py to add coverage for an additional importdescriptors error path. It refactors the expected error message into a helper function and adds a second test case using the ‘now’ timestamp in addition to the existing timestamp=0 case. The change is purely additive test code; no consensus, networking, wallet, or RPC implementation code is touched.
Changed components
test/functional/wallet_assumeutxo.pyInspect captured patch +9 / −3
diff --git a/test/functional/wallet_assumeutxo.py b/test/functional/wallet_assumeutxo.py
index 3f28e36c..9c647fa2 100755
--- a/test/functional/wallet_assumeutxo.py
+++ b/test/functional/wallet_assumeutxo.py
@@ -215,12 +215,18 @@ class AssumeutxoTest(BitcoinTestFramework):
wallet_name = "w1"
n1.createwallet(wallet_name, disable_private_keys=True)
key = get_generate_key()
- time = n1.getblockchaininfo()['time']
+ block_info = n1.getblockchaininfo()
+ time = block_info["time"]
+ def expected_rescan_error(timestamp):
+ return f"Rescan failed for descriptor with timestamp {timestamp}. There was an error reading a block from time {time}, which is after or within 7200 seconds of key creation, and could contain transactions pertaining to the desc. As a result, transactions and coins using this desc may not appear in the wallet. This error is likely caused by an in-progress assumeutxo background sync. Check logs or getchainstates RPC for assumeutxo background sync progress and try again later."
timestamp = 0
- expected_error_message = f"Rescan failed for descriptor with timestamp {timestamp}. There was an error reading a block from time {time}, which is after or within 7200 seconds of key creation, and could contain transactions pertaining to the desc. As a result, transactions and coins using this desc may not appear in the wallet. This error is likely caused by an in-progress assumeutxo background sync. Check logs or getchainstates RPC for assumeutxo background sync progress and try again later."
result = self.import_descriptor(n1, wallet_name, key, timestamp)
assert_equal(result[0]['error']['code'], -1)
- assert_equal(result[0]['error']['message'], expected_error_message)
+ assert_equal(result[0]['error']['message'], expected_rescan_error(timestamp))
+ now_timestamp = block_info["mediantime"]
+ result = self.import_descriptor(n1, wallet_name, get_generate_key(), "now")
+ assert_equal(result[0]['error']['code'], -1)
+ assert_equal(result[0]['error']['message'], expected_rescan_error(now_timestamp))
self.log.info("Test that rescanning blocks from before the snapshot fails when blocks are not available from the background sync yet")
w1 = n1.get_wallet_rpc(wallet_name)
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.