@@ -270,6 +270,36 @@ def test_rejects_filter_reset(self):
270
270
node .bumpmocktime (MAX_GETDATA_INBOUND_WAIT )
271
271
peer .wait_for_getdata ([int (low_fee_tx ['wtxid' ], 16 )])
272
272
273
+ def test_inv_wtxidrelay_mismatch (self ):
274
+ self .log .info ("Check that INV messages that don't match the wtxidrelay setting are ignored" )
275
+ node = self .nodes [0 ]
276
+ wtxidrelay_on_peer = node .add_p2p_connection (TestP2PConn (wtxidrelay = True ))
277
+ wtxidrelay_off_peer = node .add_p2p_connection (TestP2PConn (wtxidrelay = False ))
278
+ random_tx = self .wallet .create_self_transfer ()
279
+
280
+ # MSG_TX INV from wtxidrelay=True peer -> mismatch, ignored
281
+ wtxidrelay_on_peer .send_and_ping (msg_inv ([CInv (t = MSG_TX , h = int (random_tx ['txid' ], 16 ))]))
282
+ node .setmocktime (int (time .time ()))
283
+ node .bumpmocktime (MAX_GETDATA_INBOUND_WAIT )
284
+ wtxidrelay_on_peer .sync_with_ping ()
285
+ assert_equal (wtxidrelay_on_peer .tx_getdata_count , 0 )
286
+
287
+ # MSG_WTX INV from wtxidrelay=False peer -> mismatch, ignored
288
+ wtxidrelay_off_peer .send_and_ping (msg_inv ([CInv (t = MSG_WTX , h = int (random_tx ['wtxid' ], 16 ))]))
289
+ node .bumpmocktime (MAX_GETDATA_INBOUND_WAIT )
290
+ wtxidrelay_off_peer .sync_with_ping ()
291
+ assert_equal (wtxidrelay_off_peer .tx_getdata_count , 0 )
292
+
293
+ # MSG_TX INV from wtxidrelay=False peer works
294
+ wtxidrelay_off_peer .send_and_ping (msg_inv ([CInv (t = MSG_TX , h = int (random_tx ['txid' ], 16 ))]))
295
+ node .bumpmocktime (MAX_GETDATA_INBOUND_WAIT )
296
+ wtxidrelay_off_peer .wait_for_getdata ([int (random_tx ['txid' ], 16 )])
297
+
298
+ # MSG_WTX INV from wtxidrelay=True peer works
299
+ wtxidrelay_on_peer .send_and_ping (msg_inv ([CInv (t = MSG_WTX , h = int (random_tx ['wtxid' ], 16 ))]))
300
+ node .bumpmocktime (MAX_GETDATA_INBOUND_WAIT )
301
+ wtxidrelay_on_peer .wait_for_getdata ([int (random_tx ['wtxid' ], 16 )])
302
+
273
303
def run_test (self ):
274
304
self .wallet = MiniWallet (self .nodes [0 ])
275
305
@@ -291,6 +321,7 @@ def run_test(self):
291
321
(self .test_inv_block , True ),
292
322
(self .test_tx_requests , True ),
293
323
(self .test_rejects_filter_reset , False ),
324
+ (self .test_inv_wtxidrelay_mismatch , False ),
294
325
]:
295
326
self .stop_nodes ()
296
327
self .start_nodes ()
0 commit comments