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

Function test_blindedpath_privchan

tests/test_pay.py:5873–5915  ·  view source on GitHub ↗
(node_factory, bitcoind)

Source from the content-addressed store, hash-verified

5871
5872
5873def test_blindedpath_privchan(node_factory, bitcoind):
5874 l1, l2 = node_factory.line_graph(2, wait_for_announce=True,
5875 opts={'may_reconnect': True,
5876 'dev-allow-localhost': None})
5877 l3 = node_factory.get_node(options={'cltv-final': 120,
5878 'dev-allow-localhost': None},
5879 may_reconnect=True)
5880
5881 # Private channel.
5882 node_factory.join_nodes([l2, l3], announce_channels=False)
5883 # Make sure l3 knows about l1-l2, so will add route hint.
5884 wait_for(lambda: l3.rpc.listnodes(l1.info['id']) != {'nodes': []})
5885
5886 offer = l3.rpc.offer(1000, 'test_pay_blindedpath_privchan')
5887 l1.rpc.decode(offer['bolt12'])
5888
5889 inv = l2.rpc.fetchinvoice(offer['bolt12'])
5890 decode = l1.rpc.decode(inv['invoice'])
5891 assert len(decode['invoice_paths']) == 1
5892 assert decode['invoice_paths'][0]['first_node_id'] == l2.info['id']
5893
5894 # Carla points out that the path's cltv_expiry_delta *includes*
5895 # the final node's final value.
5896 assert decode['invoice_paths'][0]['payinfo']['cltv_expiry_delta'] == l3.config('cltv-final') + l2.config('cltv-delta')
5897
5898 l1.rpc.pay(inv['invoice'])
5899
5900 # Now try when l3 uses scid for entry point of blinded path.
5901 l3.stop()
5902 l3.daemon.opts['dev-invoice-bpath-scid'] = None
5903 l3.start()
5904 wait_for(lambda: [p['connected'] for p in l3.rpc.listpeers(l2.info['id'])['peers']] == [True])
5905
5906 chan = only_one(l1.rpc.listchannels(source=l2.info['id'])['channels'])
5907
5908 inv = l2.rpc.fetchinvoice(offer['bolt12'])
5909 decode = l1.rpc.decode(inv['invoice'])
5910 assert len(decode['invoice_paths']) == 1
5911 assert 'first_node_id' not in decode['invoice_paths'][0]
5912 assert decode['invoice_paths'][0]['first_scid'] == chan['short_channel_id']
5913 assert decode['invoice_paths'][0]['first_scid_dir'] == chan['direction']
5914
5915 l1.rpc.pay(inv['invoice'])
5916
5917
5918def test_blindedpath_noaddr(node_factory, bitcoind):

Callers

nothing calls this directly

Calls 15

wait_forFunction · 0.90
only_oneFunction · 0.90
line_graphMethod · 0.80
join_nodesMethod · 0.80
fetchinvoiceMethod · 0.80
configMethod · 0.80
get_nodeMethod · 0.45
listnodesMethod · 0.45
offerMethod · 0.45
decodeMethod · 0.45
payMethod · 0.45
stopMethod · 0.45

Tested by

no test coverage detected