@@ -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 ):
@@ -621,6 +660,7 @@ def __init__(
621660 self ,
622661 lightning_dir ,
623662 bitcoindproxy ,
663+ lssd_port ,
624664 port = 9735 ,
625665 random_hsm = False ,
626666 node_id = 0 ,
@@ -641,6 +681,7 @@ def __init__(
641681
642682 self .rpcproxy = bitcoindproxy
643683 self .env ['CLN_PLUGIN_LOG' ] = "cln_plugin=trace,cln_rpc=trace,cln_grpc=trace,debug"
684+ self .lssd_port = lssd_port
644685
645686 self .opts = LIGHTNINGD_CONFIG .copy ()
646687 opts = {
@@ -872,7 +913,7 @@ def call(self, method, payload=None, cmdprefix=None, filter=None):
872913
873914
874915class LightningNode (object ):
875- def __init__ (self , node_id , lightning_dir , bitcoind , executor , valgrind , may_fail = False ,
916+ def __init__ (self , node_id , lightning_dir , bitcoind , lssd , executor , valgrind , may_fail = False ,
876917 may_reconnect = False ,
877918 allow_broken_log = False ,
878919 allow_warning = False ,
@@ -882,6 +923,7 @@ def __init__(self, node_id, lightning_dir, bitcoind, executor, valgrind, may_fai
882923 valgrind_plugins = True ,
883924 ** kwargs ):
884925 self .bitcoin = bitcoind
926+ self .lssd = lssd
885927 self .executor = executor
886928 self .may_fail = may_fail
887929 self .may_reconnect = may_reconnect
@@ -901,6 +943,7 @@ def __init__(self, node_id, lightning_dir, bitcoind, executor, valgrind, may_fai
901943
902944 self .daemon = LightningD (
903945 lightning_dir , bitcoindproxy = bitcoind .get_proxy (),
946+ lssd_port = lssd .rpcport ,
904947 port = port , random_hsm = random_hsm , node_id = node_id ,
905948 grpc_port = self .grpc_port ,
906949 )
@@ -1605,7 +1648,7 @@ def flock(directory: Path):
16051648class NodeFactory (object ):
16061649 """A factory to setup and start `lightningd` daemons.
16071650 """
1608- def __init__ (self , request , testname , bitcoind , executor , directory ,
1651+ def __init__ (self , request , testname , bitcoind , lssd , executor , directory ,
16091652 db_provider , node_cls , jsonschemas ):
16101653 if request .node .get_closest_marker ("slow_test" ) and SLOW_MACHINE :
16111654 self .valgrind = False
@@ -1617,6 +1660,7 @@ def __init__(self, request, testname, bitcoind, executor, directory,
16171660 self .reserved_ports = []
16181661 self .executor = executor
16191662 self .bitcoind = bitcoind
1663+ self .lssd = lssd
16201664 self .directory = directory
16211665 self .lock = threading .Lock ()
16221666 self .db_provider = db_provider
@@ -1702,7 +1746,7 @@ def get_node(self, node_id=None, options=None, dbfile=None,
17021746 db = self .db_provider .get_db (os .path .join (lightning_dir , TEST_NETWORK ), self .testname , node_id )
17031747 db .provider = self .db_provider
17041748 node = self .node_cls (
1705- node_id , lightning_dir , self .bitcoind , self .executor , self .valgrind , db = db ,
1749+ node_id , lightning_dir , self .bitcoind , self .lssd , self . executor , self .valgrind , db = db ,
17061750 port = port , options = options , may_fail = may_fail or expect_fail ,
17071751 jsonschemas = self .jsonschemas ,
17081752 ** kwargs
0 commit comments