From 34cef2cac3aade3b5fecb73f5ae40260b12a95a0 Mon Sep 17 00:00:00 2001 From: lisa neigut Date: Sat, 7 Mar 2020 18:06:43 -0600 Subject: [PATCH] pyln-testing: add flag 'expect_fail' to node factory get_node if the node fails to start (and we're expecting it to) return to us the node object anyway we also signal to collect all of its stderr logs by setting stderr on the tailableproc that backs the node --- contrib/pyln-testing/pyln/testing/utils.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/contrib/pyln-testing/pyln/testing/utils.py b/contrib/pyln-testing/pyln/testing/utils.py index 62087ecf3..79351ec55 100644 --- a/contrib/pyln-testing/pyln/testing/utils.py +++ b/contrib/pyln-testing/pyln/testing/utils.py @@ -990,7 +990,7 @@ class NodeFactory(object): def get_node(self, node_id=None, options=None, dbfile=None, feerates=(15000, 7500, 3750), start=True, - wait_for_bitcoind_sync=True, **kwargs): + wait_for_bitcoind_sync=True, expect_fail=False, **kwargs): node_id = self.get_node_id() if not node_id else node_id port = self.get_next_port() @@ -1021,8 +1021,15 @@ class NodeFactory(object): if start: try: - node.start(wait_for_bitcoind_sync) + # Capture stderr if we're failing + if expect_fail: + stderr = subprocess.PIPE + else: + stderr = None + node.start(wait_for_bitcoind_sync, stderr=stderr) except Exception: + if expect_fail: + return node node.daemon.stop() raise return node