Skip to content

Commit 819b87a

Browse files
committed
test: Add possibility to skip awaiting for the connection
1 parent 5374229 commit 819b87a

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

test/functional/p2p_time_offset.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ def setup_network(self):
2222
# don't connect nodes yet
2323
self.setup_nodes()
2424

25-
def connect_nodes_bi(self, a, b):
26-
self.connect_nodes(a, b)
27-
self.connect_nodes(b, a)
25+
def connect_nodes_bi(self, a, b, wait_for_connect = True):
26+
self.connect_nodes(a, b, wait_for_connect)
27+
self.connect_nodes(b, a, wait_for_connect)
2828

2929
def check_connected_nodes(self):
3030
ni = [node.getnetworkinfo() for node in self.connected_nodes]
@@ -96,7 +96,8 @@ def run_test(self):
9696

9797
# try to connect node 5 and check that it can't
9898
self.log.info("Trying to connect with node-5 (+30 s)...")
99-
self.connect_nodes_bi(0, 5)
99+
# Don't wait for a connection that will never be established.
100+
self.connect_nodes_bi(0, 5, False)
100101
ni = self.nodes[0].getnetworkinfo()
101102
assert_equal(ni['connections'], 10)
102103
assert_equal(ni['timeoffset'], 15)

test/functional/test_framework/test_framework.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ def restart_node(self, i, extra_args=None):
340340
def wait_for_node_exit(self, i, timeout):
341341
self.nodes[i].process.wait(timeout)
342342

343-
def connect_nodes(self, a, b):
343+
def connect_nodes(self, a, b, wait_for_connect = True):
344344
from_connection = self.nodes[a]
345345
to_connection = self.nodes[b]
346346
ip_port = "127.0.0.1:" + str(p2p_port(b))
@@ -350,6 +350,9 @@ def connect_nodes(self, a, b):
350350
from_connection_subver = from_connection.getnetworkinfo()['subversion']
351351
to_connection_subver = to_connection.getnetworkinfo()['subversion']
352352

353+
if not wait_for_connect:
354+
return
355+
353356
def find_conn(node, peer_subversion, inbound):
354357
return next(filter(lambda peer: peer['subver'] == peer_subversion and peer['inbound'] == inbound, node.getpeerinfo()), None)
355358

0 commit comments

Comments
 (0)