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

Function test_openchannel_hook

tests/test_plugin.py:732–792  ·  view source on GitHub ↗

l2 uses the reject_odd_funding_amounts plugin to reject some openings.

(node_factory, bitcoind)

Source from the content-addressed store, hash-verified

730@pytest.mark.openchannel('v1')
731@pytest.mark.openchannel('v2')
732def test_openchannel_hook(node_factory, bitcoind):
733 """ l2 uses the reject_odd_funding_amounts plugin to reject some openings.
734 """
735 opts = [{}, {'plugin': os.path.join(os.getcwd(), 'tests/plugins/reject_odd_funding_amounts.py')}]
736 l1, l2 = node_factory.line_graph(2, fundchannel=False, opts=opts)
737 l1.fundwallet(10**6)
738
739 # Even amount: works.
740 l1.rpc.fundchannel(l2.info['id'], 100000)
741
742 # Make sure plugin got all the vars we expect
743 expected = {
744 'channel_flags': '1',
745 'dust_limit_msat': 546000,
746 'htlc_minimum_msat': 0,
747 'id': l1.info['id'],
748 'max_accepted_htlcs': '483',
749 'max_htlc_value_in_flight_msat': 18446744073709551615,
750 'to_self_delay': '5',
751 }
752
753 if 'anchors/even' in only_one(l1.rpc.listpeerchannels()['channels'])['channel_type']['names']:
754 feerate = 3750
755 expected['channel_type'] = r"{'bits': \[12, 22\], 'names': \['static_remotekey/even', 'anchors/even'\]}"
756 else:
757 feerate = 7500
758 expected['channel_type'] = r"{'bits': \[12\], 'names': \['static_remotekey/even'\]}"
759 if l2.config('experimental-dual-fund'):
760 # openchannel2 var checks
761 expected.update({
762 'channel_id': '.*',
763 'channel_max_msat': 2100000000000000000,
764 'commitment_feerate_per_kw': feerate,
765 'funding_feerate_per_kw': '7500',
766 'feerate_our_max': '150000',
767 'feerate_our_min': '1875',
768 'locktime': '.*',
769 'require_confirmed_inputs': False,
770 'their_funding_msat': 100000000,
771 })
772 else:
773 expected.update({
774 'channel_reserve_msat': 1000000,
775 'feerate_per_kw': feerate,
776 'funding_msat': 100000000,
777 'push_msat': 0,
778 })
779
780 l2.daemon.wait_for_log('reject_odd_funding_amounts.py: {} VARS'.format(len(expected)))
781 for k, v in expected.items():
782 assert l2.daemon.is_in_log('reject_odd_funding_amounts.py: {}={}'.format(k, v))
783
784 # Close it.
785 txid = only_one(l1.rpc.close(l2.info['id'])['txids'])
786 bitcoind.generate_block(1, txid)
787 wait_for(lambda: [c['state'] for c in l1.rpc.listpeerchannels(l2.info['id'])['channels']] == ['ONCHAIN'])
788
789 # Odd amount: fails

Callers

nothing calls this directly

Calls 14

only_oneFunction · 0.90
wait_forFunction · 0.90
joinMethod · 0.80
line_graphMethod · 0.80
fundwalletMethod · 0.80
listpeerchannelsMethod · 0.80
configMethod · 0.80
updateMethod · 0.80
wait_for_logMethod · 0.80
is_in_logMethod · 0.80
generate_blockMethod · 0.80
fundchannelMethod · 0.45

Tested by

no test coverage detected