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

Function test_pay_exemptfee

tests/test_pay.py:3783–3818  ·  view source on GitHub ↗

Tiny payment, huge fee l1 -> l2 -> l3 Create a tiny invoice for 1 msat, it'll be dominated by the base_fee on the l2->l3 channel. So it'll get rejected on the first attempt if we set the exemptfee way too low. The default fee exemption threshold is 5000msat, so 5001msat is not

(node_factory)

Source from the content-addressed store, hash-verified

3781
3782
3783def test_pay_exemptfee(node_factory):
3784 """Tiny payment, huge fee
3785
3786 l1 -> l2 -> l3
3787
3788 Create a tiny invoice for 1 msat, it'll be dominated by the base_fee on
3789 the l2->l3 channel. So it'll get rejected on the first attempt if we set
3790 the exemptfee way too low. The default fee exemption threshold is
3791 5000msat, so 5001msat is not exempted by default and a 5001msat fee on
3792 l2->l3 should trigger this.
3793
3794 """
3795 l1, l2, l3 = node_factory.line_graph(
3796 3,
3797 opts=[{}, {'fee-base': 5001, 'fee-per-satoshi': 0}, {}],
3798 wait_for_announce=True
3799 )
3800
3801 err = r'Could not find route without excessive cost'
3802
3803 with pytest.raises(RpcError, match=err):
3804 l1.dev_pay(l3.rpc.invoice(1, "lbl1", "desc")['bolt11'], dev_use_shadow=False)
3805
3806 # If we tell our node that 5001msat is ok this should work
3807 l1.dev_pay(l3.rpc.invoice(1, "lbl2", "desc")['bolt11'], dev_use_shadow=False, exemptfee=5001)
3808
3809 # Given the above network this is the smallest amount that passes without
3810 # the fee-exemption (notice that we let it through on equality).
3811 threshold = int(5001 / 0.05)
3812
3813 # This should be just below the fee-exemption and is the first value that is allowed through
3814 with pytest.raises(RpcError, match=err):
3815 l1.dev_pay(l3.rpc.invoice(threshold - 1, "lbl3", "desc")['bolt11'], dev_use_shadow=False)
3816
3817 # While this'll work just fine
3818 l1.dev_pay(l3.rpc.invoice(int(5001 * 200), "lbl4", "desc")['bolt11'], dev_use_shadow=False)
3819
3820
3821def test_pay_peer(node_factory, bitcoind):

Callers

nothing calls this directly

Calls 3

line_graphMethod · 0.80
dev_payMethod · 0.45
invoiceMethod · 0.45

Tested by

no test coverage detected