@@ -216,6 +216,25 @@ def test_preferred_inv(self):
216
216
with p2p_lock :
217
217
assert_equal (peer .tx_getdata_count , 1 )
218
218
219
+ def test_txid_inv_delay (self , glob_wtxid = False ):
220
+ 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 ))
221
+ self .
restart_node (
0 ,
extra_args = [
'[email protected] ' ])
222
+ mock_time = int (time .time () + 1 )
223
+ self .nodes [0 ].setmocktime (mock_time )
224
+ peer = self .nodes [0 ].add_p2p_connection (TestP2PConn (wtxidrelay = False ))
225
+ if glob_wtxid :
226
+ # Add a second wtxid-relay connection otherwise TXID_RELAY_DELAY is waived in
227
+ # lack of wtxid-relay peers
228
+ self .nodes [0 ].add_p2p_connection (TestP2PConn (wtxidrelay = True ))
229
+ peer .send_message (msg_inv ([CInv (t = MSG_TX , h = 0xff11ff11 )]))
230
+ peer .sync_with_ping ()
231
+ with p2p_lock :
232
+ assert_equal (peer .tx_getdata_count , 0 if glob_wtxid else 1 )
233
+ self .nodes [0 ].setmocktime (mock_time + TXID_RELAY_DELAY )
234
+ peer .wait_until (lambda : peer .tx_getdata_count >= 1 , timeout = 1 )
235
+ with p2p_lock :
236
+ assert_equal (peer .tx_getdata_count , 1 )
237
+
219
238
def test_large_inv_batch (self ):
220
239
self .log .info ('Test how large inv batches are handled with relay permission' )
221
240
self .
restart_node (
0 ,
extra_args = [
'[email protected] ' ])
@@ -242,6 +261,8 @@ def run_test(self):
242
261
self .test_disconnect_fallback ()
243
262
self .test_notfound_fallback ()
244
263
self .test_preferred_inv ()
264
+ self .test_txid_inv_delay ()
265
+ self .test_txid_inv_delay (True )
245
266
self .test_large_inv_batch ()
246
267
self .test_spurious_notfound ()
247
268
0 commit comments