(node_factory, executor)
| 6441 | |
| 6442 | |
| 6443 | def test_injectpaymentonion_selfpay(node_factory, executor): |
| 6444 | l1, l2 = node_factory.line_graph(2) |
| 6445 | |
| 6446 | blockheight = l1.rpc.getinfo()['blockheight'] |
| 6447 | |
| 6448 | # Test simple self-pay. |
| 6449 | inv4 = l1.rpc.invoice(1000, "test_injectpaymentonion4", "test_injectpaymentonion4") |
| 6450 | |
| 6451 | # First hop for injectpaymentonion is self. |
| 6452 | hops = [{'pubkey': l1.info['id'], |
| 6453 | 'payload': serialize_payload_final_tlv(1000, 18, 1000, blockheight, inv4['payment_secret']).hex()}] |
| 6454 | onion = l1.rpc.createonion(hops=hops, assocdata=inv4['payment_hash']) |
| 6455 | |
| 6456 | ret = l1.rpc.injectpaymentonion(onion=onion['onion'], |
| 6457 | payment_hash=inv4['payment_hash'], |
| 6458 | invstring=inv4['bolt11'], |
| 6459 | amount_msat=1000, |
| 6460 | cltv_expiry=blockheight + 18, |
| 6461 | partid=1, |
| 6462 | groupid=0) |
| 6463 | assert sha256(bytes.fromhex(ret['payment_preimage'])).hexdigest() == inv4['payment_hash'] |
| 6464 | assert only_one(l1.rpc.listinvoices("test_injectpaymentonion4")['invoices'])['status'] == 'paid' |
| 6465 | lsp = only_one(l1.rpc.listsendpays(inv4['bolt11'])['payments']) |
| 6466 | assert lsp['groupid'] == 0 |
| 6467 | assert lsp['partid'] == 1 |
| 6468 | assert lsp['payment_hash'] == inv4['payment_hash'] |
| 6469 | assert lsp['status'] == 'complete' |
| 6470 | assert lsp['destination'] == l1.info['id'] |
| 6471 | |
| 6472 | # Test self-pay with MPP. |
| 6473 | inv5 = l1.rpc.invoice(1000, "test_injectpaymentonion5", "test_injectpaymentonion5") |
| 6474 | |
| 6475 | # First hop for injectpaymentonion is self. |
| 6476 | hops1 = [{'pubkey': l1.info['id'], |
| 6477 | 'payload': serialize_payload_final_tlv(333, 18, 1000, blockheight, inv5['payment_secret']).hex()}] |
| 6478 | onion1 = l1.rpc.createonion(hops=hops1, assocdata=inv5['payment_hash']) |
| 6479 | hops2 = [{'pubkey': l1.info['id'], |
| 6480 | 'payload': serialize_payload_final_tlv(667, 18, 1000, blockheight, inv5['payment_secret']).hex()}] |
| 6481 | onion2 = l1.rpc.createonion(hops=hops2, assocdata=inv5['payment_hash']) |
| 6482 | |
| 6483 | fut1 = executor.submit(l1.rpc.injectpaymentonion, |
| 6484 | onion1['onion'], |
| 6485 | inv5['payment_hash'], |
| 6486 | 333, |
| 6487 | blockheight + 18, |
| 6488 | 1, |
| 6489 | 0) |
| 6490 | fut2 = executor.submit(l1.rpc.injectpaymentonion, |
| 6491 | onion2['onion'], |
| 6492 | inv5['payment_hash'], |
| 6493 | 667, |
| 6494 | blockheight + 18, |
| 6495 | 2, |
| 6496 | 0) |
| 6497 | # Now both should complete. |
| 6498 | ret = fut1.result(TIMEOUT) |
| 6499 | assert sha256(bytes.fromhex(ret['payment_preimage'])).hexdigest() == inv5['payment_hash'] |
| 6500 |
nothing calls this directly
no test coverage detected