diff options
author | MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> | 2023-05-11 14:02:14 +0200 |
---|---|---|
committer | MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> | 2023-06-08 11:52:30 +0200 |
commit | faa2976a56ea7cdfd77ce2580a89ce493b57b5d4 (patch) | |
tree | 547d79dc07a6f6eb69e51a8c02e7ff2f6bb36615 /test/functional/p2p_leak_tx.py | |
parent | fccecd75fed50a59ec4d54d6dc9bd9a406ea6b30 (diff) | |
download | bitcoin-faa2976a56ea7cdfd77ce2580a89ce493b57b5d4.tar.xz |
Remove mapRelay
Diffstat (limited to 'test/functional/p2p_leak_tx.py')
-rwxr-xr-x | test/functional/p2p_leak_tx.py | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/test/functional/p2p_leak_tx.py b/test/functional/p2p_leak_tx.py index ef327c7ce8..0a331eb96e 100755 --- a/test/functional/p2p_leak_tx.py +++ b/test/functional/p2p_leak_tx.py @@ -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 |