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

Function test_limits

tests/test_renepay.py:249–306  ·  view source on GitHub ↗

Topology: 1----2----4 | | 3----5----6 Try the error messages when paying when: - the fees are too high, - CLTV delay is too high, - probability of success is too low.

(node_factory)

Source from the content-addressed store, hash-verified

247
248
249def test_limits(node_factory):
250 """
251 Topology:
252 1----2----4
253 | |
254 3----5----6
255 Try the error messages when paying when:
256 - the fees are too high,
257 - CLTV delay is too high,
258 - probability of success is too low.
259 """
260 opts = [
261 {"disable-mpp": None, "fee-base": 0, "fee-per-satoshi": 100, 'allow-deprecated-apis': True},
262 ]
263 l1, l2, l3, l4, l5, l6 = node_factory.get_nodes(6, opts=opts * 6)
264 node_factory.join_nodes(
265 [l1, l2, l4, l6], wait_for_announce=True, fundamount=1000000
266 )
267 node_factory.join_nodes(
268 [l1, l3, l5, l6], wait_for_announce=True, fundamount=1000000
269 )
270
271 inv = l4.rpc.invoice("any", "any", "description")
272 l2.rpc.call("pay", {"bolt11": inv["bolt11"], "amount_msat": 500000000})
273 inv = l5.rpc.invoice("any", "any", "description")
274 l3.rpc.call("pay", {"bolt11": inv["bolt11"], "amount_msat": 500000000})
275
276 # FIXME: pylightning should define these!
277 # PAY_STOPPED_RETRYING = 210
278 PAY_ROUTE_TOO_EXPENSIVE = 206
279
280 inv = l6.rpc.invoice("any", "any", "description")
281
282 # Fee too high.
283 failmsg = r"Fee exceeds our fee budget"
284 with pytest.raises(RpcError, match=failmsg) as err:
285 l1.rpc.call(
286 "renepay", {"invstring": inv["bolt11"], "amount_msat": 1000000, "maxfee": 1}
287 )
288 assert err.value.error["code"] == PAY_ROUTE_TOO_EXPENSIVE
289 # TODO(eduardo): which error code shall we use here?
290
291 # TODO(eduardo): shall we list attempts in renepay?
292 # status = l1.rpc.call('renepaystatus', {'invstring':inv['bolt11']})['paystatus'][0]['attempts']
293
294 failmsg = r"CLTV delay exceeds our CLTV budget"
295 # Delay too high.
296 with pytest.raises(RpcError, match=failmsg) as err:
297 l1.rpc.call(
298 "renepay",
299 {"invstring": inv["bolt11"], "amount_msat": 1000000, "maxdelay": 0},
300 )
301 assert err.value.error["code"] == PAY_ROUTE_TOO_EXPENSIVE
302
303 inv2 = l6.rpc.invoice("800000sat", "inv2", "description")
304 l1.rpc.call("renepay", {"invstring": inv2["bolt11"]})
305 invoice = only_one(l6.rpc.listinvoices("inv2")["invoices"])
306 assert invoice["amount_received_msat"] >= Millisatoshi("800000sat")

Callers

nothing calls this directly

Calls 7

only_oneFunction · 0.90
MillisatoshiClass · 0.90
get_nodesMethod · 0.80
join_nodesMethod · 0.80
invoiceMethod · 0.45
callMethod · 0.45
listinvoicesMethod · 0.45

Tested by

no test coverage detected