Check that renepay can complete a payment that already started
(node_factory, bitcoind)
| 511 | |
| 512 | @unittest.skip |
| 513 | def test_previous_sendpays(node_factory, bitcoind): |
| 514 | """ |
| 515 | Check that renepay can complete a payment that already started |
| 516 | """ |
| 517 | opts = [ |
| 518 | {"disable-mpp": None, "fee-base": 1000, "fee-per-satoshi": 1000, 'allow-deprecated-apis': True}, |
| 519 | ] |
| 520 | l1, l2, l3, l4 = node_factory.line_graph(4, wait_for_announce=True, opts=opts * 4) |
| 521 | |
| 522 | # First case, do not overpay a pending MPP payment |
| 523 | invstr = l3.rpc.invoice("100000sat", "inv1", "description")["bolt11"] |
| 524 | inv = l1.rpc.decode(invstr) |
| 525 | route = l1.rpc.call( |
| 526 | "getroute", {"id": inv["payee"], "amount_msat": "50000sat", "riskfactor": 10} |
| 527 | ) |
| 528 | # we start a MPP payment |
| 529 | l1.rpc.call( |
| 530 | "sendpay", |
| 531 | { |
| 532 | "route": route["route"], |
| 533 | "payment_hash": inv["payment_hash"], |
| 534 | "payment_secret": inv["payment_secret"], |
| 535 | "amount_msat": "100000sat", |
| 536 | "groupid": 1, |
| 537 | "partid": 1, |
| 538 | }, |
| 539 | ) |
| 540 | # while it is pending, we try to complete it with renepay |
| 541 | l1.rpc.call("renepay", {"invstring": invstr}) |
| 542 | invoice = only_one(l3.rpc.listinvoices("inv1")["invoices"]) |
| 543 | # the receive amount should be exact |
| 544 | assert invoice["amount_received_msat"] == Millisatoshi("100000sat") |
| 545 | |
| 546 | # Second case, do not collide with failed sendpays |
| 547 | invstr = l3.rpc.invoice("100000sat", "inv2", "description")["bolt11"] |
| 548 | inv = l1.rpc.decode(invstr) |
| 549 | route = l1.rpc.call( |
| 550 | "getroute", {"id": inv["payee"], "amount_msat": "50000sat", "riskfactor": 10} |
| 551 | ) |
| 552 | |
| 553 | # load a plugin that fails all HTLCs |
| 554 | l2.rpc.call( |
| 555 | "plugin", |
| 556 | { |
| 557 | "subcommand": "start", |
| 558 | "plugin": os.path.join(os.getcwd(), "tests/plugins/fail_htlcs.py"), |
| 559 | }, |
| 560 | ) |
| 561 | l2.daemon.wait_for_log(r"^(?=.*plugin-manager.*fail_htlcs.py).*") |
| 562 | |
| 563 | # start a MPP payment that will fail at l2 |
| 564 | l1.rpc.call( |
| 565 | "sendpay", |
| 566 | { |
| 567 | "route": route["route"], |
| 568 | "payment_hash": inv["payment_hash"], |
| 569 | "payment_secret": inv["payment_secret"], |
| 570 | "amount_msat": "100000sat", |
nothing calls this directly
no test coverage detected