From 07350e204dedfba20da461d9cdcd469dc95e01c3 Mon Sep 17 00:00:00 2001 From: Martin Zumsande Date: Mon, 12 May 2025 16:26:17 -0400 Subject: [PATCH 1/2] test: Fix intermittent failure in wallet_basic.py There could be a race with outstanding TxAddedToMempool notifications being applied to the soon-to-be created wallet. Fixes an intermittent timeout reproducable by adding a sleep to AddToWallet. --- test/functional/wallet_basic.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/functional/wallet_basic.py b/test/functional/wallet_basic.py index ce5790100b8..fe1f38ea975 100755 --- a/test/functional/wallet_basic.py +++ b/test/functional/wallet_basic.py @@ -603,6 +603,8 @@ class WalletTest(BitcoinTestFramework): txid_a = self.nodes[0].sendtoaddress(addr_a, 0.01) txid_b = self.nodes[0].sendtoaddress(addr_b, 0.01) self.generate(self.nodes[0], 1, sync_fun=self.no_op) + # Prevent race of listunspent with outstanding TxAddedToMempool notifications + self.nodes[0].syncwithvalidationinterfacequeue() # Now import the descriptors, make sure we can identify on which descriptor each coin was received. self.nodes[0].createwallet(wallet_name="wo", descriptors=True, disable_private_keys=True) wo_wallet = self.nodes[0].get_wallet_rpc("wo") From e7ad86e1ca3b0b2f2795e91c2f9959486c67dd90 Mon Sep 17 00:00:00 2001 From: Martin Zumsande Date: Tue, 13 May 2025 11:40:42 -0400 Subject: [PATCH 2/2] test: fix another intermittent failure in wallet_basic.py During init, the test framework will start using rpc after the mempool was loaded. It will not wait for postInitProcess or outstanding transactionAddedToMempool notifications, leading to a possible race, in which listunspent is being called while the tx is still in Inactive status. Prevent this by processing outstanding notifications. --- test/functional/wallet_basic.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/functional/wallet_basic.py b/test/functional/wallet_basic.py index fe1f38ea975..4c2e90e08ef 100755 --- a/test/functional/wallet_basic.py +++ b/test/functional/wallet_basic.py @@ -656,6 +656,9 @@ class WalletTest(BitcoinTestFramework): # check that it works again with -spendzeroconfchange set (=default) self.restart_node(0, ["-spendzeroconfchange=1"]) + # Make sure the wallet knows the tx in the mempool + self.nodes[0].syncwithvalidationinterfacequeue() + zeroconf_wallet = self.nodes[0].get_wallet_rpc("zeroconf") utxos = zeroconf_wallet.listunspent(minconf=0) assert_equal(len(utxos), 1)