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

Function test_offer_experimental_fields

tests/test_pay.py:6132–6150  ·  view source on GitHub ↗
(node_factory)

Source from the content-addressed store, hash-verified

6130
6131
6132def test_offer_experimental_fields(node_factory):
6133 l1, l2 = node_factory.line_graph(2)
6134
6135 # Append experimental type 1000000001, length 1
6136 offer = l1.rpc.offer(amount='2msat', description='test_offer_path_self')['bolt12']
6137 bolt12tool = os.path.join(os.path.dirname(__file__), "..", "devtools", "bolt12-cli")
6138 # Returns HRP and hex
6139 as_hex = subprocess.check_output([bolt12tool, 'decodehex', offer]).decode('UTF-8').split()
6140 mangled = subprocess.check_output([bolt12tool, 'encodehex', as_hex[0], as_hex[1] + 'FE3B9ACA01' '01' '00']).decode('UTF-8').strip()
6141
6142 assert l1.rpc.decode(mangled)['unknown_offer_tlvs'] == [{'type': 1000000001, 'length': 1, 'value': '00'}]
6143
6144 # This will fail (offer has added field!)
6145 with pytest.raises(RpcError, match="Unknown offer"):
6146 l2.rpc.fetchinvoice(mangled)
6147
6148 # invice request contains the unknown field
6149 m = re.search(r'invoice_request: "([a-z0-9]*)"', l2.daemon.is_in_log('invoice_request:'))
6150 assert l1.rpc.decode(m.group(1))['unknown_invoice_request_tlvs'] == [{'type': 1000000001, 'length': 1, 'value': '00'}]
6151
6152
6153def test_fetch_no_description_offer(node_factory):

Callers

nothing calls this directly

Calls 6

line_graphMethod · 0.80
joinMethod · 0.80
fetchinvoiceMethod · 0.80
is_in_logMethod · 0.80
offerMethod · 0.45
decodeMethod · 0.45

Tested by

no test coverage detected