Test that we enforce fee max percentage and max delay
(node_factory)
| 107 | |
| 108 | |
| 109 | def test_pay_limits(node_factory): |
| 110 | """Test that we enforce fee max percentage and max delay""" |
| 111 | l1, l2, l3 = node_factory.line_graph(3, wait_for_announce=True) |
| 112 | |
| 113 | # FIXME: pylightning should define this! |
| 114 | PAY_ROUTE_TOO_EXPENSIVE = 206 |
| 115 | |
| 116 | inv = l3.rpc.invoice("any", "any", 'description') |
| 117 | |
| 118 | # Fee too high. |
| 119 | err = r'Could not find route without excessive cost' |
| 120 | with pytest.raises(RpcError, match=err) as err: |
| 121 | l1.rpc.call('xpay', {'invstring': inv['bolt11'], 'amount_msat': 100000, 'maxfee': 1}) |
| 122 | |
| 123 | assert err.value.error['code'] == PAY_ROUTE_TOO_EXPENSIVE |
| 124 | |
| 125 | failmsg = r'Could not find route without excessive delays' |
| 126 | # Delay too high. |
| 127 | with pytest.raises(RpcError, match=failmsg) as err: |
| 128 | l1.rpc.call('xpay', {'invstring': inv['bolt11'], 'amount_msat': 100000, 'maxdelay': 0}) |
| 129 | |
| 130 | assert err.value.error['code'] == PAY_ROUTE_TOO_EXPENSIVE |
| 131 | |
| 132 | # This fails! |
| 133 | err = r'Could not find route without excessive cost' |
| 134 | with pytest.raises(RpcError, match=err) as err: |
| 135 | l1.rpc.xpay(invstring=inv['bolt11'], amount_msat=100000, maxfee=1) |
| 136 | |
| 137 | # This works, because fee is less than exemptfee. |
| 138 | l1.dev_pay(inv['bolt11'], amount_msat=100000, maxfeepercent=0.0001, |
| 139 | exemptfee=2000, dev_use_shadow=False) |
| 140 | |
| 141 | |
| 142 | def test_pay_maxdelay_direct_channel(node_factory): |
nothing calls this directly
no test coverage detected