88from typing import Optional
99
1010import pexpect
11- from ln_test import LNTest
1211from test_base import TestBase
1312
1413from warnet .constants import LIGHTNING_MISSION
15- from warnet .k8s import download , get_mission , pod_log , wait_for_pod
14+ from warnet .k8s import download , get_mission , wait_for_pod
1615from warnet .process import run_command
1716
1817
19- class SimLNTest (LNTest , TestBase ):
18+ class SimLNTest (TestBase ):
2019 def __init__ (self ):
2120 super ().__init__ ()
2221 self .network_dir = Path (os .path .dirname (__file__ )) / "data" / "ln"
@@ -27,15 +26,8 @@ def run_test(self):
2726 try :
2827 os .chdir (self .tmpdir )
2928 self .init_directory ()
30-
31- self .import_network ()
32- self .setup_network ()
33- self .test_channel_policies ()
34- self .test_payments ()
35- self .run_simln ()
36-
29+ self .deploy_with_plugin ()
3730 self .copy_results ()
38- self .run_activity ()
3931 finally :
4032 self .cleanup ()
4133
@@ -46,32 +38,20 @@ def init_directory(self):
4638 self .sut .sendline ("n" )
4739 self .sut .close ()
4840
49- def copy_results (self ):
50- self .log .info ("Copying results" )
51- pod = get_mission (f"{ self .simln_exec } mission" )[0 ]
52- self .wait_for_gossip_sync (2 )
53- wait_for_pod (pod .metadata .name , 60 )
54-
55- log_resp = pod_log (pod .metadata .name , f"{ self .simln_exec } primary-container" )
56- self .log .info (log_resp .data .decode ("utf-8" ))
41+ def deploy_with_plugin (self ):
42+ self .log .info ("Deploy the ln network with a SimLN plugin" )
43+ results = self .warnet (f"deploy { self .network_dir } " )
44+ self .log .info (results )
45+ wait_for_pod (self .get_first_simln_pod ())
5746
58- partial_func = partial (self .found_results_remotely , pod .metadata .name )
47+ def copy_results (self ):
48+ pod = self .get_first_simln_pod ()
49+ partial_func = partial (self .found_results_remotely , pod )
5950 self .wait_for_predicate (partial_func )
6051
61- download (pod . metadata . name , Path ("/working/results" ), Path ("." ), pod . metadata . namespace )
52+ download (pod , Path ("/working/results" ), Path ("." ))
6253 self .wait_for_predicate (self .found_results_locally )
6354
64- def run_activity (self ):
65- cmd = f"{ self .simln_exec } get-example-activity"
66- self .log .info (f"Activity: { cmd } " )
67- activity_result = run_command (cmd )
68- activity = json .loads (activity_result )
69- pod_result = run_command (f"{ self .simln_exec } launch-activity '{ json .dumps (activity )} '" )
70- self .log .info (f"launched activity: { pod_result } " )
71- partial_func = partial (self .found_results_remotely , pod_result .strip ())
72- self .wait_for_predicate (partial_func )
73- self .log .info ("Successfully ran activity" )
74-
7555 def wait_for_gossip_sync (self , expected : int ):
7656 self .log .info (f"Waiting for sync (expecting { expected } )..." )
7757 current = 0
@@ -88,9 +68,7 @@ def wait_for_gossip_sync(self, expected: int):
8868
8969 def found_results_remotely (self , pod : Optional [str ] = None ) -> bool :
9070 if pod is None :
91- pod_names_literal = run_command (f"{ self .simln_exec } list-pod-names" )
92- pod_names = ast .literal_eval (pod_names_literal )
93- pod = pod_names [0 ]
71+ pod = self .get_first_simln_pod ()
9472 self .log .info (f"Checking for results file in { pod } " )
9573 results_file = run_command (f"{ self .simln_exec } sh { pod } ls /working/results" ).strip ()
9674 self .log .info (f"Results file: { results_file } " )
@@ -100,6 +78,13 @@ def found_results_remotely(self, pod: Optional[str] = None) -> bool:
10078 self .log .info (results )
10179 return results .find ("Success" ) > 0
10280
81+ def get_first_simln_pod (self ):
82+ command = f"{ self .simln_exec } list-pod-names"
83+ pod_names_literal = run_command (command )
84+ self .log .info (f"{ command } : { pod_names_literal } " )
85+ pod_names = ast .literal_eval (pod_names_literal )
86+ return pod_names [0 ]
87+
10388 def found_results_locally (self ) -> bool :
10489 directory = "results"
10590 self .log .info (f"Searching { directory } " )
0 commit comments