mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-02 09:46:52 -05:00
Add mutation for functional test test_preferred_inv
Add a booelan arg to test_preferred_inv to cover NONPREF_PEER_TX_DELAY as applied as a TxRequestTracker parameter in AddTxAnnouncement.
This commit is contained in:
parent
06efb3163c
commit
d3b5eac9a9
1 changed files with 18 additions and 6 deletions
|
@ -47,6 +47,7 @@ TXID_RELAY_DELAY = 2 # seconds
|
||||||
OVERLOADED_PEER_DELAY = 2 # seconds
|
OVERLOADED_PEER_DELAY = 2 # seconds
|
||||||
MAX_GETDATA_IN_FLIGHT = 100
|
MAX_GETDATA_IN_FLIGHT = 100
|
||||||
MAX_PEER_TX_ANNOUNCEMENTS = 5000
|
MAX_PEER_TX_ANNOUNCEMENTS = 5000
|
||||||
|
NONPREF_PEER_TX_DELAY = 2
|
||||||
|
|
||||||
# Python test constants
|
# Python test constants
|
||||||
NUM_INBOUND = 10
|
NUM_INBOUND = 10
|
||||||
|
@ -207,14 +208,24 @@ class TxDownloadTest(BitcoinTestFramework):
|
||||||
with p2p_lock:
|
with p2p_lock:
|
||||||
assert_equal(peer_fallback.tx_getdata_count, 1)
|
assert_equal(peer_fallback.tx_getdata_count, 1)
|
||||||
|
|
||||||
def test_preferred_inv(self):
|
def test_preferred_inv(self, preferred=False):
|
||||||
self.log.info('Check that invs from preferred peers are downloaded immediately')
|
if preferred:
|
||||||
self.restart_node(0, extra_args=['-whitelist=noban@127.0.0.1'])
|
self.log.info('Check invs from preferred peers are downloaded immediately')
|
||||||
|
self.restart_node(0, extra_args=['-whitelist=noban@127.0.0.1'])
|
||||||
|
else:
|
||||||
|
self.log.info('Check invs from non-preferred peers are downloaded after {} s'.format(NONPREF_PEER_TX_DELAY))
|
||||||
|
mock_time = int(time.time() + 1)
|
||||||
|
self.nodes[0].setmocktime(mock_time)
|
||||||
peer = self.nodes[0].add_p2p_connection(TestP2PConn())
|
peer = self.nodes[0].add_p2p_connection(TestP2PConn())
|
||||||
peer.send_message(msg_inv([CInv(t=MSG_WTX, h=0xff00ff00)]))
|
peer.send_message(msg_inv([CInv(t=MSG_WTX, h=0xff00ff00)]))
|
||||||
peer.wait_until(lambda: peer.tx_getdata_count >= 1, timeout=1)
|
peer.sync_with_ping()
|
||||||
with p2p_lock:
|
if preferred:
|
||||||
assert_equal(peer.tx_getdata_count, 1)
|
peer.wait_until(lambda: peer.tx_getdata_count >= 1, timeout=1)
|
||||||
|
else:
|
||||||
|
with p2p_lock:
|
||||||
|
assert_equal(peer.tx_getdata_count, 0)
|
||||||
|
self.nodes[0].setmocktime(mock_time + NONPREF_PEER_TX_DELAY)
|
||||||
|
peer.wait_until(lambda: peer.tx_getdata_count >= 1, timeout=1)
|
||||||
|
|
||||||
def test_txid_inv_delay(self, glob_wtxid=False):
|
def test_txid_inv_delay(self, glob_wtxid=False):
|
||||||
self.log.info('Check that inv from a txid-relay peers are delayed by {} s, with a wtxid peer {}'.format(TXID_RELAY_DELAY, glob_wtxid))
|
self.log.info('Check that inv from a txid-relay peers are delayed by {} s, with a wtxid peer {}'.format(TXID_RELAY_DELAY, glob_wtxid))
|
||||||
|
@ -261,6 +272,7 @@ class TxDownloadTest(BitcoinTestFramework):
|
||||||
self.test_disconnect_fallback()
|
self.test_disconnect_fallback()
|
||||||
self.test_notfound_fallback()
|
self.test_notfound_fallback()
|
||||||
self.test_preferred_inv()
|
self.test_preferred_inv()
|
||||||
|
self.test_preferred_inv(True)
|
||||||
self.test_txid_inv_delay()
|
self.test_txid_inv_delay()
|
||||||
self.test_txid_inv_delay(True)
|
self.test_txid_inv_delay(True)
|
||||||
self.test_large_inv_batch()
|
self.test_large_inv_batch()
|
||||||
|
|
Loading…
Add table
Reference in a new issue