functional_tests: fix HTTP digest auth sporadic failures
What changed, and why it matters
This change only modifies a test script for Monero's automated functional tests. It replaces one way of setting up test blockchain state (mining through a wallet) with another (generating a block directly via the daemon and rescanning the wallet). It also makes two test assertions more explicit about expecting a connection to be rejected. There is no change to the actual Monero node, wallet, or RPC authentication code that users run, and nothing here suggests a security vulnerability or fix in production software.
No security action required. Treat as a normal test-maintenance commit.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit updates tests/functional_tests/http_digest_auth.py. It removes mine_through_wallet(), which called wallet.start_mining() and waited up to 20 seconds for blocks, and replaces it with scan_wallet(), which uses daemon.generateblocks() to create one block and then verifies wallet rescan behavior. It also rewrites test_daemon_login_required and test_wallet_login_required to use a rejected flag and assert(rejected) instead of the previous assert(False) inside a try/except. These are test-harness robustness and clarity improvements only; no production code is touched.
Changed components
tests/functional_tests/http_digest_auth.pyInspect captured patch +22 / −26
diff --git a/tests/functional_tests/http_digest_auth.py b/tests/functional_tests/http_digest_auth.py
index 1311ae6..9bb7ec2 100644
--- a/tests/functional_tests/http_digest_auth.py
+++ b/tests/functional_tests/http_digest_auth.py
@@ -51,25 +51,27 @@ class HttpDigestAuthTest():
self.make_daemon_conn()
self.create_wallet()
- self.mine_through_wallet()
+ self.scan_wallet()
def test_daemon_login_required(self):
print('Attempting to connect to daemon loginless with RPC digest authentication required...')
bad_daemon = Daemon(idx = DAEMON_IDX)
+ rejected = False
try:
res = bad_daemon.get_height()
- assert(False)
except:
- pass
-
+ rejected = True
+ assert(rejected)
+
def test_wallet_login_required(self):
print('Attempting to connect to wallet server loginless with RPC digest authentication required...')
bad_wallet = Wallet(idx = WALLET_IDX)
+ rejected = False
try:
res = bad_wallet.get_balance()
- assert(False)
except:
- pass
+ rejected = True
+ assert(rejected)
def make_daemon_conn(self):
print('Connecting to daemon with RPC digest authentication required...')
@@ -85,26 +87,20 @@ class HttpDigestAuthTest():
try: self.wallet.close_wallet()
except: pass
res = self.wallet.restore_deterministic_wallet(seed = WALLET_SEED)
-
- def mine_through_wallet(self):
- print('Telling login-required daemon to start mining through login-required wallet server...')
- start_height = self.daemon.get_height().height
- self.wallet.start_mining(2)
-
- print("Waiting a few seconds for mining to occur...")
- for tries in range(20):
- time.sleep(1)
-
- stop_height = self.daemon.get_height().height
- if stop_height > start_height:
- break
-
- print('Telling login-required daemon to stop mining through login-required wallet server...')
- self.wallet.stop_mining()
-
- num_blocks_mined = stop_height - start_height
- assert num_blocks_mined > 0
- print('Mined {} blocks!'.format(num_blocks_mined))
+ self.wallet_address = res.address
+ self.wallet.auto_refresh(False)
+
+ def scan_wallet(self):
+ print('Telling login-required wallet server to rescan blockchain from login-required daemon...')
+ self.wallet.refresh()
+ h1 = self.daemon.get_height().height
+ assert(self.wallet.get_height().height == h1)
+ self.daemon.generateblocks(self.wallet_address, 1)
+ h2 = self.daemon.get_height().height
+ assert(h2 > h1)
+ assert(self.wallet.get_height().height == h1)
+ self.wallet.rescan_blockchain(hard = True)
+ assert(self.wallet.get_height().height == h2)
if __name__ == '__main__':
HttpDigestAuthTest().run_test()
Why this scored 13/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.