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

Function test_invoice_amount_override

tests/test_pay.py:7248–7274  ·  view source on GitHub ↗

Uses the htlc_accepted hook response value `invoice_msat` to override the expected total payment amount of the invoice.

(node_factory)

Source from the content-addressed store, hash-verified

7246
7247
7248def test_invoice_amount_override(node_factory):
7249 """Uses the htlc_accepted hook response value `invoice_msat` to override
7250 the expected total payment amount of the invoice.
7251 """
7252 plugin = os.path.join(os.path.dirname(__file__), "plugins/override_invoice_msat.py")
7253 l1, l2 = node_factory.line_graph(2, opts=[{}, {"plugin": plugin}])
7254
7255 inv = l2.rpc.invoice(10_000, "expected_amt_override", "expected_amt_override")
7256
7257 route = [
7258 {
7259 "amount_msat": 1_000, # Reduced amount that is below the expected amount
7260 "id": l2.info["id"],
7261 "delay": 10,
7262 "channel": first_scid(l1, l2),
7263 }
7264 ]
7265
7266 with pytest.raises(RpcError):
7267 l1.rpc.sendpay(route, inv["payment_hash"], payment_secret=inv["payment_secret"])
7268 l1.rpc.waitsendpay(inv["payment_hash"])
7269
7270 # Override expected invoice amount, via htlc_accepted.
7271 l2.rpc.setinvoicemsat(msat=1_000)
7272
7273 l1.rpc.sendpay(route, inv["payment_hash"], payment_secret=inv["payment_secret"])
7274 assert l1.rpc.waitsendpay(inv["payment_hash"])["status"] == "complete"
7275
7276
7277def test_offer_currency_no_amount(node_factory):

Callers

nothing calls this directly

Calls 6

first_scidFunction · 0.90
joinMethod · 0.80
line_graphMethod · 0.80
sendpayMethod · 0.80
waitsendpayMethod · 0.80
invoiceMethod · 0.45

Tested by

no test coverage detected