Refactor: Provide lightningd in constructor

The fixtures in `tests/fixtures.py` modifies the path to
`lightningd/lightningd`.

I've adapted `pyln-testing` to accept an executable in the constructor.
This approach is more transparant and allows us to use the executable
path to query the version in the constructor.
This commit is contained in:
Erik De Smedt 2025-02-20 14:54:08 +10:30 committed by Alex Myers
parent 8e16cb1a16
commit df5d081ed2
2 changed files with 7 additions and 5 deletions

View file

@ -596,10 +596,11 @@ class LightningD(TailableProc):
port=9735,
random_hsm=False,
node_id=0,
executable=None,
):
# We handle our own version of verbose, below.
TailableProc.__init__(self, lightning_dir, verbose=False)
self.executable = 'lightningd'
self.executable = "lightningd" if executable is None else executable
self.lightning_dir = lightning_dir
self.port = port
self.cmd_prefix = []
@ -759,6 +760,7 @@ class LightningNode(object):
db=None, port=None, grpc_port=None, disconnect=None, random_hsm=None, options=None,
jsonschemas={},
valgrind_plugins=True,
executable=None,
**kwargs):
self.bitcoin = bitcoind
self.executor = executor
@ -781,6 +783,7 @@ class LightningNode(object):
self.daemon = LightningD(
lightning_dir, bitcoindproxy=bitcoind.get_proxy(),
port=port, random_hsm=random_hsm, node_id=node_id,
executable=executable,
)
self.disconnect = disconnect

View file

@ -16,6 +16,9 @@ def node_cls():
class LightningNode(utils.LightningNode):
def __init__(self, *args, **kwargs):
# Yes, we really want to test the local development version, not
# something in out path.
kwargs["executable"] = "lightningd/lightningd"
utils.LightningNode.__init__(self, *args, **kwargs)
# This is a recent innovation, and we don't want to nail pyln-testing to this version.
@ -50,10 +53,6 @@ class LightningNode(utils.LightningNode):
accts_db = self.db.provider.get_db('', 'accounts', 0)
self.daemon.opts['bookkeeper-db'] = accts_db.get_dsn()
# Yes, we really want to test the local development version, not
# something in out path.
self.daemon.executable = 'lightningd/lightningd'
class CompatLevel(object):
"""An object that encapsulates the compat-level of our build.