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

Function test_injectpaymentonion_mpp

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

Source from the content-addressed store, hash-verified

6279
6280
6281def test_injectpaymentonion_mpp(node_factory, executor):
6282 l1, l2 = node_factory.line_graph(2)
6283
6284 blockheight = l1.rpc.getinfo()['blockheight']
6285 inv2 = l2.rpc.invoice(3000, "test_injectpaymentonion2", "test_injectpaymentonion2")
6286
6287 # First hop for injectpaymentonion is self.
6288 hops1 = [{'pubkey': l1.info['id'],
6289 'payload': serialize_payload_tlv(1000, 18 + 6, first_scid(l1, l2), blockheight).hex()},
6290 {'pubkey': l2.info['id'],
6291 'payload': serialize_payload_final_tlv(1000, 18, 3000, blockheight, inv2['payment_secret']).hex()}]
6292 onion1 = l1.rpc.createonion(hops=hops1, assocdata=inv2['payment_hash'])
6293 hops2 = [{'pubkey': l1.info['id'],
6294 'payload': serialize_payload_tlv(2000, 18 + 6, first_scid(l1, l2), blockheight).hex()},
6295 {'pubkey': l2.info['id'],
6296 'payload': serialize_payload_final_tlv(2000, 18, 3000, blockheight, inv2['payment_secret']).hex()}]
6297 onion2 = l1.rpc.createonion(hops=hops2, assocdata=inv2['payment_hash'])
6298
6299 fut1 = executor.submit(l1.rpc.injectpaymentonion,
6300 onion1['onion'],
6301 inv2['payment_hash'],
6302 1000,
6303 blockheight + 18 + 6,
6304 1,
6305 0)
6306 # Test destination storage while we're here.
6307 fut2 = executor.submit(l1.rpc.injectpaymentonion,
6308 onion=onion2['onion'],
6309 payment_hash=inv2['payment_hash'],
6310 amount_msat=2000,
6311 cltv_expiry=blockheight + 18 + 6,
6312 partid=2,
6313 groupid=0,
6314 destination=l2.info['id'])
6315
6316 # Now both should complete.
6317 ret = fut1.result(TIMEOUT)
6318 assert sha256(bytes.fromhex(ret['payment_preimage'])).hexdigest() == inv2['payment_hash']
6319 ret = fut2.result(TIMEOUT)
6320 assert sha256(bytes.fromhex(ret['payment_preimage'])).hexdigest() == inv2['payment_hash']
6321
6322 assert only_one(l2.rpc.listinvoices("test_injectpaymentonion2")['invoices'])['status'] == 'paid'
6323 lsps = l1.rpc.listsendpays(inv2['bolt11'])['payments']
6324 for lsp in lsps:
6325 assert lsp['groupid'] == 0
6326 assert lsp['partid'] == 1 or lsp['partid'] == 2
6327 assert lsp['payment_hash'] == inv2['payment_hash']
6328 assert lsp['status'] == 'complete'
6329 assert 'amount_msat' not in lsp
6330 if lsp['partid'] == 1:
6331 assert 'destination' not in lsp
6332 else:
6333 assert lsp['destination'] == l2.info['id']
6334 assert len(lsps) == 2
6335
6336
6337def 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