Skip to content

Commit 57ee739

Browse files
author
MarcoFalke
committed
Merge #11538: qa: Fix race condition failures in replace-by-fee.py, sendheaders.py
6d51eae qa: Fix race condition in sendheaders.py (Suhas Daftuar) c96b2e4 qa: Fix replace-by-fee race condition failures (Suhas Daftuar) Pull request description: I think #11407 broke replace-by-fee by introducing a race condition. I was observing frequent failures of replace-by-fee locally, always with a mempool sync failure (the sync call was added in #11407). It appeared to me like there were two causes: sometimes the node would be in IBD and not request the transaction that was relayed; other times the blocks generated in make_utxo wouldn't have relayed quickly enough for the spend of the transaction to be accepted. I believe I've fixed both potential errors. ping @instagibbs Edit: I found a race condition in the sendheaders.py test, where if the verack from the python node wasn't processed before the first block in the test was generated, then no block announcement would go out to that peer, breaking the test. Fixed by adding a sync_with_ping after waiting for verack. Tree-SHA512: 6ad160966e432c151c1ce6e88ae67e60e47123523bda3755cf7697a00e1a5ba38de8561751826e3d7cf0e492f8c2aec298e1b4de8424ebbaf497f099a1ef1d07
2 parents 6157e8c + 6d51eae commit 57ee739

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

test/functional/replace-by-fee.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,14 @@ def set_test_params(self):
7272
["-mempoolreplacement=0"]]
7373

7474
def run_test(self):
75+
# Leave IBD
76+
self.nodes[0].generate(1)
77+
7578
make_utxo(self.nodes[0], 1*COIN)
7679

80+
# Ensure nodes are synced
81+
self.sync_all()
82+
7783
self.log.info("Running test simple doublespend...")
7884
self.test_simple_doublespend()
7985

@@ -110,13 +116,18 @@ def test_simple_doublespend(self):
110116
"""Simple doublespend"""
111117
tx0_outpoint = make_utxo(self.nodes[0], int(1.1*COIN))
112118

119+
# make_utxo may have generated a bunch of blocks, so we need to sync
120+
# before we can spend the coins generated, or else the resulting
121+
# transactions might not be accepted by our peers.
122+
self.sync_all()
123+
113124
tx1a = CTransaction()
114125
tx1a.vin = [CTxIn(tx0_outpoint, nSequence=0)]
115126
tx1a.vout = [CTxOut(1*COIN, CScript([b'a']))]
116127
tx1a_hex = txToHex(tx1a)
117128
tx1a_txid = self.nodes[0].sendrawtransaction(tx1a_hex, True)
118129

119-
self.sync_all([self.nodes])
130+
self.sync_all()
120131

121132
# Should fail because we haven't changed the fee
122133
tx1b = CTransaction()

test/functional/sendheaders.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,10 @@ def run_test(self):
225225
inv_node.wait_for_verack()
226226
test_node.wait_for_verack()
227227

228+
# Ensure verack's have been processed by our peer
229+
inv_node.sync_with_ping()
230+
test_node.sync_with_ping()
231+
228232
tip = int(self.nodes[0].getbestblockhash(), 16)
229233

230234
# PART 1

0 commit comments

Comments
 (0)