Skip to content

Commit

Permalink
pytest: allow to set stdin for lightningd
Browse files Browse the repository at this point in the history
And also allow to not wait for it to be started
  • Loading branch information
darosior committed Oct 7, 2019
1 parent 8689f2b commit 5dc55aa
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,14 @@ def __init__(self, outputDir=None, verbose=True):
# pass it to the log matcher and not print it to stdout).
self.log_filter = lambda line: False

def start(self):
def start(self, stdin=None, stdout=None):
"""Start the underlying process and start monitoring it.
"""
logging.debug("Starting '%s'", " ".join(self.cmd_line))
self.proc = subprocess.Popen(self.cmd_line, stdout=subprocess.PIPE, env=self.env)
self.proc = subprocess.Popen(self.cmd_line,
stdin=stdin if stdin else subprocess.PIPE,
stdout=stdout if stdout else subprocess.PIPE,
env=self.env)
self.thread = threading.Thread(target=self.tail)
self.thread.daemon = True
self.thread.start()
Expand Down Expand Up @@ -496,10 +499,11 @@ def cmd_line(self):

return self.cmd_prefix + [self.executable] + opts

def start(self):
def start(self, stdin=None, stdout=None, wait_for_initialized=True):
self.opts['bitcoin-rpcport'] = self.rpcproxy.rpcport
TailableProc.start(self)
self.wait_for_log("Server started with public key")
TailableProc.start(self, stdin, stdout)
if wait_for_initialized:
self.wait_for_log("Server started with public key")
logging.info("LightningD started")

def wait(self, timeout=10):
Expand Down

0 comments on commit 5dc55aa

Please sign in to comment.