Merge bitcoin/bitcoin#36553: test: Add missing sync_mempools in wallet_conflicts.py
What changed, and why it matters
This commit fixes a flaky automated test in Bitcoin Core. It adds missing mempool synchronization calls in a wallet-conflict test and removes a couple of redundant block-sync calls. There is no change to production code, no security vulnerability, and no risk to users' funds or node safety.
No security action needed. This is a routine test-maintenance change.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch modifies only test/functional/wallet_conflicts.py. It adds self.sync_mempools() after each sendrawtransaction in test_mempool_conflict() so that all test nodes agree on mempool state before assertions run. It also removes two self.sync_blocks() calls that were redundant because self.generate() already calls sync_all(), and it changes the final generate() call to use the bob node directly. The failure being fixed was a 2400-second mempool-sync timeout in CI caused by nodes having divergent mempool contents when generate() tried to sync them.
Changed components
test/functional/wallet_conflicts.pyInspect captured patch +5 / −4
### test/functional/wallet_conflicts.py
@@ -44,7 +44,6 @@ def test_block_conflicts(self):
txid_conflict_from_1 = self.nodes[0].sendtoaddress(self.nodes[0].getnewaddress(), Decimal("10"))
txid_conflict_from_2 = self.nodes[0].sendtoaddress(self.nodes[0].getnewaddress(), Decimal("10"))
self.generate(self.nodes[0], 1)
- self.sync_blocks()
self.log.info("Disconnect nodes to broadcast conflicts on their respective chains")
self.disconnect_nodes(0, 1)
@@ -130,7 +129,6 @@ def test_block_conflicts(self):
# Rebroadcast former conflicted tx and check it confirms smoothly
self.nodes[2].sendrawtransaction(conflicted["hex"])
self.generate(self.nodes[2], 1)
- self.sync_blocks()
former_conflicted = self.nodes[0].gettransaction(txid_AB_parent)
assert_equal(former_conflicted["confirmations"], 1)
assert_equal(former_conflicted["blockheight"], 217)
@@ -165,12 +163,14 @@ def test_mempool_conflict(self):
# broadcast tx1
tx1_txid = alice.sendrawtransaction(tx1)
+ self.sync_mempools()
assert_equal(alice.listunspent(), [unspents[2]])
assert_equal(alice.getbalance(), 25)
# broadcast tx2, replaces tx1 in mempool
tx2_txid = alice.sendrawtransaction(tx2)
+ self.sync_mempools()
# Check that unspent[0] is now available because the transaction spending it has been replaced in the mempool
assert_equal(alice.listunspent(), [unspents[0]])
@@ -186,9 +186,10 @@ def test_mempool_conflict(self):
# rebroadcasted. Now unspent[0] is not available, because
# tx1 is no longer conflicted.
alice.sendrawtransaction(tx3)
+ self.sync_mempools()
assert_equal(alice.gettransaction(tx1_txid)["mempoolconflicts"], [])
- assert tx1_txid not in self.nodes[0].getrawmempool()
+ assert tx1_txid not in alice.getrawmempool()
# now all of alice's outputs should be considered spent
# unspent[0]: spent by inactive tx1
@@ -199,7 +200,7 @@ def test_mempool_conflict(self):
# Clean up for next test
bob.sendall([self.nodes[2].getnewaddress()])
- self.generate(self.nodes[2], 1)
+ self.generate(bob, 1)
alice.unloadwallet()
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.