aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2019-09-16 09:22:49 -0400
committerMarcoFalke <falke.marco@gmail.com>2019-09-17 13:08:17 -0400
commitfaaee1e39a91b3f603881655d3980c29af09852b (patch)
tree902cf7b6a2756ee81681e8a2c6b6084ee6e24b1f /test
parent1111bb91f517838e5b9f778bf6b5a9c8d561e857 (diff)
test: Use connect_nodes when connecting nodes in the test_framework
Diffstat (limited to 'test')
-rwxr-xr-xtest/functional/p2p_disconnect_ban.py8
-rwxr-xr-xtest/functional/p2p_tx_download.py1
-rwxr-xr-xtest/functional/rpc_net.py9
-rwxr-xr-xtest/functional/test_framework/test_framework.py12
-rwxr-xr-xtest/functional/wallet_listsinceblock.py13
5 files changed, 38 insertions, 5 deletions
diff --git a/test/functional/p2p_disconnect_ban.py b/test/functional/p2p_disconnect_ban.py
index 1b11a2a294..f05a3e026c 100755
--- a/test/functional/p2p_disconnect_ban.py
+++ b/test/functional/p2p_disconnect_ban.py
@@ -18,6 +18,10 @@ class DisconnectBanTest(BitcoinTestFramework):
self.num_nodes = 2
def run_test(self):
+ self.log.info("Connect nodes both way")
+ connect_nodes(self.nodes[0], 1)
+ connect_nodes(self.nodes[1], 0)
+
self.log.info("Test setban and listbanned RPCs")
self.log.info("setban: successfully ban single IP address")
@@ -74,7 +78,9 @@ class DisconnectBanTest(BitcoinTestFramework):
# Clear ban lists
self.nodes[1].clearbanned()
- connect_nodes_bi(self.nodes, 0, 1)
+ self.log.info("Connect nodes both way")
+ connect_nodes(self.nodes[0], 1)
+ connect_nodes(self.nodes[1], 0)
self.log.info("Test disconnectnode RPCs")
diff --git a/test/functional/p2p_tx_download.py b/test/functional/p2p_tx_download.py
index 19d78ff303..aada04f66f 100755
--- a/test/functional/p2p_tx_download.py
+++ b/test/functional/p2p_tx_download.py
@@ -121,6 +121,7 @@ class TxDownloadTest(BitcoinTestFramework):
# 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'] == False
timeout = 2 + (MAX_GETDATA_RANDOM_DELAY + INBOUND_PEER_TX_DELAY) + (
GETDATA_TX_INTERVAL + MAX_GETDATA_RANDOM_DELAY)
self.log.info("Tx should be received at node 1 after {} seconds".format(timeout))
diff --git a/test/functional/rpc_net.py b/test/functional/rpc_net.py
index 104c66aaa7..fde9614621 100755
--- a/test/functional/rpc_net.py
+++ b/test/functional/rpc_net.py
@@ -54,6 +54,10 @@ class NetTest(BitcoinTestFramework):
self.extra_args = [["-minrelaytxfee=0.00001000"],["-minrelaytxfee=0.00000500"]]
def run_test(self):
+ self.log.info('Connect nodes both way')
+ connect_nodes(self.nodes[0], 1)
+ connect_nodes(self.nodes[1], 0)
+
self._test_connection_count()
self._test_getnettotals()
self._test_getnetworkinfo()
@@ -105,7 +109,10 @@ class NetTest(BitcoinTestFramework):
wait_until(lambda: self.nodes[0].getnetworkinfo()['connections'] == 0, timeout=3)
self.nodes[0].setnetworkactive(state=True)
- connect_nodes_bi(self.nodes, 0, 1)
+ self.log.info('Connect nodes both way')
+ connect_nodes(self.nodes[0], 1)
+ connect_nodes(self.nodes[1], 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
index 9aff08fdc7..68df238c92 100755
--- a/test/functional/test_framework/test_framework.py
+++ b/test/functional/test_framework/test_framework.py
@@ -281,8 +281,18 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
# 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, i + 1)
+ connect_nodes(self.nodes[i + 1], i)
self.sync_all()
def setup_nodes(self):
diff --git a/test/functional/wallet_listsinceblock.py b/test/functional/wallet_listsinceblock.py
index 021a29d4ac..4aeb393255 100755
--- a/test/functional/wallet_listsinceblock.py
+++ b/test/functional/wallet_listsinceblock.py
@@ -5,9 +5,15 @@
"""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
@@ -16,6 +22,9 @@ class ListSinceBlockTest (BitcoinTestFramework):
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], 2)
self.nodes[2].generate(101)
self.sync_all()