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

Function test_offer_path_self

tests/test_pay.py:6052–6091  ·  view source on GitHub ↗

We can fetch an offer, and pay an invoice which uses a blinded path starting at us

(node_factory)

Source from the content-addressed store, hash-verified

6050
6051
6052def test_offer_path_self(node_factory):
6053 """We can fetch an offer, and pay an invoice which uses a blinded path starting at us"""
6054 l1, l2, l3 = node_factory.line_graph(3, fundchannel=False,
6055 opts={'may_reconnect': True})
6056
6057 # Private channel from l2->l3, makes l3 add a hint.
6058 node_factory.join_nodes([l1, l2], wait_for_announce=True)
6059 node_factory.join_nodes([l2, l3], announce_channels=False)
6060 wait_for(lambda: ['alias' in n for n in l3.rpc.listnodes()['nodes']] == [True, True])
6061
6062 # l3 uses l2 as entry point for offer.
6063 offer = l3.rpc.offer(amount='2msat', description='test_offer_path_self')
6064 paths = l1.rpc.decode(offer['bolt12'])['offer_paths']
6065 assert len(paths) == 1
6066 assert paths[0]['first_node_id'] == l2.info['id']
6067
6068 # l1 can fetch invoice.
6069 l1.rpc.fetchinvoice(offer['bolt12'])['invoice']
6070
6071 # l2 can fetch invoice
6072 inv = l2.rpc.fetchinvoice(offer['bolt12'])['invoice']
6073
6074 # And can pay it!
6075 l2.rpc.pay(inv)
6076
6077 # We can also handle it if invoice has next hop specified by real scid, or alias.
6078 scid = only_one(l2.rpc.listpeerchannels(l3.info['id'])['channels'])['alias']['local']
6079
6080 l3.stop()
6081 l3.daemon.opts['dev-invoice-internal-scid'] = scid
6082 l3.start()
6083 l2.rpc.connect(l3.info['id'], 'localhost', l3.port)
6084
6085 inv = l2.rpc.fetchinvoice(offer['bolt12'])['invoice']
6086
6087 # And can pay it!
6088 l2.rpc.pay(inv)
6089
6090 # It should have mapped the hop.
6091 l2.daemon.wait_for_log(f"injectpaymentonion: sending to channel {scid}")
6092
6093
6094def test_offer_selfpay(node_factory):

Callers

nothing calls this directly

Calls 14

wait_forFunction · 0.90
only_oneFunction · 0.90
line_graphMethod · 0.80
join_nodesMethod · 0.80
fetchinvoiceMethod · 0.80
listpeerchannelsMethod · 0.80
wait_for_logMethod · 0.80
listnodesMethod · 0.45
offerMethod · 0.45
decodeMethod · 0.45
payMethod · 0.45
stopMethod · 0.45

Tested by

no test coverage detected