@@ -384,6 +384,45 @@ def f(*args):
384384 return f
385385
386386
387+ class LssD (TailableProc ):
388+ def __init__ (self , directory , rpcport = None ):
389+ lss_dir = os .path .join (directory , 'lss' )
390+ TailableProc .__init__ (self , lss_dir , verbose = False )
391+
392+ if rpcport is None :
393+ self .reserved_rpcport = reserve_unused_port ()
394+ rpcport = self .reserved_rpcport
395+ else :
396+ self .reserved_rpcport = None
397+
398+ self .rpcport = rpcport
399+ self .prefix = 'lss'
400+
401+ if not os .path .exists (lss_dir ):
402+ os .makedirs (lss_dir )
403+
404+ self .cmd_line = [
405+ 'lssd' ,
406+ '--datadir={}' .format (lss_dir ),
407+ '--port={}' .format (rpcport ),
408+ ]
409+
410+ def __del__ (self ):
411+ if self .reserved_rpcport is not None :
412+ drop_unused_port (self .reserved_rpcport )
413+
414+ def start (self ):
415+ self .env ['RUST_LOG' ] = 'debug'
416+ TailableProc .start (self )
417+ self .wait_for_log ("ready on" , timeout = TIMEOUT )
418+
419+ logging .info ("LssD started" )
420+
421+ def stop (self ):
422+ logging .info ("Stopping LssD" )
423+ return TailableProc .stop (self )
424+
425+
387426class BitcoinD (TailableProc ):
388427
389428 def __init__ (self , bitcoin_dir = "/tmp/bitcoind-test" , rpcport = None ):
@@ -625,6 +664,7 @@ def __init__(
625664 self ,
626665 lightning_dir ,
627666 bitcoindproxy ,
667+ lssd_port ,
628668 port = 9735 ,
629669 random_hsm = False ,
630670 node_id = 0 ,
@@ -645,6 +685,7 @@ def __init__(
645685
646686 self .rpcproxy = bitcoindproxy
647687 self .env ['CLN_PLUGIN_LOG' ] = "cln_plugin=trace,cln_rpc=trace,cln_grpc=trace,debug"
688+ self .lssd_port = lssd_port
648689
649690 self .opts = LIGHTNINGD_CONFIG .copy ()
650691 opts = {
@@ -759,6 +800,8 @@ def start(self, stdin=None, wait_for_initialized=True, stderr_redir=False):
759800 # We can't do this in the constructor because we need a new port on each restart.
760801 self .env ['REMOTE_HSMD_ENDPOINT' ] = '127.0.0.1:{}' .format (self .vlsd_port )
761802
803+ self .env ['VLS_LSS' ] = f"http://localhost:{ self .lssd_port } "
804+ self .env ['RUST_LOG' ] = 'debug'
762805 # Some of the remote hsmd proxies need a bitcoind RPC connection
763806 self .env ['BITCOIND_RPC_URL' ] = 'http://{}:{}@localhost:{}' .format (
764807 BITCOIND_CONFIG ['rpcuser' ],
@@ -873,7 +916,7 @@ def call(self, method, payload=None, cmdprefix=None, filter=None):
873916
874917
875918class LightningNode (object ):
876- def __init__ (self , node_id , lightning_dir , bitcoind , executor , valgrind , may_fail = False ,
919+ def __init__ (self , node_id , lightning_dir , bitcoind , lssd , executor , valgrind , may_fail = False ,
877920 may_reconnect = False ,
878921 allow_broken_log = False ,
879922 allow_warning = False ,
@@ -883,6 +926,7 @@ def __init__(self, node_id, lightning_dir, bitcoind, executor, valgrind, may_fai
883926 valgrind_plugins = True ,
884927 ** kwargs ):
885928 self .bitcoin = bitcoind
929+ self .lssd = lssd
886930 self .executor = executor
887931 self .may_fail = may_fail
888932 self .may_reconnect = may_reconnect
@@ -902,6 +946,7 @@ def __init__(self, node_id, lightning_dir, bitcoind, executor, valgrind, may_fai
902946
903947 self .daemon = LightningD (
904948 lightning_dir , bitcoindproxy = bitcoind .get_proxy (),
949+ lssd_port = lssd .rpcport ,
905950 port = port , random_hsm = random_hsm , node_id = node_id ,
906951 grpc_port = self .grpc_port ,
907952 )
@@ -1606,7 +1651,7 @@ def flock(directory: Path):
16061651class NodeFactory (object ):
16071652 """A factory to setup and start `lightningd` daemons.
16081653 """
1609- def __init__ (self , request , testname , bitcoind , executor , directory ,
1654+ def __init__ (self , request , testname , bitcoind , lssd , executor , directory ,
16101655 db_provider , node_cls , jsonschemas ):
16111656 if request .node .get_closest_marker ("slow_test" ) and SLOW_MACHINE :
16121657 self .valgrind = False
@@ -1618,6 +1663,7 @@ def __init__(self, request, testname, bitcoind, executor, directory,
16181663 self .reserved_ports = []
16191664 self .executor = executor
16201665 self .bitcoind = bitcoind
1666+ self .lssd = lssd
16211667 self .directory = directory
16221668 self .lock = threading .Lock ()
16231669 self .db_provider = db_provider
@@ -1703,7 +1749,7 @@ def get_node(self, node_id=None, options=None, dbfile=None,
17031749 db = self .db_provider .get_db (os .path .join (lightning_dir , TEST_NETWORK ), self .testname , node_id )
17041750 db .provider = self .db_provider
17051751 node = self .node_cls (
1706- node_id , lightning_dir , self .bitcoind , self .executor , self .valgrind , db = db ,
1752+ node_id , lightning_dir , self .bitcoind , self .lssd , self . executor , self .valgrind , db = db ,
17071753 port = port , options = options , may_fail = may_fail or expect_fail ,
17081754 jsonschemas = self .jsonschemas ,
17091755 ** kwargs
0 commit comments