Skip to content

Commit

Permalink
pyln: Decode process output once before storing it
Browse files Browse the repository at this point in the history
  • Loading branch information
cdecker authored and rustyrussell committed Oct 6, 2020
1 parent 81569de commit 9021bb2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
14 changes: 11 additions & 3 deletions contrib/pyln-testing/pyln/testing/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import string
import struct
import subprocess
import sys
import threading
import time
import warnings
Expand Down Expand Up @@ -202,15 +203,22 @@ def tail(self):
for line in iter(self.proc.stdout.readline, ''):
if len(line) == 0:
break
if self.log_filter(line.decode('ASCII')):

line = line.decode('ASCII').rstrip()

if self.log_filter(line):
continue

if self.verbose:
logging.debug("%s: %s", self.prefix, line.decode().rstrip())
sys.stdout.write("{}: {}\n".format(self.prefix, line))

with self.logs_cond:
self.logs.append(str(line.rstrip()))
self.logs.append(line)
self.logs_cond.notifyAll()

self.running = False
self.proc.stdout.close()

if self.proc.stderr:
for line in iter(self.proc.stderr.readline, ''):
if len(line) == 0:
Expand Down
4 changes: 2 additions & 2 deletions tests/test_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -2125,7 +2125,7 @@ def test_dataloss_protection(node_factory, bitcoind):
# be zero)
"[0-9a-f]{64}"
# my_current_per_commitment_point
"0[23][0-9a-f]{64}'$")
"0[23][0-9a-f]{64}")

# After an htlc, we should get different results (two more commits)
l1.pay(l2, 200000000)
Expand All @@ -2148,7 +2148,7 @@ def test_dataloss_protection(node_factory, bitcoind):
# your_last_per_commitment_secret
"[0-9a-f]{64}"
# my_current_per_commitment_point
"0[23][0-9a-f]{64}'$")
"0[23][0-9a-f]{64}")

# Now, move l2 back in time.
l2.stop()
Expand Down
2 changes: 1 addition & 1 deletion tests/test_gossip.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ def test_gossip_weirdalias(node_factory, bitcoind):
{'alias': normal_name}
]
l1, l2 = node_factory.get_nodes(2, opts=opts)
weird_name_json = json.encoder.JSONEncoder().encode(weird_name)[1:-1].replace('\\', '\\\\')
weird_name_json = json.encoder.JSONEncoder().encode(weird_name)[1:-1]
aliasline = l1.daemon.is_in_log('Server started with public key .* alias')
assert weird_name_json in str(aliasline)
assert l2.daemon.is_in_log('Server started with public key .* alias {}'
Expand Down

0 comments on commit 9021bb2

Please sign in to comment.