test_lightningd.py: fix wait_for_logs with duplicate entries.

In the next test, we wait for multiple 'sendrawtx exit 0' which
doesn't work because we use a set not a list, and the current code
would match multiple against the same thing.  The result was we didn't
wait for the final sendrawtransaction, and occasionally had test
failures as a result.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2017-09-26 14:27:31 +09:30
parent 0e569209ec
commit d640dc3a6f

View File

@@ -107,7 +107,7 @@ class TailableProc(object):
"""
logging.debug("Waiting for {} in the logs".format(regexs))
exs = {re.compile(r) for r in regexs}
exs = [re.compile(r) for r in regexs]
start_time = time.time()
pos = self.logsearch_start
initial_pos = len(self.logs)
@@ -130,10 +130,11 @@ class TailableProc(object):
continue
for r in exs.copy():
self.logsearch_start = pos+1
if r.search(self.logs[pos]):
logging.debug("Found '%s' in logs", r)
exs.remove(r)
self.logsearch_start = pos+1
break
if len(exs) == 0:
return self.logs[pos]
pos += 1