55
66from commander import Commander
77from ln_framework .ln import (
8- Policy ,
98 CHANNEL_OPEN_START_HEIGHT ,
109 CHANNEL_OPENS_PER_BLOCK ,
10+ FEE_RATE_DECREMENT ,
1111 MAX_FEE_RATE ,
12- FEE_RATE_DECREMENT
12+ Policy ,
1313)
14+ from test_framework .address import address_to_scriptpubkey
1415from test_framework .messages import (
1516 COIN ,
1617 CTransaction ,
1718 CTxOut ,
1819)
19- from test_framework .address import address_to_scriptpubkey
2020
2121
2222class LNInit (Commander ):
@@ -105,7 +105,7 @@ def get_ln_addr(self, ln):
105105 sat_amt = 10 * COIN
106106 helicopter .vout .append (CTxOut (sat_amt , address_to_scriptpubkey (addr )))
107107 rawtx = miner .fundrawtransaction (helicopter .serialize ().hex ())
108- signed_tx = miner .signrawtransactionwithwallet (rawtx [' hex' ])[' hex' ]
108+ signed_tx = miner .signrawtransactionwithwallet (rawtx [" hex" ])[" hex" ]
109109 txid = miner .sendrawtransaction (signed_tx )
110110 # confirm funds in last block before channel opens
111111 gen (1 )
@@ -133,11 +133,14 @@ def confirm_ln_balance(self, ln_name):
133133 self .log .info (f"Got 0 balance from { ln_name } retrying in 5 seconds..." )
134134 sleep (5 )
135135 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+ )
137139 sleep (5 )
138140
139141 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
141144 ]
142145 for thread in fund_threads :
143146 thread .start ()
@@ -159,7 +162,9 @@ def get_ln_uri(self, ln):
159162 self .log .info (f"LN node { ln .name } has URI { uri } " )
160163 break
161164 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+ )
163168 sleep (5 )
164169
165170 uri_threads = [
@@ -212,7 +217,9 @@ def connect_ln(self, pair):
212217 else :
213218 raise Exception (res )
214219 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+ )
216223 sleep (5 )
217224
218225 p2p_threads = [
@@ -268,15 +275,21 @@ def open_channel(self, ch, fee_rate):
268275 )
269276 ch ["txid" ] = res ["txid" ]
270277 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+ )
272281 break
273282 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+ )
275286 sleep (5 )
276287
277288 channels = sorted (ch_by_block [target_block ], key = lambda ch : ch ["id" ]["index" ])
278289 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+ )
280293 index = 0
281294 fee_rate = MAX_FEE_RATE
282295 ch_threads = []
@@ -335,7 +348,9 @@ def ln_all_chs(self, ln):
335348 )
336349 sleep (5 )
337350 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+ )
339354 sleep (5 )
340355
341356 ch_ann_threads = [
@@ -367,7 +382,9 @@ def update_policy(self, ln, txid_hex, policy, capacity):
367382 continue
368383 break
369384 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+ )
371388 sleep (5 )
372389
373390 update_threads = []
@@ -416,7 +433,9 @@ def matching_graph(self, expected, ln):
416433 try :
417434 actual = ln .graph ()["edges" ]
418435 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+ )
420439 sleep (5 )
421440 continue
422441
0 commit comments