From 6231e9969fe40dc68b058a9df5d45117365972af Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Sat, 5 May 2018 17:15:53 +0200 Subject: [PATCH] pytest: Give lightningd nodes a numeric ID to prefix logs 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 --- tests/test_lightningd.py | 5 ++++- tests/utils.py | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/test_lightningd.py b/tests/test_lightningd.py index 26eb8797d..0444fb894 100644 --- a/tests/test_lightningd.py +++ b/tests/test_lightningd.py @@ -163,7 +163,10 @@ class NodeFactory(object): 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: diff --git a/tests/utils.py b/tests/utils.py index bc2ba4915..25e5c88c9 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -251,7 +251,7 @@ class BitcoinD(TailableProc): 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 @@ -281,7 +281,7 @@ class LightningD(TailableProc): 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):