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

Function verify_chans

tests/test_splice.py:578–614  ·  view source on GitHub ↗
(nodes, bitcoind, txid, chanids, fee, expected_balances=None, fee_multiplier=None)

Source from the content-addressed store, hash-verified

576
577
578def verify_chans(nodes, bitcoind, txid, chanids, fee, expected_balances=None, fee_multiplier=None):
579 for node in nodes:
580 node.daemon.wait_for_log(r'CHANNELD_NORMAL to CHANNELD_AWAITING_SPLICE')
581
582 wait_for(lambda: len(list(bitcoind.rpc.getrawmempool(True).keys())) == 1)
583
584 bitcoind.generate_block(6, wait_for_mempool=1)
585
586 for chanid in chanids:
587 nodes[1].daemon.wait_for_log(r'CHANNELD_AWAITING_SPLICE to CHANNELD_NORMAL')
588
589 if not expected_balances:
590 return
591
592 # Modify expected_balances by fee_multipler and fee
593 extra_funds = 0
594 last_index = 0
595
596 if fee_multiplier:
597 for index, multiplier in enumerate(fee_multiplier):
598 amount, remainder = divmod(multiplier * fee, 1)
599 expected_balances[index] += int(amount)
600 extra_funds += remainder
601 if multiplier != 0:
602 last_index = index
603
604 # If we have extra funds, put them all in the last item
605 if extra_funds > 0:
606 expected_balances[last_index] += int(extra_funds)
607
608 channel_funds = nodes[1].rpc.listfunds()['channels']
609
610 channel_funds.sort(key=lambda info: chanids.index(info['channel_id']))
611
612 funds = [info['our_amount_msat'] // 1000 for info in channel_funds]
613
614 assert funds == expected_balances
615
616
617# * expected_balances is an array of sat values

Callers 1

execute_scriptFunction · 0.85

Calls 5

wait_forFunction · 0.90
wait_for_logMethod · 0.80
generate_blockMethod · 0.80
sortMethod · 0.80
listfundsMethod · 0.45

Tested by

no test coverage detected