test: Use connect_nodes when connecting nodes in the test_framework
This commit is contained in:
parent
1111bb91f5
commit
faaee1e39a
5 changed files with 38 additions and 5 deletions
|
@ -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")
|
||||
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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()
|
||||
|
||||
|
|
Loading…
Reference in a new issue