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

Function test_rune_bolt11_parse

tests/test_runes.py:728–845  ·  view source on GitHub ↗
(node_factory)

Source from the content-addressed store, hash-verified

726
727
728def test_rune_bolt11_parse(node_factory):
729 l1 = node_factory.get_node()
730 # Simple
731 inv = l1.rpc.invoice(1, "inv", "inv")['bolt11']
732 # No amount
733 inv_no_amount = l1.rpc.invoice("any", "inv_no_amount", "inv_no_amount")['bolt11']
734 # No description
735 inv_no_description = l1.rpc.invoice(2, "inv_no_description", "inv_no_description", deschashonly=True)['bolt11']
736
737 rune_amount_1 = l1.rpc.createrune(restrictions=[['pinvbolt11_amount=1']])['rune']
738 rune_no_amount = l1.rpc.createrune(restrictions=[['pinvbolt11_amount!']])['rune']
739 rune_desc_inv = l1.rpc.createrune(restrictions=[['pinvbolt11_description=inv']])['rune']
740 rune_no_desc = l1.rpc.createrune(restrictions=[['pinvbolt11_description!']])['rune']
741 rune_node_l1 = l1.rpc.createrune(restrictions=[['pinvbolt11_node=' + l1.info['id']]])['rune']
742
743 # parameter (bolt11) must exist
744 for r in [rune_amount_1, rune_no_amount, rune_desc_inv, rune_no_desc, rune_node_l1]:
745 with pytest.raises(RpcError, match='Not permitted: Unknown invoice parameter bolt11'):
746 l1.rpc.checkrune(nodeid=l1.info['id'],
747 rune=r,
748 method='pay',
749 params={'bolt11x': inv})
750
751 # parameter must be valid invoice
752 for r in [rune_amount_1, rune_no_amount, rune_desc_inv, rune_no_desc, rune_node_l1]:
753 with pytest.raises(RpcError, match='Not permitted: Invalid invoice: '):
754 l1.rpc.checkrune(nodeid=l1.info['id'],
755 rune=r,
756 method='pay',
757 params={'bolt11': 'xxx'})
758
759 # Rune amount_1 success:
760 l1.rpc.checkrune(nodeid=l1.info['id'],
761 rune=rune_amount_1,
762 method='pay',
763 params={'bolt11': inv})
764
765 # Also with lightning: prefix (both cases)
766 l1.rpc.checkrune(nodeid=l1.info['id'],
767 rune=rune_amount_1,
768 method='pay',
769 params={'bolt11': 'lightning:' + inv})
770
771 l1.rpc.checkrune(nodeid=l1.info['id'],
772 rune=rune_amount_1,
773 method='pay',
774 params={'bolt11': 'LIGHTNING:' + inv})
775
776 # Rune amount_1 fail (no amount)
777 with pytest.raises(RpcError, match='Not permitted: invoice parameter bolt11_amount not present'):
778 l1.rpc.checkrune(nodeid=l1.info['id'],
779 rune=rune_amount_1,
780 method='pay',
781 params={'bolt11': inv_no_amount})
782
783 # Rune amount_1 fail (wrong amount)
784 with pytest.raises(RpcError, match='Not permitted: invoice parameter bolt11_amount is not equal to 1'):
785 l1.rpc.checkrune(nodeid=l1.info['id'],

Callers

nothing calls this directly

Calls 2

get_nodeMethod · 0.45
invoiceMethod · 0.45

Tested by

no test coverage detected