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

Function test_zeroreserve

tests/test_opening.py:1747–1823  ·  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

1745
1746
1747def test_zeroreserve(node_factory, bitcoind):
1748 """Ensure we can set the reserves.
1749
1750 3 nodes:
1751 - l1 enforces zeroreserve
1752 - l2 enforces default reserve
1753 - l3 enforces sub-dust reserves
1754 """
1755 plugin_path = Path(__file__).parent / "plugins" / "zeroreserve.py"
1756 opts = [
1757 {
1758 'plugin': str(plugin_path),
1759 'reserve': '0sat',
1760 'dev-allowdustreserve': True,
1761 },
1762 {
1763 'dev-allowdustreserve': True,
1764 },
1765 {
1766 'plugin': str(plugin_path),
1767 'reserve': '123sat',
1768 'dev-allowdustreserve': True,
1769 }
1770 ]
1771 l1, l2, l3 = node_factory.get_nodes(3, opts=opts)
1772
1773 l1.fundwallet(10**7)
1774 l2.fundwallet(10**7)
1775 l3.fundwallet(10**7)
1776
1777 l1.connect(l2)
1778 l2.connect(l3)
1779 l3.connect(l1)
1780
1781 l1.rpc.fundchannel(l2.info['id'], 10**6, reserve='0sat')
1782 l2.rpc.fundchannel(l3.info['id'], 10**6)
1783 l3.rpc.fundchannel(l1.info['id'], 10**6, reserve='321sat')
1784 bitcoind.generate_block(1, wait_for_mempool=3)
1785 wait_for(lambda: l1.channel_state(l2) == 'CHANNELD_NORMAL')
1786 wait_for(lambda: l2.channel_state(l3) == 'CHANNELD_NORMAL')
1787 wait_for(lambda: l3.channel_state(l1) == 'CHANNELD_NORMAL')
1788
1789 # Now make sure we all agree on each others reserves
1790 l1c1 = l1.rpc.listpeers(l2.info['id'])['peers'][0]['channels'][0]
1791 l2c1 = l2.rpc.listpeers(l1.info['id'])['peers'][0]['channels'][0]
1792 l2c2 = l2.rpc.listpeers(l3.info['id'])['peers'][0]['channels'][0]
1793 l3c2 = l3.rpc.listpeers(l2.info['id'])['peers'][0]['channels'][0]
1794 l3c3 = l3.rpc.listpeers(l1.info['id'])['peers'][0]['channels'][0]
1795 l1c3 = l1.rpc.listpeers(l3.info['id'])['peers'][0]['channels'][0]
1796
1797 # l1 imposed a 0sat reserve on l2, while l2 imposed the default 1% reserve on l1
1798 assert l1c1['their_reserve_msat'] == l2c1['our_reserve_msat'] == Millisatoshi('0sat')
1799 assert l1c1['our_reserve_msat'] == l2c1['their_reserve_msat'] == Millisatoshi('10000sat')
1800
1801 # l2 imposed the default 1% on l3, while l3 imposed a custom 123sat fee on l2
1802 assert l2c2['their_reserve_msat'] == l3c2['our_reserve_msat'] == Millisatoshi('10000sat')
1803 assert l2c2['our_reserve_msat'] == l3c2['their_reserve_msat'] == Millisatoshi('123sat')
1804

Callers

nothing calls this directly

Calls 12

wait_forFunction · 0.90
MillisatoshiClass · 0.90
get_nodesMethod · 0.80
fundwalletMethod · 0.80
generate_blockMethod · 0.80
channel_stateMethod · 0.80
keysendMethod · 0.80
drainMethod · 0.80
connectMethod · 0.45
fundchannelMethod · 0.45
listpeersMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected