Remove mapRelay

This commit is contained in:
MarcoFalke
2023-05-11 14:02:14 +02:00
parent fccecd75fe
commit faa2976a56
2 changed files with 32 additions and 36 deletions

View File

@ -4,8 +4,8 @@
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test transaction upload"""
from test_framework.messages import msg_getdata, CInv, MSG_TX
from test_framework.p2p import p2p_lock, P2PDataStore
from test_framework.messages import msg_getdata, CInv, MSG_TX, MSG_WTX
from test_framework.p2p import p2p_lock, P2PDataStore, P2PTxInvStore
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (
assert_equal,
@ -27,6 +27,7 @@ class P2PLeakTxTest(BitcoinTestFramework):
self.miniwallet = MiniWallet(self.gen_node)
self.test_tx_in_block()
self.test_notfound_on_replaced_tx()
self.test_notfound_on_unannounced_tx()
def test_tx_in_block(self):
@ -45,8 +46,36 @@ class P2PLeakTxTest(BitcoinTestFramework):
inbound_peer.send_and_ping(want_tx)
assert_equal(inbound_peer.last_message.get("tx").tx.getwtxid(), wtxid)
def test_notfound_on_replaced_tx(self):
self.gen_node.disconnect_p2ps()
inbound_peer = self.gen_node.add_p2p_connection(P2PTxInvStore())
self.log.info("Transaction tx_a is broadcast")
tx_a = self.miniwallet.send_self_transfer(from_node=self.gen_node)
inbound_peer.wait_for_broadcast(txns=[tx_a["wtxid"]])
tx_b = tx_a["tx"]
tx_b.vout[0].nValue -= 9000
self.gen_node.sendrawtransaction(tx_b.serialize().hex())
self.log.info("Re-request of tx_a after replacement is answered with notfound")
req_vec = [
CInv(t=MSG_TX, h=int(tx_a["txid"], 16)),
CInv(t=MSG_WTX, h=int(tx_a["wtxid"], 16)),
]
want_tx = msg_getdata()
want_tx.inv = req_vec
with p2p_lock:
inbound_peer.last_message.pop("notfound", None)
inbound_peer.last_message.pop("tx", None)
inbound_peer.send_and_ping(want_tx)
assert_equal(inbound_peer.last_message.get("notfound").vec, req_vec)
assert "tx" not in inbound_peer.last_message
def test_notfound_on_unannounced_tx(self):
self.log.info("Check that we don't leak txs to inbound peers that we haven't yet announced to")
self.gen_node.disconnect_p2ps()
inbound_peer = self.gen_node.add_p2p_connection(P2PNode()) # An "attacking" inbound peer
MAX_REPEATS = 100