Skip to content

Commit

Permalink
pytest: Give lightningd nodes a numeric ID to prefix logs
Browse files Browse the repository at this point in the history
This used to be the port, but since we no longer have fixed ports, and we start
them in random order we can't easily distinguish them by the port anymore. Just
use a numeric ID that matches their lightning-dirs.

Signed-off-by: Christian Decker <[email protected]>
  • Loading branch information
cdecker authored and rustyrussell committed May 7, 2018
1 parent 65cac1b commit 6231e99
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 4 additions & 1 deletion tests/test_lightningd.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,10 @@ def get_node(self, disconnect=None, options=None, may_fail=False, may_reconnect=
shutil.rmtree(lightning_dir)

socket_path = os.path.join(lightning_dir, "lightning-rpc").format(node_id)
daemon = utils.LightningD(lightning_dir, self.bitcoind.bitcoin_dir, port=port, random_hsm=random_hsm)
daemon = utils.LightningD(
lightning_dir, self.bitcoind.bitcoin_dir,
port=port, random_hsm=random_hsm, node_id=node_id
)
# If we have a disconnect string, dump it to a file for daemon.
if disconnect:
with open(os.path.join(lightning_dir, "dev_disconnect"), "w") as f:
Expand Down
4 changes: 2 additions & 2 deletions tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ def generate_block(self, numblocks=1):


class LightningD(TailableProc):
def __init__(self, lightning_dir, bitcoin_dir, port=9735, random_hsm=False):
def __init__(self, lightning_dir, bitcoin_dir, port=9735, random_hsm=False, node_id=0):
TailableProc.__init__(self, lightning_dir)
self.lightning_dir = lightning_dir
self.port = port
Expand Down Expand Up @@ -281,7 +281,7 @@ def __init__(self, lightning_dir, bitcoin_dir, port=9735, random_hsm=False):
f.write(seed)
if DEVELOPER:
self.opts['dev-broadcast-interval'] = 1000
self.prefix = 'lightningd(%d)' % (port)
self.prefix = 'lightningd-%d' % (node_id)

@property
def cmd_line(self):
Expand Down

0 comments on commit 6231e99

Please sign in to comment.