@@ -385,6 +385,45 @@ def f(*args):
385385 return f
386386
387387
388+ class LssD (TailableProc ):
389+ def __init__ (self , directory , rpcport = None ):
390+ lss_dir = os .path .join (directory , 'lss' )
391+ TailableProc .__init__ (self , lss_dir , verbose = False )
392+
393+ if rpcport is None :
394+ self .reserved_rpcport = reserve_unused_port ()
395+ rpcport = self .reserved_rpcport
396+ else :
397+ self .reserved_rpcport = None
398+
399+ self .rpcport = rpcport
400+ self .prefix = 'lss'
401+
402+ if not os .path .exists (lss_dir ):
403+ os .makedirs (lss_dir )
404+
405+ self .cmd_line = [
406+ 'lssd' ,
407+ '--datadir={}' .format (lss_dir ),
408+ '--port={}' .format (rpcport ),
409+ ]
410+
411+ def __del__ (self ):
412+ if self .reserved_rpcport is not None :
413+ drop_unused_port (self .reserved_rpcport )
414+
415+ def start (self ):
416+ self .env ['RUST_LOG' ] = 'debug'
417+ TailableProc .start (self )
418+ self .wait_for_log ("ready on" , timeout = TIMEOUT )
419+
420+ logging .info ("LssD started" )
421+
422+ def stop (self ):
423+ logging .info ("Stopping LssD" )
424+ return TailableProc .stop (self )
425+
426+
388427class BitcoinD (TailableProc ):
389428
390429 def __init__ (self , bitcoin_dir = "/tmp/bitcoind-test" , rpcport = None ):
@@ -626,6 +665,7 @@ def __init__(
626665 self ,
627666 lightning_dir ,
628667 bitcoindproxy ,
668+ lssd_port ,
629669 port = 9735 ,
630670 random_hsm = False ,
631671 node_id = 0 ,
@@ -647,6 +687,7 @@ def __init__(
647687
648688 self .rpcproxy = bitcoindproxy
649689 self .env ['CLN_PLUGIN_LOG' ] = "cln_plugin=trace,cln_rpc=trace,cln_grpc=trace,debug"
690+ self .lssd_port = lssd_port
650691
651692 self .opts = LIGHTNINGD_CONFIG .copy ()
652693 opts = {
@@ -762,6 +803,8 @@ def start(self, stdin=None, wait_for_initialized=True, stderr_redir=False):
762803 # We can't do this in the constructor because we need a new port on each restart.
763804 self .env ['REMOTE_HSMD_ENDPOINT' ] = '127.0.0.1:{}' .format (self .vlsd_port )
764805
806+ self .env ['VLS_LSS' ] = f"http://localhost:{ self .lssd_port } "
807+ self .env ['RUST_LOG' ] = 'debug'
765808 # Some of the remote hsmd proxies need a bitcoind RPC connection
766809 self .env ['BITCOIND_RPC_URL' ] = 'http://{}:{}@localhost:{}' .format (
767810 BITCOIND_CONFIG ['rpcuser' ],
@@ -860,7 +903,7 @@ def call(self, method, payload=None, cmdprefix=None, filter=None):
860903
861904
862905class LightningNode (object ):
863- def __init__ (self , node_id , lightning_dir , bitcoind , executor , valgrind , may_fail = False ,
906+ def __init__ (self , node_id , lightning_dir , bitcoind , lssd , executor , valgrind , may_fail = False ,
864907 may_reconnect = False ,
865908 allow_broken_log = False ,
866909 allow_warning = False ,
@@ -870,6 +913,7 @@ def __init__(self, node_id, lightning_dir, bitcoind, executor, valgrind, may_fai
870913 valgrind_plugins = True ,
871914 ** kwargs ):
872915 self .bitcoin = bitcoind
916+ self .lssd = lssd
873917 self .executor = executor
874918 self .may_fail = may_fail
875919 self .may_reconnect = may_reconnect
@@ -889,6 +933,7 @@ def __init__(self, node_id, lightning_dir, bitcoind, executor, valgrind, may_fai
889933
890934 self .daemon = LightningD (
891935 lightning_dir , bitcoindproxy = bitcoind .get_proxy (),
936+ lssd_port = lssd .rpcport ,
892937 port = port , random_hsm = random_hsm , node_id = node_id ,
893938 grpc_port = self .grpc_port ,
894939 )
@@ -1555,7 +1600,7 @@ def flock(directory: Path):
15551600class NodeFactory (object ):
15561601 """A factory to setup and start `lightningd` daemons.
15571602 """
1558- def __init__ (self , request , testname , bitcoind , executor , directory ,
1603+ def __init__ (self , request , testname , bitcoind , lssd , executor , directory ,
15591604 db_provider , node_cls , jsonschemas ):
15601605 if request .node .get_closest_marker ("slow_test" ) and SLOW_MACHINE :
15611606 self .valgrind = False
@@ -1567,6 +1612,7 @@ def __init__(self, request, testname, bitcoind, executor, directory,
15671612 self .reserved_ports = []
15681613 self .executor = executor
15691614 self .bitcoind = bitcoind
1615+ self .lssd = lssd
15701616 self .directory = directory
15711617 self .lock = threading .Lock ()
15721618 self .db_provider = db_provider
@@ -1652,7 +1698,7 @@ def get_node(self, node_id=None, options=None, dbfile=None,
16521698 db = self .db_provider .get_db (os .path .join (lightning_dir , TEST_NETWORK ), self .testname , node_id )
16531699 db .provider = self .db_provider
16541700 node = self .node_cls (
1655- node_id , lightning_dir , self .bitcoind , self .executor , self .valgrind , db = db ,
1701+ node_id , lightning_dir , self .bitcoind , self .lssd , self . executor , self .valgrind , db = db ,
16561702 port = port , options = options , may_fail = may_fail or expect_fail ,
16571703 jsonschemas = self .jsonschemas ,
16581704 ** kwargs
0 commit comments