mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-24 18:23:26 -03:00
Merge bitcoin/bitcoin#31658: test: p2p: fix sending of manual INVs in tx download test
Some checks are pending
CI / test each commit (push) Waiting to run
CI / macOS 14 native, arm64, no depends, sqlite only, gui (push) Waiting to run
CI / macOS 14 native, arm64, fuzz (push) Waiting to run
CI / Win64 native, VS 2022 (push) Waiting to run
CI / Win64 native fuzz, VS 2022 (push) Waiting to run
CI / ASan + LSan + UBSan + integer, no depends, USDT (push) Waiting to run
Some checks are pending
CI / test each commit (push) Waiting to run
CI / macOS 14 native, arm64, no depends, sqlite only, gui (push) Waiting to run
CI / macOS 14 native, arm64, fuzz (push) Waiting to run
CI / Win64 native, VS 2022 (push) Waiting to run
CI / Win64 native fuzz, VS 2022 (push) Waiting to run
CI / ASan + LSan + UBSan + integer, no depends, USDT (push) Waiting to run
8996fef8ae
test: p2p: check that INV messages not matching wtxidrelay are ignored (Sebastian Falbesoner)e0b3336822
test: p2p: fix sending of manual INVs in tx download test (Sebastian Falbesoner) Pull request description: The `test_inv_block` sub-test in p2p_tx_download.py has a subtle bug: the manual msg_inv announcements from peers currently have no effect, since they don't match the wtxidrelay setting (=true by default for `P2PInterface` instances) and are hence ignored by the nodes (since2d282e0c
/ PR #18044):e7c4794955/src/net_processing.cpp (L3904-L3911)
Though the test still passes on master, it does so without the intended scenario of asking an additional peer (triggering the GETDATA_TX_INTERVAL delay). Fix this by sending the INV message with MSG_WTX instead of MSG_TX. This increases the test run time by about one minute intentionally. It might be good to avoid issues like this in the future, happy to add test framework improvements if someone has a concrete idea. (Got into the topic of tx/wtx announcements via the discussion https://github.com/bitcoin/bitcoin/pull/31397#discussion_r1904121487) ACKs for top commit: maflcko: ACK8996fef8ae
😸 danielabrozzoni: ACK8996fef8ae
mzumsande: Code Review ACK8996fef8ae
Tree-SHA512: 3da26f9539c89d64c3b0d0579d9af2a6a4577615eed192506e1fb4318421b235f99a6672a497dea3050fba85dad32678f37fd2cda9ecb70cbf52982db37982e8
This commit is contained in:
commit
2d07384243
1 changed files with 33 additions and 2 deletions
|
@ -93,11 +93,11 @@ class TxDownloadTest(BitcoinTestFramework):
|
|||
def test_inv_block(self):
|
||||
self.log.info("Generate a transaction on node 0")
|
||||
tx = self.wallet.create_self_transfer()
|
||||
txid = int(tx['txid'], 16)
|
||||
wtxid = int(tx['wtxid'], 16)
|
||||
|
||||
self.log.info(
|
||||
"Announce the transaction to all nodes from all {} incoming peers, but never send it".format(NUM_INBOUND))
|
||||
msg = msg_inv([CInv(t=MSG_TX, h=txid)])
|
||||
msg = msg_inv([CInv(t=MSG_WTX, h=wtxid)])
|
||||
for p in self.peers:
|
||||
p.send_and_ping(msg)
|
||||
|
||||
|
@ -270,6 +270,36 @@ class TxDownloadTest(BitcoinTestFramework):
|
|||
node.bumpmocktime(MAX_GETDATA_INBOUND_WAIT)
|
||||
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):
|
||||
self.wallet = MiniWallet(self.nodes[0])
|
||||
|
||||
|
@ -291,6 +321,7 @@ class TxDownloadTest(BitcoinTestFramework):
|
|||
(self.test_inv_block, True),
|
||||
(self.test_tx_requests, True),
|
||||
(self.test_rejects_filter_reset, False),
|
||||
(self.test_inv_wtxidrelay_mismatch, False),
|
||||
]:
|
||||
self.stop_nodes()
|
||||
self.start_nodes()
|
||||
|
|
Loading…
Add table
Reference in a new issue