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

Function test_injectpaymentonion_mpp

tests/test_pay.py:6353–6406  ·  view source on GitHub ↗
(node_factory, executor)

Source from the content-addressed store, hash-verified

6351
6352
6353def test_injectpaymentonion_mpp(node_factory, executor):
6354 l1, l2 = node_factory.line_graph(2)
6355
6356 blockheight = l1.rpc.getinfo()['blockheight']
6357 inv2 = l2.rpc.invoice(3000, "test_injectpaymentonion2", "test_injectpaymentonion2")
6358
6359 # First hop for injectpaymentonion is self.
6360 hops1 = [{'pubkey': l1.info['id'],
6361 'payload': serialize_payload_tlv(1000, 18 + 6, first_scid(l1, l2), blockheight).hex()},
6362 {'pubkey': l2.info['id'],
6363 'payload': serialize_payload_final_tlv(1000, 18, 3000, blockheight, inv2['payment_secret']).hex()}]
6364 onion1 = l1.rpc.createonion(hops=hops1, assocdata=inv2['payment_hash'])
6365 hops2 = [{'pubkey': l1.info['id'],
6366 'payload': serialize_payload_tlv(2000, 18 + 6, first_scid(l1, l2), blockheight).hex()},
6367 {'pubkey': l2.info['id'],
6368 'payload': serialize_payload_final_tlv(2000, 18, 3000, blockheight, inv2['payment_secret']).hex()}]
6369 onion2 = l1.rpc.createonion(hops=hops2, assocdata=inv2['payment_hash'])
6370
6371 fut1 = executor.submit(l1.rpc.injectpaymentonion,
6372 onion1['onion'],
6373 inv2['payment_hash'],
6374 1000,
6375 blockheight + 18 + 6,
6376 1,
6377 0)
6378 # Test destination storage while we're here.
6379 fut2 = executor.submit(l1.rpc.injectpaymentonion,
6380 onion=onion2['onion'],
6381 payment_hash=inv2['payment_hash'],
6382 amount_msat=2000,
6383 cltv_expiry=blockheight + 18 + 6,
6384 partid=2,
6385 groupid=0,
6386 destination=l2.info['id'])
6387
6388 # Now both should complete.
6389 ret = fut1.result(TIMEOUT)
6390 assert sha256(bytes.fromhex(ret['payment_preimage'])).hexdigest() == inv2['payment_hash']
6391 ret = fut2.result(TIMEOUT)
6392 assert sha256(bytes.fromhex(ret['payment_preimage'])).hexdigest() == inv2['payment_hash']
6393
6394 assert only_one(l2.rpc.listinvoices("test_injectpaymentonion2")['invoices'])['status'] == 'paid'
6395 lsps = l1.rpc.listsendpays(inv2['bolt11'])['payments']
6396 for lsp in lsps:
6397 assert lsp['groupid'] == 0
6398 assert lsp['partid'] == 1 or lsp['partid'] == 2
6399 assert lsp['payment_hash'] == inv2['payment_hash']
6400 assert lsp['status'] == 'complete'
6401 assert 'amount_msat' not in lsp
6402 if lsp['partid'] == 1:
6403 assert 'destination' not in lsp
6404 else:
6405 assert lsp['destination'] == l2.info['id']
6406 assert len(lsps) == 2
6407
6408
6409def test_injectpaymentonion_3hop(node_factory, executor):

Callers

nothing calls this directly

Calls 10

serialize_payload_tlvFunction · 0.90
first_scidFunction · 0.90
only_oneFunction · 0.90
line_graphMethod · 0.80
listsendpaysMethod · 0.80
sha256Class · 0.50
getinfoMethod · 0.45
invoiceMethod · 0.45
listinvoicesMethod · 0.45

Tested by

no test coverage detected