Skip to content

Commit a7a1937

Browse files
author
MarcoFalke
committed
Merge bitcoin#21804: [tests] Speed up p2p_segwit.py
a33bdb5 [tests] Speed up p2p_segwit.py (John Newbery) Pull request description: Never sleep for more than 5 seconds when waiting for an inv-getdata exchange to time out. Shaves about 1 minute of the runtime of p2p_segwit.py. ACKs for top commit: MarcoFalke: review ACK a33bdb5 🐳 Tree-SHA512: 7bd892ed0b1b817579f88910ba4714519bd0d871241e1b9a67968d297de1ed63d558115abad2aae4d105ff176c35a7079a3a789f3053442aed30d6e1aefb5c4a
2 parents 1daca9f + a33bdb5 commit a7a1937

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

test/functional/p2p_segwit.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ def on_getdata(self, message):
164164
def on_wtxidrelay(self, message):
165165
self.last_wtxidrelay.append(message)
166166

167-
def announce_tx_and_wait_for_getdata(self, tx, timeout=60, success=True, use_wtxid=False):
167+
def announce_tx_and_wait_for_getdata(self, tx, success=True, use_wtxid=False):
168168
if success:
169169
# sanity check
170170
assert (self.wtxidrelay and use_wtxid) or (not self.wtxidrelay and not use_wtxid)
@@ -178,11 +178,11 @@ def announce_tx_and_wait_for_getdata(self, tx, timeout=60, success=True, use_wtx
178178

179179
if success:
180180
if use_wtxid:
181-
self.wait_for_getdata([wtxid], timeout)
181+
self.wait_for_getdata([wtxid])
182182
else:
183-
self.wait_for_getdata([tx.sha256], timeout)
183+
self.wait_for_getdata([tx.sha256])
184184
else:
185-
time.sleep(timeout)
185+
time.sleep(5)
186186
assert not self.last_message.get("getdata")
187187

188188
def announce_block_and_wait_for_getdata(self, block, use_header, timeout=60):
@@ -604,7 +604,7 @@ def test_witness_tx_relay_before_segwit_activation(self):
604604

605605
# Since we haven't delivered the tx yet, inv'ing the same tx from
606606
# a witness transaction ought not result in a getdata.
607-
self.test_node.announce_tx_and_wait_for_getdata(tx, timeout=2, success=False)
607+
self.test_node.announce_tx_and_wait_for_getdata(tx, success=False)
608608

609609
# Delivering this transaction with witness should fail (no matter who
610610
# its from)
@@ -1461,7 +1461,7 @@ def test_segwit_versions(self):
14611461
self.std_node.announce_tx_and_wait_for_getdata(tx3)
14621462
test_transaction_acceptance(self.nodes[1], self.std_node, tx3, with_witness=True, accepted=False, reason="bad-txns-nonstandard-inputs")
14631463
# Now the node will no longer ask for getdata of this transaction when advertised by same txid
1464-
self.std_node.announce_tx_and_wait_for_getdata(tx3, timeout=5, success=False)
1464+
self.std_node.announce_tx_and_wait_for_getdata(tx3, success=False)
14651465

14661466
# Spending a higher version witness output is not allowed by policy,
14671467
# even with fRequireStandard=false.

0 commit comments

Comments
 (0)