Skip to content

Commit b7dd44c

Browse files
committed
Add start and stop node methods to BitcoinTestFramework
1 parent b111324 commit b7dd44c

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

test/functional/test_framework/test_framework.py

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
p2p_port,
3232
rpc_url,
3333
set_node_times,
34+
start_node,
3435
start_nodes,
3536
stop_node,
3637
stop_nodes,
@@ -64,9 +65,18 @@ def setup_chain(self):
6465
else:
6566
self._initialize_chain(self.options.tmpdir, self.num_nodes, self.options.cachedir)
6667

68+
def start_node(self, i, dirname, extra_args=None, rpchost=None, timewait=None, binary=None, stderr=None):
69+
return start_node(i, dirname, extra_args, rpchost, timewait, binary, stderr)
70+
71+
def start_nodes(self, num_nodes, dirname, extra_args=None, rpchost=None, timewait=None, binary=None):
72+
return start_nodes(num_nodes, dirname, extra_args, rpchost, timewait, binary)
73+
6774
def stop_node(self, num_node):
6875
stop_node(self.nodes[num_node], num_node)
6976

77+
def stop_nodes(self):
78+
stop_nodes(self.nodes)
79+
7080
def setup_nodes(self):
7181
extra_args = None
7282
if hasattr(self, "extra_args"):
@@ -165,7 +175,7 @@ def main(self):
165175

166176
if not self.options.noshutdown:
167177
self.log.info("Stopping nodes")
168-
stop_nodes(self.nodes)
178+
self.stop_nodes()
169179
else:
170180
self.log.info("Note: bitcoinds were not stopped and may still be running")
171181

@@ -259,10 +269,10 @@ def _initialize_chain(self, test_dir, num_nodes, cachedir):
259269
wait_for_bitcoind_start(bitcoind_processes[i], rpc_url(i), i)
260270
self.log.debug("initialize_chain: RPC successfully started")
261271

262-
rpcs = []
272+
self.nodes = []
263273
for i in range(MAX_NODES):
264274
try:
265-
rpcs.append(get_rpc_proxy(rpc_url(i), i))
275+
self.nodes.append(get_rpc_proxy(rpc_url(i), i))
266276
except:
267277
self.log.exception("Error connecting to node %d" % i)
268278
sys.exit(1)
@@ -279,14 +289,15 @@ def _initialize_chain(self, test_dir, num_nodes, cachedir):
279289
for i in range(2):
280290
for peer in range(4):
281291
for j in range(25):
282-
set_node_times(rpcs, block_time)
283-
rpcs[peer].generate(1)
292+
set_node_times(self.nodes, block_time)
293+
self.nodes[peer].generate(1)
284294
block_time += 10 * 60
285295
# Must sync before next peer starts generating blocks
286-
sync_blocks(rpcs)
296+
sync_blocks(self.nodes)
287297

288298
# Shut them down, and clean up cache directories:
289-
stop_nodes(rpcs)
299+
self.stop_nodes()
300+
self.nodes = []
290301
disable_mocktime()
291302
for i in range(MAX_NODES):
292303
os.remove(log_filename(cachedir, i, "debug.log"))
@@ -330,7 +341,7 @@ def add_options(self, parser):
330341
help="bitcoind binary to use for reference nodes (if any)")
331342

332343
def setup_network(self):
333-
self.nodes = start_nodes(
344+
self.nodes = self.start_nodes(
334345
self.num_nodes, self.options.tmpdir,
335346
extra_args=[['-whitelist=127.0.0.1']] * self.num_nodes,
336347
binary=[self.options.testbinary] +

0 commit comments

Comments
 (0)