mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-06-30 02:31:05 +02:00
[tests] Speed up p2p_segwit.py
Never sleep for more than 5 seconds when waiting for an inv-getdata exchange to time out.
This commit is contained in:
@ -164,7 +164,7 @@ class TestP2PConn(P2PInterface):
|
|||||||
def on_wtxidrelay(self, message):
|
def on_wtxidrelay(self, message):
|
||||||
self.last_wtxidrelay.append(message)
|
self.last_wtxidrelay.append(message)
|
||||||
|
|
||||||
def announce_tx_and_wait_for_getdata(self, tx, timeout=60, success=True, use_wtxid=False):
|
def announce_tx_and_wait_for_getdata(self, tx, success=True, use_wtxid=False):
|
||||||
if success:
|
if success:
|
||||||
# sanity check
|
# sanity check
|
||||||
assert (self.wtxidrelay and use_wtxid) or (not self.wtxidrelay and not use_wtxid)
|
assert (self.wtxidrelay and use_wtxid) or (not self.wtxidrelay and not use_wtxid)
|
||||||
@ -178,11 +178,11 @@ class TestP2PConn(P2PInterface):
|
|||||||
|
|
||||||
if success:
|
if success:
|
||||||
if use_wtxid:
|
if use_wtxid:
|
||||||
self.wait_for_getdata([wtxid], timeout)
|
self.wait_for_getdata([wtxid])
|
||||||
else:
|
else:
|
||||||
self.wait_for_getdata([tx.sha256], timeout)
|
self.wait_for_getdata([tx.sha256])
|
||||||
else:
|
else:
|
||||||
time.sleep(timeout)
|
time.sleep(5)
|
||||||
assert not self.last_message.get("getdata")
|
assert not self.last_message.get("getdata")
|
||||||
|
|
||||||
def announce_block_and_wait_for_getdata(self, block, use_header, timeout=60):
|
def announce_block_and_wait_for_getdata(self, block, use_header, timeout=60):
|
||||||
@ -604,7 +604,7 @@ class SegWitTest(BitcoinTestFramework):
|
|||||||
|
|
||||||
# Since we haven't delivered the tx yet, inv'ing the same tx from
|
# Since we haven't delivered the tx yet, inv'ing the same tx from
|
||||||
# a witness transaction ought not result in a getdata.
|
# a witness transaction ought not result in a getdata.
|
||||||
self.test_node.announce_tx_and_wait_for_getdata(tx, timeout=2, success=False)
|
self.test_node.announce_tx_and_wait_for_getdata(tx, success=False)
|
||||||
|
|
||||||
# Delivering this transaction with witness should fail (no matter who
|
# Delivering this transaction with witness should fail (no matter who
|
||||||
# its from)
|
# its from)
|
||||||
@ -1461,7 +1461,7 @@ class SegWitTest(BitcoinTestFramework):
|
|||||||
self.std_node.announce_tx_and_wait_for_getdata(tx3)
|
self.std_node.announce_tx_and_wait_for_getdata(tx3)
|
||||||
test_transaction_acceptance(self.nodes[1], self.std_node, tx3, with_witness=True, accepted=False, reason="bad-txns-nonstandard-inputs")
|
test_transaction_acceptance(self.nodes[1], self.std_node, tx3, with_witness=True, accepted=False, reason="bad-txns-nonstandard-inputs")
|
||||||
# Now the node will no longer ask for getdata of this transaction when advertised by same txid
|
# Now the node will no longer ask for getdata of this transaction when advertised by same txid
|
||||||
self.std_node.announce_tx_and_wait_for_getdata(tx3, timeout=5, success=False)
|
self.std_node.announce_tx_and_wait_for_getdata(tx3, success=False)
|
||||||
|
|
||||||
# Spending a higher version witness output is not allowed by policy,
|
# Spending a higher version witness output is not allowed by policy,
|
||||||
# even with fRequireStandard=false.
|
# even with fRequireStandard=false.
|
||||||
|
Reference in New Issue
Block a user