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

Function test_pay_maxfee_shadow

tests/test_pay.py:472–496  ·  view source on GitHub ↗

Test that we respect maxfeepercent for shadow routing.

(node_factory)

Source from the content-addressed store, hash-verified

470
471
472def test_pay_maxfee_shadow(node_factory):
473 """Test that we respect maxfeepercent for shadow routing."""
474 l1, l2, l3 = node_factory.line_graph(3, fundchannel=True,
475 wait_for_announce=True)
476 # We use this to search for shadow routes
477 wait_for(
478 lambda: len(l1.rpc.listchannels(source=l2.info["id"])["channels"]) > 1
479 )
480
481 # shadow routes are random, so run multiple times.
482 for i in range(5):
483 # A tiny amount, we must not add the base_fee between l2 and l3
484 amount = 2
485 bolt11 = l2.rpc.invoice(amount, "tiny.{}".format(i), "tiny")["bolt11"]
486 pay_status = l1.rpc.pay(bolt11)
487 assert pay_status["amount_msat"] == Millisatoshi(amount)
488
489 # shadow routes are random, so run multiple times.
490 for i in range(5):
491 # A bigger amount, shadow routing could have been used but we set a low
492 # maxfeepercent.
493 amount = 20000
494 bolt11 = l2.rpc.invoice(amount, "big.{}".format(i), "bigger")["bolt11"]
495 pay_status = l1.rpc.pay(bolt11, maxfeepercent=0.001)
496 assert pay_status["amount_msat"] == Millisatoshi(amount)
497
498
499def test_sendpay(node_factory):

Callers

nothing calls this directly

Calls 6

wait_forFunction · 0.90
MillisatoshiClass · 0.90
line_graphMethod · 0.80
listchannelsMethod · 0.45
invoiceMethod · 0.45
payMethod · 0.45

Tested by

no test coverage detected