@@ -353,21 +353,13 @@ def stop_node(self, expected_stderr='', *, wait=0, wait_until_stopped=True):
353
353
for profile_name in tuple (self .perf_subprocesses .keys ()):
354
354
self ._stop_perf (profile_name )
355
355
356
- # Check that stderr is as expected
357
- self .stderr .seek (0 )
358
- stderr = self .stderr .read ().decode ('utf-8' ).strip ()
359
- if stderr != expected_stderr :
360
- raise AssertionError ("Unexpected stderr {} != {}" .format (stderr , expected_stderr ))
361
-
362
- self .stdout .close ()
363
- self .stderr .close ()
364
-
365
356
del self .p2ps [:]
366
357
358
+ assert (not expected_stderr ) or wait_until_stopped # Must wait to check stderr
367
359
if wait_until_stopped :
368
- self .wait_until_stopped ()
360
+ self .wait_until_stopped (expected_stderr = expected_stderr )
369
361
370
- def is_node_stopped (self , expected_ret_code = 0 ):
362
+ def is_node_stopped (self , * , expected_stderr = "" , expected_ret_code = 0 ):
371
363
"""Checks whether the node has stopped.
372
364
373
365
Returns True if the node has stopped. False otherwise.
@@ -381,16 +373,25 @@ def is_node_stopped(self, expected_ret_code=0):
381
373
# process has stopped. Assert that it didn't return an error code.
382
374
assert return_code == expected_ret_code , self ._node_msg (
383
375
f"Node returned unexpected exit code ({ return_code } ) vs ({ expected_ret_code } ) when stopping" )
376
+ # Check that stderr is as expected
377
+ self .stderr .seek (0 )
378
+ stderr = self .stderr .read ().decode ('utf-8' ).strip ()
379
+ if stderr != expected_stderr :
380
+ raise AssertionError ("Unexpected stderr {} != {}" .format (stderr , expected_stderr ))
381
+
382
+ self .stdout .close ()
383
+ self .stderr .close ()
384
+
384
385
self .running = False
385
386
self .process = None
386
387
self .rpc_connected = False
387
388
self .rpc = None
388
389
self .log .debug ("Node stopped" )
389
390
return True
390
391
391
- def wait_until_stopped (self , timeout = BITCOIND_PROC_WAIT_TIMEOUT , expect_error = False ):
392
+ def wait_until_stopped (self , * , timeout = BITCOIND_PROC_WAIT_TIMEOUT , expect_error = False , ** kwargs ):
392
393
expected_ret_code = 1 if expect_error else 0 # Whether node shutdown return EXIT_FAILURE or EXIT_SUCCESS
393
- wait_until_helper (lambda : self .is_node_stopped (expected_ret_code = expected_ret_code ), timeout = timeout , timeout_factor = self .timeout_factor )
394
+ wait_until_helper (lambda : self .is_node_stopped (expected_ret_code = expected_ret_code , ** kwargs ), timeout = timeout , timeout_factor = self .timeout_factor )
394
395
395
396
def replace_in_config (self , replacements ):
396
397
"""
0 commit comments