(node_factory, executor)
| 359 | @pytest.mark.openchannel('v1') |
| 360 | @pytest.mark.openchannel('v2') |
| 361 | def test_xpay_partial_msat(node_factory, executor): |
| 362 | l1, l2, l3 = node_factory.line_graph(3) |
| 363 | |
| 364 | inv = l3.rpc.invoice(100000000, "inv", "inv") |
| 365 | |
| 366 | with pytest.raises(RpcError, match="partial_msat must be less or equal to total amount 10000000"): |
| 367 | l2.rpc.xpay(invstring=inv['bolt11'], partial_msat=100000001) |
| 368 | |
| 369 | # This will fail with an MPP timeout. |
| 370 | with pytest.raises(RpcError, match=r"Timed out after after 1 attempts\. Payment of 90000000msat reached destination, but timed out before the rest arrived\."): |
| 371 | l2.rpc.xpay(invstring=inv['bolt11'], partial_msat=90000000) |
| 372 | |
| 373 | # This will work like normal. |
| 374 | l2.rpc.xpay(invstring=inv['bolt11'], partial_msat=100000000) |
| 375 | |
| 376 | # Make sure l3 can pay to l2 now. |
| 377 | wait_for(lambda: only_one(l3.rpc.listpeerchannels()['channels'])['spendable_msat'] > 1001) |
| 378 | |
| 379 | # Now we can combine together to pay l2: |
| 380 | inv = l2.rpc.invoice('any', "inv", "inv") |
| 381 | |
| 382 | # If we specify different totals, this *won't work* |
| 383 | l1pay = executor.submit(l1.rpc.xpay, invstring=inv['bolt11'], amount_msat=10000, partial_msat=9000) |
| 384 | l3pay = executor.submit(l3.rpc.xpay, invstring=inv['bolt11'], amount_msat=10001, partial_msat=1001) |
| 385 | |
| 386 | # BOLT #4: |
| 387 | # - SHOULD fail the entire HTLC set if `total_msat` is not |
| 388 | # the same for all HTLCs in the set. |
| 389 | with pytest.raises(RpcError, match=r"Unexpected error \(final_incorrect_htlc_amount\) from final node"): |
| 390 | l3pay.result(TIMEOUT) |
| 391 | with pytest.raises(RpcError, match=r"Unexpected error \(final_incorrect_htlc_amount\) from final node"): |
| 392 | l1pay.result(TIMEOUT) |
| 393 | |
| 394 | # But same amount, will combine forces! |
| 395 | l1pay = executor.submit(l1.rpc.xpay, invstring=inv['bolt11'], amount_msat=10000, partial_msat=9000) |
| 396 | l3pay = executor.submit(l3.rpc.xpay, invstring=inv['bolt11'], amount_msat=10000, partial_msat=1000) |
| 397 | |
| 398 | l1pay.result(TIMEOUT) |
| 399 | l3pay.result(TIMEOUT) |
| 400 | |
| 401 | |
| 402 | def test_xpay_takeover(node_factory, executor): |
nothing calls this directly
no test coverage detected