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

Function test_zeroreserve_alldust

tests/test_opening.py:2844–2888  ·  view source on GitHub ↗

If we allow dust reserves we need larger fundings This is because we might have up to allhtlcs = (local.max_concurrent_htlcs + remote.max_concurrent_htlcs) alldust = allhlcs * min(local.dust, remote.dust) allocated to HTLCs in flight, reducing both direct outputs to dust.

(node_factory)

Source from the content-addressed store, hash-verified

2842
2843
2844def test_zeroreserve_alldust(node_factory):
2845 """If we allow dust reserves we need larger fundings
2846
2847 This is because we might have up to
2848
2849 allhtlcs = (local.max_concurrent_htlcs + remote.max_concurrent_htlcs)
2850 alldust = allhlcs * min(local.dust, remote.dust)
2851
2852 allocated to HTLCs in flight, reducing both direct outputs to
2853 dust. This could leave us with no outs on the commitment, is
2854 therefore invalid.
2855
2856 Parameters are as follows:
2857 - Regtest:
2858 - max_concurrent_htlcs = 483
2859 - dust = 546sat
2860 - minfunding = (483 * 2 + 2) * 546sat = 528528sat
2861 - Mainnet:
2862 - max_concurrent_htlcs = 30
2863 - dust = 546sat
2864 - minfunding = (30 * 2 + 2) * 546sat = 33852s
2865 """
2866 plugin_path = Path(__file__).parent / "plugins" / "zeroreserve.py"
2867 l1, l2 = node_factory.get_nodes(2, opts=[{
2868 'plugin': plugin_path,
2869 'reserve': '0sat',
2870 'dev-allowdustreserve': True
2871 }] * 2)
2872 maxhtlc = 483
2873 mindust = 546
2874 minfunding = (maxhtlc * 2 + 2) * mindust
2875
2876 l1.fundwallet(10**6)
2877 error = (f'channel funding {minfunding}sat too small for chosen parameters: '
2878 f'a total of {maxhtlc * 2} HTLCs with dust value {mindust}sat would '
2879 f'result in a commitment_transaction without outputs')
2880
2881 # This is right on the edge, and should fail
2882 with pytest.raises(RpcError, match=error):
2883 l1.connect(l2)
2884 l1.rpc.fundchannel(l2.info['id'], minfunding)
2885
2886 # Now try with just a bit more
2887 l1.connect(l2)
2888 l1.rpc.fundchannel(l2.info['id'], minfunding + 1)
2889
2890
2891def test_coinbase_unspendable(node_factory, bitcoind):

Callers

nothing calls this directly

Calls 4

get_nodesMethod · 0.80
fundwalletMethod · 0.80
connectMethod · 0.45
fundchannelMethod · 0.45

Tested by

no test coverage detected