5
5
6
6
from commander import Commander
7
7
from ln_framework .ln import (
8
- Policy ,
9
8
CHANNEL_OPEN_START_HEIGHT ,
10
9
CHANNEL_OPENS_PER_BLOCK ,
10
+ FEE_RATE_DECREMENT ,
11
11
MAX_FEE_RATE ,
12
- FEE_RATE_DECREMENT
12
+ Policy ,
13
13
)
14
+ from test_framework .address import address_to_scriptpubkey
14
15
from test_framework .messages import (
15
16
COIN ,
16
17
CTransaction ,
17
18
CTxOut ,
18
19
)
19
- from test_framework .address import address_to_scriptpubkey
20
20
21
21
22
22
class LNInit (Commander ):
@@ -105,7 +105,7 @@ def get_ln_addr(self, ln):
105
105
sat_amt = 10 * COIN
106
106
helicopter .vout .append (CTxOut (sat_amt , address_to_scriptpubkey (addr )))
107
107
rawtx = miner .fundrawtransaction (helicopter .serialize ().hex ())
108
- signed_tx = miner .signrawtransactionwithwallet (rawtx [' hex' ])[' hex' ]
108
+ signed_tx = miner .signrawtransactionwithwallet (rawtx [" hex" ])[" hex" ]
109
109
txid = miner .sendrawtransaction (signed_tx )
110
110
# confirm funds in last block before channel opens
111
111
gen (1 )
@@ -133,11 +133,14 @@ def confirm_ln_balance(self, ln_name):
133
133
self .log .info (f"Got 0 balance from { ln_name } retrying in 5 seconds..." )
134
134
sleep (5 )
135
135
except Exception as e :
136
- self .log .info (f"Couldn't get balance from { ln_name } because { e } , retrying in 5 seconds..." )
136
+ self .log .info (
137
+ f"Couldn't get balance from { ln_name } because { e } , retrying in 5 seconds..."
138
+ )
137
139
sleep (5 )
138
140
139
141
fund_threads = [
140
- threading .Thread (target = confirm_ln_balance , args = (self , ln_name )) for ln_name in channel_openers
142
+ threading .Thread (target = confirm_ln_balance , args = (self , ln_name ))
143
+ for ln_name in channel_openers
141
144
]
142
145
for thread in fund_threads :
143
146
thread .start ()
@@ -159,7 +162,9 @@ def get_ln_uri(self, ln):
159
162
self .log .info (f"LN node { ln .name } has URI { uri } " )
160
163
break
161
164
except Exception as e :
162
- self .log .info (f"Couldn't get URI from { ln .name } because { e } , retrying in 5 seconds..." )
165
+ self .log .info (
166
+ f"Couldn't get URI from { ln .name } because { e } , retrying in 5 seconds..."
167
+ )
163
168
sleep (5 )
164
169
165
170
uri_threads = [
@@ -212,7 +217,9 @@ def connect_ln(self, pair):
212
217
else :
213
218
raise Exception (res )
214
219
except Exception as e :
215
- self .log .info (f"Couldn't connect { pair [0 ].name } -> { pair [1 ].name } because { e } , retrying in 5 seconds..." )
220
+ self .log .info (
221
+ f"Couldn't connect { pair [0 ].name } -> { pair [1 ].name } because { e } , retrying in 5 seconds..."
222
+ )
216
223
sleep (5 )
217
224
218
225
p2p_threads = [
@@ -268,15 +275,21 @@ def open_channel(self, ch, fee_rate):
268
275
)
269
276
ch ["txid" ] = res ["txid" ]
270
277
ch ["outpoint" ] = res ["outpoint" ]
271
- self .log .info (f"Channel open success:\n { log } \n outpoint: { res ['outpoint' ]} " )
278
+ self .log .info (
279
+ f"Channel open success:\n { log } \n outpoint: { res ['outpoint' ]} "
280
+ )
272
281
break
273
282
except Exception as e :
274
- self .log .info (f"Couldn't open channel:\n { log } \n { e } \n Retrying in 5 seconds..." )
283
+ self .log .info (
284
+ f"Couldn't open channel:\n { log } \n { e } \n Retrying in 5 seconds..."
285
+ )
275
286
sleep (5 )
276
287
277
288
channels = sorted (ch_by_block [target_block ], key = lambda ch : ch ["id" ]["index" ])
278
289
if len (channels ) > CHANNEL_OPENS_PER_BLOCK :
279
- raise Exception (f"Too many channels in block { target_block } : { len (channels )} / Maximum: { CHANNEL_OPENS_PER_BLOCK } " )
290
+ raise Exception (
291
+ f"Too many channels in block { target_block } : { len (channels )} / Maximum: { CHANNEL_OPENS_PER_BLOCK } "
292
+ )
280
293
index = 0
281
294
fee_rate = MAX_FEE_RATE
282
295
ch_threads = []
@@ -335,7 +348,9 @@ def ln_all_chs(self, ln):
335
348
)
336
349
sleep (5 )
337
350
except Exception as e :
338
- self .log .info (f"Couldn't check graph from { ln .name } because { e } , retrying in 5 seconds..." )
351
+ self .log .info (
352
+ f"Couldn't check graph from { ln .name } because { e } , retrying in 5 seconds..."
353
+ )
339
354
sleep (5 )
340
355
341
356
ch_ann_threads = [
@@ -367,7 +382,9 @@ def update_policy(self, ln, txid_hex, policy, capacity):
367
382
continue
368
383
break
369
384
except Exception as e :
370
- self .log .info (f"Couldn't update channel policy for { ln .name } because { e } , retrying in 5 seconds..." )
385
+ self .log .info (
386
+ f"Couldn't update channel policy for { ln .name } because { e } , retrying in 5 seconds..."
387
+ )
371
388
sleep (5 )
372
389
373
390
update_threads = []
@@ -416,7 +433,9 @@ def matching_graph(self, expected, ln):
416
433
try :
417
434
actual = ln .graph ()["edges" ]
418
435
except Exception as e :
419
- self .log .info (f"Couldn't get graph from { ln .name } because { e } , retrying in 5 seconds..." )
436
+ self .log .info (
437
+ f"Couldn't get graph from { ln .name } because { e } , retrying in 5 seconds..."
438
+ )
420
439
sleep (5 )
421
440
continue
422
441
0 commit comments