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

Function test_fetchinvoice_with_no_quantity

tests/test_pay.py:5570–5592  ·  view source on GitHub ↗

Reproducer for https://github.com/ElementsProject/lightning/issues/6089 The issue is when the offer has the quantity_max and the parameter. In particular, in the fetchinvoice we forget to map the quantity parameter with the invoice request quantity field.

(node_factory)

Source from the content-addressed store, hash-verified

5568
5569
5570def test_fetchinvoice_with_no_quantity(node_factory):
5571 """
5572 Reproducer for https://github.com/ElementsProject/lightning/issues/6089
5573
5574 The issue is when the offer has the quantity_max and the parameter.
5575
5576 In particular, in the fetchinvoice we forget to map the
5577 quantity parameter with the invoice request quantity field.
5578 """
5579 l1, l2 = node_factory.line_graph(2, wait_for_announce=True)
5580 offer1 = l2.rpc.call('offer', {'amount': '2msat',
5581 'description': 'simple test',
5582 'quantity_max': 10})
5583
5584 assert offer1['created'] is True, f"offer created is {offer1['created']}"
5585
5586 with pytest.raises(RpcError, match="quantity parameter required"):
5587 l1.rpc.call('fetchinvoice', {'offer': offer1['bolt12']})
5588
5589 inv = l1.rpc.call('fetchinvoice', {'offer': offer1['bolt12'], 'quantity': 2})
5590 inv = inv['invoice']
5591 decode_inv = l2.rpc.decode(inv)
5592 assert decode_inv['invreq_quantity'] == 2, f'`invreq_quantity` in the invoice did not match, received {decode_inv["quantity"]}, expected 2'
5593
5594
5595def test_invoice_pay_desc_with_quotes(node_factory):

Callers

nothing calls this directly

Calls 3

line_graphMethod · 0.80
callMethod · 0.45
decodeMethod · 0.45

Tested by

no test coverage detected