diff --git a/test/functional/p2p_disconnect_ban.py b/test/functional/p2p_disconnect_ban.py --- a/test/functional/p2p_disconnect_ban.py +++ b/test/functional/p2p_disconnect_ban.py @@ -9,6 +9,7 @@ from test_framework.util import ( assert_equal, assert_raises_rpc_error, + connect_nodes, connect_nodes_bi, wait_until, ) @@ -19,6 +20,10 @@ self.num_nodes = 2 def run_test(self): + self.log.info("Connect nodes both way") + connect_nodes(self.nodes[0], self.nodes[1]) + connect_nodes(self.nodes[1], self.nodes[0]) + self.log.info("Test setban and listbanned RPCs") self.log.info("setban: successfully ban single IP address") @@ -85,7 +90,9 @@ # Clear ban lists self.nodes[1].clearbanned() - connect_nodes_bi(self.nodes[0], self.nodes[1]) + self.log.info("Connect nodes both way") + connect_nodes(self.nodes[0], self.nodes[1]) + connect_nodes(self.nodes[1], self.nodes[0]) self.log.info("Test disconnectnode RPCs") diff --git a/test/functional/p2p_tx_download.py b/test/functional/p2p_tx_download.py --- a/test/functional/p2p_tx_download.py +++ b/test/functional/p2p_tx_download.py @@ -126,6 +126,7 @@ # peer, plus # * the first time it is re-requested from the outbound peer, plus # * 2 seconds to avoid races + assert self.nodes[1].getpeerinfo()[0]['inbound'] is False timeout = 2 + (MAX_GETDATA_RANDOM_DELAY + INBOUND_PEER_TX_DELAY) + ( GETDATA_TX_INTERVAL + MAX_GETDATA_RANDOM_DELAY) self.log.info( diff --git a/test/functional/rpc_net.py b/test/functional/rpc_net.py --- a/test/functional/rpc_net.py +++ b/test/functional/rpc_net.py @@ -15,7 +15,7 @@ assert_greater_than_or_equal, assert_greater_than, assert_raises_rpc_error, - connect_nodes_bi, + connect_nodes, p2p_port, wait_until, ) @@ -31,6 +31,10 @@ ["-minrelaytxfee=0.00000500"]] def run_test(self): + self.log.info('Connect nodes both way') + connect_nodes(self.nodes[0], self.nodes[1]) + connect_nodes(self.nodes[1], self.nodes[0]) + self._test_connection_count() self._test_getnettotals() self._test_getnetworkinginfo() @@ -95,7 +99,10 @@ 'connections'] == 0, timeout=3) self.nodes[0].setnetworkactive(state=True) - connect_nodes_bi(self.nodes[0], self.nodes[1]) + self.log.info('Connect nodes both way') + connect_nodes(self.nodes[0], self.nodes[1]) + connect_nodes(self.nodes[1], self.nodes[0]) + assert_equal(self.nodes[0].getnetworkinfo()['networkactive'], True) assert_equal(self.nodes[0].getnetworkinfo()['connections'], 2) diff --git a/test/functional/test_framework/test_framework.py b/test/functional/test_framework/test_framework.py --- a/test/functional/test_framework/test_framework.py +++ b/test/functional/test_framework/test_framework.py @@ -22,6 +22,7 @@ from .util import ( assert_equal, check_json_precision, + connect_nodes, connect_nodes_bi, disconnect_nodes, get_datadir_path, @@ -265,8 +266,18 @@ # Connect the nodes as a "chain". This allows us # to split the network between nodes 1 and 2 to get # two halves that can work on competing chains. + # + # Topology looks like this: + # node0 <-- node1 <-- node2 <-- node3 + # + # If all nodes are in IBD (clean chain from genesis), node0 is assumed to be the source of blocks (miner). To + # ensure block propagation, all nodes will establish outgoing connections toward node0. + # See fPreferredDownload in net_processing. + # + # If further outbound connections are needed, they can be added at the beginning of the test with e.g. + # connect_nodes(self.nodes[1], 2) for i in range(self.num_nodes - 1): - connect_nodes_bi(self.nodes[i], self.nodes[i + 1]) + connect_nodes(self.nodes[i + 1], self.nodes[i]) self.sync_all() def setup_nodes(self): diff --git a/test/functional/wallet_listsinceblock.py b/test/functional/wallet_listsinceblock.py --- a/test/functional/wallet_listsinceblock.py +++ b/test/functional/wallet_listsinceblock.py @@ -4,10 +4,15 @@ # file COPYING or http://www.opensource.org/licenses/mit-license.php. """Test the listsincelast RPC.""" from test_framework.test_framework import BitcoinTestFramework -from test_framework.util import assert_equal, assert_array_result, assert_raises_rpc_error +from test_framework.util import ( + assert_array_result, + assert_equal, + assert_raises_rpc_error, + connect_nodes, +) -class ListSinceBlockTest (BitcoinTestFramework): +class ListSinceBlockTest(BitcoinTestFramework): def set_test_params(self): self.num_nodes = 4 self.setup_clean_chain = True @@ -17,6 +22,9 @@ self.skip_if_no_wallet() def run_test(self): + # All nodes are in IBD from genesis, so they'll need the miner (node2) to be an outbound connection, or have + # only one connection. (See fPreferredDownload in net_processing) + connect_nodes(self.nodes[1], self.nodes[2]) self.nodes[2].generate(101) self.sync_all()