|
| 1 | +#!/usr/bin/env python3 |
| 2 | +# Copyright (c) 2022 The Bitcoin Core developers |
| 3 | +# Distributed under the MIT software license, see the accompanying |
| 4 | +# file COPYING or http://www.opensource.org/licenses/mit-license.php. |
| 5 | +""" |
| 6 | +See traffic patterns in v2 traffic |
| 7 | +
|
| 8 | +node0 <--- node1 <--- node2 |
| 9 | +
|
| 10 | +Can we see tx created by node3 propagating from node3 to node0? |
| 11 | +""" |
| 12 | +from test_framework.blocktools import ( |
| 13 | + COINBASE_MATURITY, |
| 14 | +) |
| 15 | +from test_framework.p2p import ( |
| 16 | + P2PInterface, |
| 17 | +) |
| 18 | +from test_framework.test_framework import BitcoinTestFramework |
| 19 | +from test_framework.util import ( |
| 20 | + assert_equal, |
| 21 | +) |
| 22 | + |
| 23 | +class P2PTraffic(BitcoinTestFramework): |
| 24 | + def set_test_params(self): |
| 25 | + self.num_nodes = 3 |
| 26 | + self.extra_args = [["-v2transport=1"], ["-v2transport=1"], ["-v2transport=1"]] |
| 27 | + |
| 28 | + def add_options(self, parser): |
| 29 | + self.add_wallet_options(parser) |
| 30 | + |
| 31 | + def run_test(self): |
| 32 | + node0, node1, node2 = self.nodes[0], self.nodes[1], self.nodes[2] |
| 33 | + peer = node0.add_p2p_connection(P2PInterface(), wait_for_verack=True, supports_v2_p2p=True) |
| 34 | + assert peer.supports_v2_p2p |
| 35 | + # 1. node2 creates a transaction |
| 36 | + node2.createwallet(wallet_name='test') |
| 37 | + test_wallet = node2.get_wallet_rpc('test') |
| 38 | + |
| 39 | + self.generatetoaddress(node2, COINBASE_MATURITY + 1, test_wallet.getnewaddress()) |
| 40 | + |
| 41 | + address1 = test_wallet.getnewaddress() |
| 42 | + txid = node2.sendtoaddress(address=address1, amount=1) |
| 43 | + |
| 44 | + # 2. wait for node0's peer to receive transaction |
| 45 | + peer.wait_for_tx(txid) |
| 46 | + |
| 47 | + # 1. node2 creates a transaction |
| 48 | + |
| 49 | + # self.generatetoaddress(node2, COINBASE_MATURITY + 1, test_wallet.getnewaddress()) |
| 50 | + address2 = test_wallet.getnewaddress() |
| 51 | + txid = node2.sendtoaddress(address=address2, amount=1) |
| 52 | + |
| 53 | + # 2. wait for node0's peer to receive transaction |
| 54 | + peer.wait_for_tx(txid) |
| 55 | + |
| 56 | + # can you see fixed size transaction msg moving? |
| 57 | + # what are other msg types + sizes you see? |
| 58 | + assert False |
| 59 | + |
| 60 | + |
| 61 | + |
| 62 | +if __name__ == '__main__': |
| 63 | + P2PTraffic().main() |
0 commit comments