aboutsummaryrefslogtreecommitdiff
path: root/test/functional/p2p_tx_download.py
diff options
context:
space:
mode:
authorAntoine Riard <ariard@student.42.fr>2020-10-17 11:22:01 -0400
committerAntoine Riard <ariard@student.42.fr>2020-11-02 18:29:49 -0500
commit06efb3163cdf30e74df3f78afc4896b0f55ce937 (patch)
tree02f54d64c7fcdc8d5792296831a6e4f8acc539c7 /test/functional/p2p_tx_download.py
parenta07910abcd580ed07187794cf0e1faf040bb4212 (diff)
downloadbitcoin-06efb3163cdf30e74df3f78afc4896b0f55ce937.tar.xz
Add functional test test_txid_inv_delay
Add a simple functional test to cover TXID_RELAY_DELAY as applied as a TxRequestTracker parameter in AddTxAnnoucement.
Diffstat (limited to 'test/functional/p2p_tx_download.py')
-rwxr-xr-xtest/functional/p2p_tx_download.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/functional/p2p_tx_download.py b/test/functional/p2p_tx_download.py
index a666d6c8d1..b82ca95cbe 100755
--- a/test/functional/p2p_tx_download.py
+++ b/test/functional/p2p_tx_download.py
@@ -216,6 +216,25 @@ class TxDownloadTest(BitcoinTestFramework):
with p2p_lock:
assert_equal(peer.tx_getdata_count, 1)
+ 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.restart_node(0, extra_args=['-whitelist=noban@127.0.0.1'])
+ mock_time = int(time.time() + 1)
+ self.nodes[0].setmocktime(mock_time)
+ peer = self.nodes[0].add_p2p_connection(TestP2PConn(wtxidrelay=False))
+ if glob_wtxid:
+ # Add a second wtxid-relay connection otherwise TXID_RELAY_DELAY is waived in
+ # lack of wtxid-relay peers
+ self.nodes[0].add_p2p_connection(TestP2PConn(wtxidrelay=True))
+ peer.send_message(msg_inv([CInv(t=MSG_TX, h=0xff11ff11)]))
+ peer.sync_with_ping()
+ with p2p_lock:
+ assert_equal(peer.tx_getdata_count, 0 if glob_wtxid else 1)
+ self.nodes[0].setmocktime(mock_time + TXID_RELAY_DELAY)
+ peer.wait_until(lambda: peer.tx_getdata_count >= 1, timeout=1)
+ with p2p_lock:
+ assert_equal(peer.tx_getdata_count, 1)
+
def test_large_inv_batch(self):
self.log.info('Test how large inv batches are handled with relay permission')
self.restart_node(0, extra_args=['-whitelist=relay@127.0.0.1'])
@@ -242,6 +261,8 @@ class TxDownloadTest(BitcoinTestFramework):
self.test_disconnect_fallback()
self.test_notfound_fallback()
self.test_preferred_inv()
+ self.test_txid_inv_delay()
+ self.test_txid_inv_delay(True)
self.test_large_inv_batch()
self.test_spurious_notfound()