(node_factory)
| 846 | |
| 847 | |
| 848 | def test_rune_bolt12_parse(node_factory): |
| 849 | l1, l2 = node_factory.line_graph(2) |
| 850 | |
| 851 | # Two invoices. |
| 852 | l1inv_1msat = l2.rpc.fetchinvoice(l1.rpc.offer(1, "inv_1msat")['bolt12'])['invoice'] |
| 853 | l1inv_2msat = l2.rpc.fetchinvoice(l1.rpc.offer(2, "inv_2msat")['bolt12'])['invoice'] |
| 854 | |
| 855 | rune_amount_1 = l1.rpc.createrune(restrictions=[['pinvbolt11_amount=1']])['rune'] |
| 856 | rune_no_amount = l1.rpc.createrune(restrictions=[['pinvbolt11_amount!']])['rune'] |
| 857 | rune_desc_inv = l1.rpc.createrune(restrictions=[['pinvbolt11_description=inv_1msat']])['rune'] |
| 858 | rune_no_desc = l1.rpc.createrune(restrictions=[['pinvbolt11_description!']])['rune'] |
| 859 | rune_node_l1 = l1.rpc.createrune(restrictions=[['pinvbolt11_node=' + l1.info['id']]])['rune'] |
| 860 | |
| 861 | # parameter must be valid invoice |
| 862 | for r in [rune_amount_1, rune_no_amount, rune_desc_inv, rune_no_desc, rune_node_l1]: |
| 863 | with pytest.raises(RpcError, match='Not permitted: Invalid invoice: '): |
| 864 | l1.rpc.checkrune(nodeid=l1.info['id'], |
| 865 | rune=r, |
| 866 | method='pay', |
| 867 | params={'bolt11': 'lnixxx'}) |
| 868 | |
| 869 | # Rune amount_1 success: |
| 870 | l1.rpc.checkrune(nodeid=l1.info['id'], |
| 871 | rune=rune_amount_1, |
| 872 | method='pay', |
| 873 | params={'bolt11': l1inv_1msat}) |
| 874 | |
| 875 | # Rune amount_1 fail (wrong amount) |
| 876 | with pytest.raises(RpcError, match='Not permitted: invoice parameter bolt11_amount is not equal to 1'): |
| 877 | l1.rpc.checkrune(nodeid=l1.info['id'], |
| 878 | rune=rune_amount_1, |
| 879 | method='pay', |
| 880 | params={'bolt11': l1inv_2msat}) |
| 881 | |
| 882 | # Rune no_amount fail (bolt12 invoice always has amount) |
| 883 | with pytest.raises(RpcError, match='Not permitted: invoice parameter bolt11_amount is present'): |
| 884 | l1.rpc.checkrune(nodeid=l1.info['id'], |
| 885 | rune=rune_no_amount, |
| 886 | method='pay', |
| 887 | params={'bolt11': l1inv_1msat}) |
| 888 | |
| 889 | # Rune desc success: |
| 890 | l1.rpc.checkrune(nodeid=l1.info['id'], |
| 891 | rune=rune_desc_inv, |
| 892 | method='pay', |
| 893 | params={'bolt11': l1inv_1msat}) |
| 894 | |
| 895 | # Rune desc fail (wrong description) |
| 896 | with pytest.raises(RpcError, match='Not permitted: invoice parameter bolt11_description is not equal to inv_1msat'): |
| 897 | l1.rpc.checkrune(nodeid=l1.info['id'], |
| 898 | rune=rune_desc_inv, |
| 899 | method='pay', |
| 900 | params={'bolt11': l1inv_2msat}) |
| 901 | |
| 902 | # Rune no_desc fail (has description) |
| 903 | with pytest.raises(RpcError, match='Not permitted: invoice parameter bolt11_description is present'): |
| 904 | l1.rpc.checkrune(nodeid=l1.info['id'], |
| 905 | rune=rune_no_desc, |
nothing calls this directly
no test coverage detected