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
This commit is contained in:
lisa neigut
2020-03-07 18:06:43 -06:00
committed by Rusty Russell
parent 0cf3e19e0b
commit 34cef2cac3

View File

@@ -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