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

Function test_offer_fronting

tests/test_invoices.py:1113–1140  ·  view source on GitHub ↗
(node_factory)

Source from the content-addressed store, hash-verified

1111
1112
1113def test_offer_fronting(node_factory):
1114 # l1 -> l2 -> l3
1115 # \ /
1116 # l4
1117 # Nodes will not front for offers if they don't have an advertized address.
1118 l1, l2, l3, l4 = node_factory.get_nodes(4, opts={'dev-allow-localhost': None})
1119 node_factory.join_nodes([l1, l2, l3], wait_for_announce=True)
1120 node_factory.join_nodes([l2, l4], wait_for_announce=True)
1121 node_factory.join_nodes([l3, l4], wait_for_announce=True)
1122
1123 offer_nofront = l4.rpc.offer("any", "nofront")['bolt12']
1124 assert 'offer_paths' not in l1.rpc.decode(offer_nofront)
1125 offer_front_l2 = l4.rpc.offer("any", "frontl2", fronting_nodes=[l2.info['id']])['bolt12']
1126 assert only_one(l1.rpc.decode(offer_front_l2)['offer_paths'])['first_node_id'] == l2.info['id']
1127 offer_front_l2l3 = l4.rpc.offer("any", "frontl2l3", fronting_nodes=[l2.info['id'], l3.info['id']])['bolt12']
1128 assert [p['first_node_id'] for p in l1.rpc.decode(offer_front_l2l3)['offer_paths']] == [l2.info['id'], l3.info['id']]
1129
1130 inv_nofront = l1.rpc.fetchinvoice(offer_nofront, 1)['invoice']
1131 assert only_one(l1.rpc.decode(inv_nofront)['invoice_paths'])['first_node_id'] == l4.info['id']
1132 l1.rpc.xpay(inv_nofront)
1133
1134 inv_front_l2 = l1.rpc.fetchinvoice(offer_front_l2, 2)['invoice']
1135 assert only_one(l1.rpc.decode(inv_front_l2)['invoice_paths'])['first_node_id'] == l2.info['id']
1136 l1.rpc.xpay(inv_front_l2)
1137
1138 inv_front_l2l3 = l1.rpc.fetchinvoice(offer_front_l2l3, 3)['invoice']
1139 assert only_one(l1.rpc.decode(inv_front_l2l3)['invoice_paths'])['first_node_id'] in (l2.info['id'], l3.info['id'])
1140 l1.rpc.xpay(inv_front_l2l3)
1141
1142
1143def test_invoice_maxdesc(node_factory, chainparams):

Callers

nothing calls this directly

Calls 7

only_oneFunction · 0.90
get_nodesMethod · 0.80
join_nodesMethod · 0.80
fetchinvoiceMethod · 0.80
offerMethod · 0.45
decodeMethod · 0.45
xpayMethod · 0.45

Tested by

no test coverage detected