mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-29 14:59:39 -04:00
test: p2p: check that INV messages not matching wtxidrelay are ignored
This commit is contained in:
parent
e0b3336822
commit
8996fef8ae
1 changed files with 31 additions and 0 deletions
|
@ -270,6 +270,36 @@ class TxDownloadTest(BitcoinTestFramework):
|
||||||
node.bumpmocktime(MAX_GETDATA_INBOUND_WAIT)
|
node.bumpmocktime(MAX_GETDATA_INBOUND_WAIT)
|
||||||
peer.wait_for_getdata([int(low_fee_tx['wtxid'], 16)])
|
peer.wait_for_getdata([int(low_fee_tx['wtxid'], 16)])
|
||||||
|
|
||||||
|
def test_inv_wtxidrelay_mismatch(self):
|
||||||
|
self.log.info("Check that INV messages that don't match the wtxidrelay setting are ignored")
|
||||||
|
node = self.nodes[0]
|
||||||
|
wtxidrelay_on_peer = node.add_p2p_connection(TestP2PConn(wtxidrelay=True))
|
||||||
|
wtxidrelay_off_peer = node.add_p2p_connection(TestP2PConn(wtxidrelay=False))
|
||||||
|
random_tx = self.wallet.create_self_transfer()
|
||||||
|
|
||||||
|
# MSG_TX INV from wtxidrelay=True peer -> mismatch, ignored
|
||||||
|
wtxidrelay_on_peer.send_and_ping(msg_inv([CInv(t=MSG_TX, h=int(random_tx['txid'], 16))]))
|
||||||
|
node.setmocktime(int(time.time()))
|
||||||
|
node.bumpmocktime(MAX_GETDATA_INBOUND_WAIT)
|
||||||
|
wtxidrelay_on_peer.sync_with_ping()
|
||||||
|
assert_equal(wtxidrelay_on_peer.tx_getdata_count, 0)
|
||||||
|
|
||||||
|
# MSG_WTX INV from wtxidrelay=False peer -> mismatch, ignored
|
||||||
|
wtxidrelay_off_peer.send_and_ping(msg_inv([CInv(t=MSG_WTX, h=int(random_tx['wtxid'], 16))]))
|
||||||
|
node.bumpmocktime(MAX_GETDATA_INBOUND_WAIT)
|
||||||
|
wtxidrelay_off_peer.sync_with_ping()
|
||||||
|
assert_equal(wtxidrelay_off_peer.tx_getdata_count, 0)
|
||||||
|
|
||||||
|
# MSG_TX INV from wtxidrelay=False peer works
|
||||||
|
wtxidrelay_off_peer.send_and_ping(msg_inv([CInv(t=MSG_TX, h=int(random_tx['txid'], 16))]))
|
||||||
|
node.bumpmocktime(MAX_GETDATA_INBOUND_WAIT)
|
||||||
|
wtxidrelay_off_peer.wait_for_getdata([int(random_tx['txid'], 16)])
|
||||||
|
|
||||||
|
# MSG_WTX INV from wtxidrelay=True peer works
|
||||||
|
wtxidrelay_on_peer.send_and_ping(msg_inv([CInv(t=MSG_WTX, h=int(random_tx['wtxid'], 16))]))
|
||||||
|
node.bumpmocktime(MAX_GETDATA_INBOUND_WAIT)
|
||||||
|
wtxidrelay_on_peer.wait_for_getdata([int(random_tx['wtxid'], 16)])
|
||||||
|
|
||||||
def run_test(self):
|
def run_test(self):
|
||||||
self.wallet = MiniWallet(self.nodes[0])
|
self.wallet = MiniWallet(self.nodes[0])
|
||||||
|
|
||||||
|
@ -291,6 +321,7 @@ class TxDownloadTest(BitcoinTestFramework):
|
||||||
(self.test_inv_block, True),
|
(self.test_inv_block, True),
|
||||||
(self.test_tx_requests, True),
|
(self.test_tx_requests, True),
|
||||||
(self.test_rejects_filter_reset, False),
|
(self.test_rejects_filter_reset, False),
|
||||||
|
(self.test_inv_wtxidrelay_mismatch, False),
|
||||||
]:
|
]:
|
||||||
self.stop_nodes()
|
self.stop_nodes()
|
||||||
self.start_nodes()
|
self.start_nodes()
|
||||||
|
|
Loading…
Add table
Reference in a new issue