Skip to content

Commit 566aada

Browse files
committed
Test that wtxid relay peers add wtxid to reject filter
h/t Anthony Towns
1 parent 0fea6ed commit 566aada

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

test/functional/p2p_segwit.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,9 @@ def on_wtxidrelay(self, message):
174174
self.last_wtxidrelay.append(message)
175175

176176
def announce_tx_and_wait_for_getdata(self, tx, timeout=60, success=True, use_wtxid=False):
177+
if success:
178+
# sanity check
179+
assert (self.wtxidrelay and use_wtxid) or (not self.wtxidrelay and not use_wtxid)
177180
with mininode_lock:
178181
self.last_message.pop("getdata", None)
179182
if use_wtxid:
@@ -259,6 +262,8 @@ def run_test(self):
259262
self.old_node = self.nodes[0].add_p2p_connection(TestP2PConn(), services=NODE_NETWORK)
260263
# self.std_node is for testing node1 (fRequireStandard=true)
261264
self.std_node = self.nodes[1].add_p2p_connection(TestP2PConn(), services=NODE_NETWORK | NODE_WITNESS)
265+
# self.std_wtx_node is for testing node1 with wtxid relay
266+
self.std_wtx_node = self.nodes[1].add_p2p_connection(TestP2PConn(wtxidrelay=True), services=NODE_NETWORK | NODE_WITNESS)
262267

263268
assert self.test_node.nServices & NODE_WITNESS != 0
264269

@@ -1320,10 +1325,13 @@ def test_tx_relay_after_segwit_activation(self):
13201325
tx3.rehash()
13211326

13221327
# Node will not be blinded to the transaction, requesting it any number of times
1323-
# since it is being announced via txid relay.
1328+
# if it is being announced via txid relay.
1329+
# Node will be blinded to the transaction via wtxid, however.
13241330
self.std_node.announce_tx_and_wait_for_getdata(tx3)
1331+
self.std_wtx_node.announce_tx_and_wait_for_getdata(tx3, use_wtxid=True)
13251332
test_transaction_acceptance(self.nodes[1], self.std_node, tx3, True, False, 'tx-size')
13261333
self.std_node.announce_tx_and_wait_for_getdata(tx3)
1334+
self.std_wtx_node.announce_tx_and_wait_for_getdata(tx3, use_wtxid=True, success=False)
13271335

13281336
# Remove witness stuffing, instead add extra witness push on stack
13291337
tx3.vout[0] = CTxOut(tx2.vout[0].nValue - 1000, CScript([OP_TRUE, OP_DROP] * 15 + [OP_TRUE]))

0 commit comments

Comments
 (0)