@@ -12,6 +12,7 @@ class LNBasicTest(TestBase):
12
12
def __init__ (self ):
13
13
super ().__init__ ()
14
14
self .network_dir = Path (os .path .dirname (__file__ )) / "data" / "ln"
15
+ self .scen_dir = Path (os .path .dirname (__file__ )).parent / "resources" / "scenarios"
15
16
self .lns = [
16
17
"tank-0000-ln" ,
17
18
"tank-0001-ln" ,
@@ -29,16 +30,21 @@ def run_test(self):
29
30
self .fund_wallets ()
30
31
31
32
# Manually open two channels between first three nodes
32
- # and send a payment
33
+ # and send a payment using warnet RPC
33
34
self .manual_open_channels ()
34
35
self .wait_for_gossip_sync (self .lns [:3 ], 2 )
35
36
self .pay_invoice (sender = "tank-0000-ln" , recipient = "tank-0002-ln" )
36
37
37
- # Automatically open channels from network.yaml
38
+ # Automatically open channels from network.yaml using warnet RPC
38
39
self .automatic_open_channels ()
39
- self .wait_for_gossip_sync (self .lns [3 :], 3 )
40
+ self .wait_for_gossip_sync (self .lns [3 :], 2 )
40
41
# push_amt should enable payments from target to source
41
42
self .pay_invoice (sender = "tank-0005-ln" , recipient = "tank-0003-ln" )
43
+
44
+ # Automatically open channels from inside a scenario commander
45
+ self .scenario_open_channels ()
46
+ self .pay_invoice (sender = "tank-0002-ln" , recipient = "tank-0003-ln" )
47
+
42
48
finally :
43
49
self .cleanup ()
44
50
@@ -75,6 +81,11 @@ def fund_wallets(self):
75
81
self .warnet ("bitcoin rpc tank-0000 sendmany '' '{" + outputs + "}'" )
76
82
self .warnet ("bitcoin rpc tank-0000 -generate 1" )
77
83
84
+ def wait_for_two_txs (self ):
85
+ self .wait_for_predicate (
86
+ lambda : json .loads (self .warnet ("bitcoin rpc tank-0000 getmempoolinfo" ))["size" ] == 2
87
+ )
88
+
78
89
def manual_open_channels (self ):
79
90
# 0 -> 1 -> 2
80
91
pk1 = self .warnet ("ln pubkey tank-0001-ln" )
@@ -101,10 +112,7 @@ def manual_open_channels(self):
101
112
)
102
113
)
103
114
104
- def wait_for_two_txs ():
105
- return json .loads (self .warnet ("bitcoin rpc tank-0000 getmempoolinfo" ))["size" ] == 2
106
-
107
- self .wait_for_predicate (wait_for_two_txs )
115
+ self .wait_for_two_txs ()
108
116
109
117
self .warnet ("bitcoin rpc tank-0000 -generate 10" )
110
118
@@ -131,14 +139,20 @@ def wait_for_success():
131
139
self .wait_for_predicate (wait_for_success )
132
140
133
141
def automatic_open_channels (self ):
142
+ # 3 -> 4 -> 5
134
143
self .warnet ("ln open-all-channels" )
135
144
136
- def wait_for_three_txs ():
137
- return json .loads (self .warnet ("bitcoin rpc tank-0000 getmempoolinfo" ))["size" ] == 3
145
+ self .wait_for_two_txs ()
138
146
139
- self .wait_for_predicate (wait_for_three_txs )
140
147
self .warnet ("bitcoin rpc tank-0000 -generate 10" )
141
148
149
+ def scenario_open_channels (self ):
150
+ # 2 -> 3
151
+ # connecting all six ln nodes in the graph
152
+ scenario_file = self .scen_dir / "test_scenarios" / "ln_basic.py"
153
+ self .log .info (f"Running scenario from: { scenario_file } " )
154
+ self .warnet (f"run { scenario_file } --source_dir={ self .scen_dir } --debug" )
155
+
142
156
143
157
if __name__ == "__main__" :
144
158
test = LNBasicTest ()
0 commit comments