@@ -184,7 +184,6 @@ def connect_ln(self, pair):
184
184
threading .Thread (target = connect_ln , args = (self , pair )) for pair in connections
185
185
]
186
186
for thread in p2p_threads :
187
- sleep (1 )
188
187
thread .start ()
189
188
190
189
all (thread .join (timeout = THREAD_JOIN_TIMEOUT ) is None for thread in p2p_threads )
@@ -258,7 +257,6 @@ def open_channel(self, ch, fee_rate):
258
257
assert index == ch ["id" ]["index" ], "Channel ID indexes are not consecutive"
259
258
assert fee_rate >= 1 , "Too many TXs in block, out of fee range"
260
259
t = threading .Thread (target = open_channel , args = (self , ch , fee_rate ))
261
- sleep (2 )
262
260
t .start ()
263
261
ch_threads .append (t )
264
262
@@ -288,20 +286,25 @@ def open_channel(self, ch, fee_rate):
288
286
def ln_all_chs (self , ln ):
289
287
expected = len (self .channels )
290
288
attempts = 0
291
- max_tries = 5
292
- while len (ln .graph ()["edges" ]) != expected and attempts < max_tries :
289
+ actual = 0
290
+ while actual != expected :
291
+ actual = len (ln .graph ()["edges" ])
292
+ if attempts > 10 :
293
+ break
293
294
attempts += 1
294
- sleep (1 )
295
- self .log .info (f"LN { ln .name } has graph with all { expected } channels" )
295
+ sleep (5 )
296
+ if actual == expected :
297
+ self .log .info (f"LN { ln .name } has graph with all { expected } channels" )
298
+ else :
299
+ self .log .error (f"LN { ln .name } graph is INCOMPLETE - { actual } of { expected } channels" )
296
300
297
301
ch_ann_threads = [
298
302
threading .Thread (target = ln_all_chs , args = (self , ln )) for ln in ln_nodes
299
303
]
300
304
for thread in ch_ann_threads :
301
- sleep (1 )
302
305
thread .start ()
303
306
304
- all (thread .join (timeout = THREAD_JOIN_TIMEOUT ) is None for thread in ch_ann_threads )
307
+ all (thread .join (timeout = THREAD_JOIN_TIMEOUT * 2 ) is None for thread in ch_ann_threads )
305
308
self .log .info ("All LN nodes have complete graph" )
306
309
307
310
##
@@ -359,14 +362,15 @@ def matching_graph(self, expected, ln):
359
362
while not done :
360
363
actual = ln .graph ()["edges" ]
361
364
self .log .debug (f"LN { ln .name } channel graph edges: { actual } " )
362
- assert (len (expected ) == len (actual ),f"Expected edges { expected } , actual edges { actual } " )
363
- if len (actual ) > 0 : done = True
365
+ if len (actual ) > 0 :
366
+ done = True
367
+ assert len (expected ) == len (actual ), f"Expected edges { len (expected )} , actual edges { len (actual )} \n { actual } "
364
368
for i , actual_ch in enumerate (actual ):
365
369
expected_ch = expected [i ]
366
370
capacity = expected_ch ["capacity" ]
367
371
# We assert this because it isn't updated as part of policy.
368
372
# If this fails we have a bigger issue
369
- assert int (actual_ch ["capacity" ]) == capacity , f"LN { ln .name } graph capacity mismatch:\n actual: { actual_ch } \n expected: { expected_ch } "
373
+ assert int (actual_ch ["capacity" ]) == capacity , f"LN { ln .name } graph capacity mismatch:\n actual: { actual_ch [ "capacity" ] } \n expected: { capacity } "
370
374
371
375
# Policies were not defined in network.yaml
372
376
if "source_policy" not in expected_ch or "target_policy" not in expected_ch :
0 commit comments