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

Function test_zeroreserve

tests/test_opening.py:2736–2811  ·  view source on GitHub ↗

Ensure we can set the reserves. 3 nodes: - l1 enforces zeroreserve - l2 enforces default reserve - l3 enforces sub-dust reserves

(node_factory, bitcoind)

Source from the content-addressed store, hash-verified

2734
2735
2736def test_zeroreserve(node_factory, bitcoind):
2737 """Ensure we can set the reserves.
2738
2739 3 nodes:
2740 - l1 enforces zeroreserve
2741 - l2 enforces default reserve
2742 - l3 enforces sub-dust reserves
2743 """
2744 plugin_path = Path(__file__).parent / "plugins" / "zeroreserve.py"
2745 opts = [
2746 {
2747 'plugin': str(plugin_path),
2748 'reserve': '0sat',
2749 'dev-allowdustreserve': True,
2750 },
2751 {
2752 'dev-allowdustreserve': True,
2753 },
2754 {
2755 'plugin': str(plugin_path),
2756 'reserve': '123sat',
2757 'dev-allowdustreserve': True,
2758 }
2759 ]
2760 l1, l2, l3 = node_factory.get_nodes(3, opts=opts)
2761
2762 l1.fundwallet(10**7)
2763 l2.fundwallet(10**7)
2764 l3.fundwallet(10**7)
2765
2766 l1.connect(l2)
2767 l2.connect(l3)
2768 l3.connect(l1)
2769
2770 l1.rpc.fundchannel(l2.info['id'], 10**6, reserve='0sat')
2771 l2.rpc.fundchannel(l3.info['id'], 10**6)
2772 l3.rpc.fundchannel(l1.info['id'], 10**6, reserve='321sat')
2773 bitcoind.generate_block(1, wait_for_mempool=3)
2774 wait_for(lambda: l1.channel_state(l2) == 'CHANNELD_NORMAL')
2775 wait_for(lambda: l2.channel_state(l3) == 'CHANNELD_NORMAL')
2776 wait_for(lambda: l3.channel_state(l1) == 'CHANNELD_NORMAL')
2777
2778 # Now make sure we all agree on each others reserves
2779 l1c1 = l1.rpc.listpeerchannels(l2.info['id'])['channels'][0]
2780 l2c1 = l2.rpc.listpeerchannels(l1.info['id'])['channels'][0]
2781 l2c2 = l2.rpc.listpeerchannels(l3.info['id'])['channels'][0]
2782 l3c2 = l3.rpc.listpeerchannels(l2.info['id'])['channels'][0]
2783 l3c3 = l3.rpc.listpeerchannels(l1.info['id'])['channels'][0]
2784 l1c3 = l1.rpc.listpeerchannels(l3.info['id'])['channels'][0]
2785 # l1 imposed a 0sat reserve on l2, while l2 imposed the default 1% reserve on l1
2786 assert l1c1['their_reserve_msat'] == l2c1['our_reserve_msat'] == Millisatoshi('0sat')
2787 assert l1c1['our_reserve_msat'] == l2c1['their_reserve_msat'] == Millisatoshi('10000sat')
2788
2789 # l2 imposed the default 1% on l3, while l3 imposed a custom 123sat fee on l2
2790 assert l2c2['their_reserve_msat'] == l3c2['our_reserve_msat'] == Millisatoshi('10000sat')
2791 assert l2c2['our_reserve_msat'] == l3c2['their_reserve_msat'] == Millisatoshi('123sat')
2792
2793 # l3 imposed a custom 321sat fee on l1, while l1 imposed a custom 0sat fee on l3

Callers

nothing calls this directly

Calls 13

wait_forFunction · 0.90
MillisatoshiClass · 0.90
only_oneFunction · 0.90
get_nodesMethod · 0.80
fundwalletMethod · 0.80
generate_blockMethod · 0.80
channel_stateMethod · 0.80
listpeerchannelsMethod · 0.80
drainMethod · 0.80
connectMethod · 0.45
fundchannelMethod · 0.45
xkeysendMethod · 0.45

Tested by

no test coverage detected