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

Function test_createproof_include

tests/test_pay.py:7367–7403  ·  view source on GitHub ↗

Proof with custom include list: only requested fields appear.

(node_factory, bitcoind)

Source from the content-addressed store, hash-verified

7365
7366
7367def test_createproof_include(node_factory, bitcoind):
7368 """Proof with custom include list: only requested fields appear."""
7369 l1, l2, l3 = node_factory.line_graph(3, wait_for_announce=True,
7370 opts=[{},
7371 {'dev-allow-localhost': None},
7372 {'dev-allow-localhost': None}])
7373
7374 offer = l3.rpc.offer('10000msat', 'include test')
7375 inv = l1.rpc.fetchinvoice(offer['bolt12'])['invoice']
7376 l1.rpc.xpay(inv)
7377
7378 # Include only invoice_amount by name, plus the mandatory fields.
7379 ret = l1.rpc.call('createproof', {'invstring': inv,
7380 'include': ['invoice_amount']})
7381 proof = only_one(ret['proofs'])
7382
7383 # Mandatory fields always present.
7384 assert 'invreq_payer_id' in proof['invreq_fields_included']
7385 assert 'invoice_payment_hash' in proof['invoice_fields_included']
7386 assert 'invoice_features' in proof['invoice_fields_included']
7387 assert 'invoice_node_id' in proof['invoice_fields_included']
7388 assert 'signature' in proof['invoice_fields_included']
7389
7390 # invoice_amount is there; but offer_description is not (not in our include list).
7391 assert 'invoice_amount' in proof['invoice_fields_included']
7392 assert 'offer_description' not in proof['offer_fields_included']
7393
7394 decoded = l1.rpc.decode(proof['bolt12'])
7395 assert decoded['valid'] is True
7396
7397 # Include by number works too (170 = invoice_amount).
7398 ret2 = l1.rpc.call('createproof', {'invstring': inv, 'include': [170]})
7399 assert only_one(ret2['proofs'])['bolt12'] == proof['bolt12']
7400
7401 # Unknown name is an error.
7402 with pytest.raises(RpcError, match=r'Unknown field name'):
7403 l1.rpc.call('createproof', {'invstring': inv, 'include': ['no_such_field']})
7404
7405
7406def _pyln_has_inline_plugin():

Callers

nothing calls this directly

Calls 7

only_oneFunction · 0.90
line_graphMethod · 0.80
fetchinvoiceMethod · 0.80
offerMethod · 0.45
xpayMethod · 0.45
callMethod · 0.45
decodeMethod · 0.45

Tested by

no test coverage detected