MCPcopy Create free account
hub / github.com/ElementsProject/lightning / check_inspect_channel

Function check_inspect_channel

tests/utils.py:372–407  ·  view source on GitHub ↗
(n, channel_id, expected_txs)

Source from the content-addressed store, hash-verified

370
371
372def check_inspect_channel(n, channel_id, expected_txs):
373 actual_txs = n.rpc.bkpr_inspect(channel_id)['txs']
374 # Stash a copy in case we need to print on error/assert at end
375 _actual_txs = actual_txs
376 if len(actual_txs) != len(expected_txs.keys()):
377 raise ValueError(f'count actual_txs != expected exp: {expected_txs}')
378 # start at the top
379 exp = list(expected_txs.values())[0]
380 actual = actual_txs[0]
381
382 txids = []
383
384 exp_counter = 1
385 inspect_check_actual(txids, channel_id, actual, exp)
386 actual_txs.remove(actual)
387
388 for (marker, txid) in txids:
389 actual = None
390 for a in actual_txs:
391 if a['txid'] == txid:
392 actual = a
393 break
394 if not actual:
395 raise ValueError(f'No "actual" tx found, looking for {txid}. {actual_txs}')
396 exp = expected_txs[marker]
397 inspect_check_actual(txids, channel_id, actual, exp)
398
399 # after we've inspected it, remove it
400 actual_txs.remove(actual)
401 exp_counter += 1
402
403 # Did we inspect everything?
404 if len(actual_txs) != 0:
405 raise ValueError(f'Had more txs than expected. expected: {expected_txs}. actual: {_actual_txs}')
406 if exp_counter != len(expected_txs.keys()):
407 raise ValueError(f'Had less txs than expected. expected: {expected_txs}. actual txs: {_actual_txs}')
408
409
410def check_utxos_channel(n, chans, expected, exp_tag_list=None, filter_channel=None):

Callers 1

Calls 3

inspect_check_actualFunction · 0.85
bkpr_inspectMethod · 0.80
removeMethod · 0.45

Tested by 1