22import json
33import os
44from pathlib import Path
5- from subprocess import run
65from time import sleep
76
87import pexpect
1312
1413lightning_selector = "mission=lightning"
1514
15+ UP = "\033 [A"
16+ DOWN = "\033 [B"
17+ ENTER = "\n "
1618
17- class LNTest (TestBase ):
19+
20+ class SimLNTest (TestBase ):
1821 def __init__ (self ):
1922 super ().__init__ ()
2023 self .network_dir = Path (os .path .dirname (__file__ )) / "data" / "ln"
@@ -40,7 +43,36 @@ def run_plugin(self):
4043 self .sut .sendline ("n" )
4144 self .sut .close ()
4245
43- self .log .info (run (["warnet" , "plugin" , "run" , "simln" , "run_simln" ]))
46+ cmd = "warnet plugin run"
47+ self .log .info (cmd )
48+ self .sut = pexpect .spawn (cmd )
49+ self .sut .expect ("simln" , timeout = 10 )
50+ self .sut .send (ENTER )
51+ self .sut .expect ("run_simln" , timeout = 10 )
52+ self .sut .send (DOWN )
53+ self .sut .send (DOWN )
54+ self .sut .send (DOWN )
55+ self .sut .send (DOWN )
56+ self .sut .send (DOWN )
57+ self .sut .send (DOWN )
58+ self .sut .send (DOWN )
59+ self .sut .send (DOWN ) # run_simln
60+ self .sut .send (ENTER )
61+ self .sut .expect ("Sent command" , timeout = 60 * 3 )
62+ self .sut .close ()
63+
64+ cmd = "warnet plugin run simln get_example_activity"
65+ self .log .info (cmd )
66+ self .sut = pexpect .spawn (cmd )
67+ self .sut .expect ("amount_msat" , timeout = 10 )
68+ self .sut .close ()
69+
70+ cmd = 'warnet plugin run simln launch_activity --params "$(warnet plugin run simln get_example_activity)"'
71+ self .log .info (f"/bin/bash -c '{ cmd } '" )
72+ self .sut = pexpect .spawn (f"/bin/bash -c '{ cmd } '" )
73+ self .sut .expect ("install simln" , timeout = 10 )
74+ self .sut .close ()
75+
4476 sleep (10 )
4577
4678 def copy_results (self ) -> bool :
@@ -83,5 +115,5 @@ def wait_for_gossip_sync(self, expected: int):
83115
84116
85117if __name__ == "__main__" :
86- test = LNTest ()
118+ test = SimLNTest ()
87119 test .run_test ()
0 commit comments