Uses the htlc_accepted hook response value `invoice_msat` to override the expected total payment amount of the invoice.
(node_factory)
| 7246 | |
| 7247 | |
| 7248 | def 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 | |
| 7277 | def test_offer_currency_no_amount(node_factory): |
nothing calls this directly
no test coverage detected