Test the processing of the payment description interface.
(node_factory)
| 802 | |
| 803 | |
| 804 | def test_description(node_factory): |
| 805 | """Test the processing of the payment description interface.""" |
| 806 | l1, l2 = node_factory.line_graph(2, opts={'allow-deprecated-apis': True}) |
| 807 | |
| 808 | # do not provide description in the command line, all payments should be |
| 809 | # fine |
| 810 | inv_with_desc = l2.rpc.invoice( |
| 811 | "100sat", "desctest1", "paying for pizza", deschashonly=False |
| 812 | )["bolt11"] |
| 813 | inv_with_hash = l2.rpc.invoice( |
| 814 | "100sat", "desctest2", "paying for coffee", deschashonly=True |
| 815 | )["bolt11"] |
| 816 | |
| 817 | details = l1.rpc.call("renepay", {"invstring": inv_with_desc}) |
| 818 | assert details["status"] == "complete" |
| 819 | details = l1.rpc.call("renepay", {"invstring": inv_with_hash}) |
| 820 | assert details["status"] == "complete" |
| 821 | |
| 822 | # pass a description in the command line, should check if the hash matches |
| 823 | inv_with_desc = l2.rpc.invoice( |
| 824 | "100sat", "desctest3", "paying for pizza", deschashonly=False |
| 825 | )["bolt11"] |
| 826 | inv_with_hash = l2.rpc.invoice( |
| 827 | "100sat", "desctest4", "paying for coffee", deschashonly=True |
| 828 | )["bolt11"] |
| 829 | |
| 830 | details = l1.rpc.call( |
| 831 | "renepay", {"invstring": inv_with_desc, "description": "paying for pizza"} |
| 832 | ) |
| 833 | assert details["status"] == "complete" |
| 834 | |
| 835 | # if the description does not match the hash in the invoice, we fail |
| 836 | with pytest.raises(RpcError, match=r"h: does not match description"): |
| 837 | l1.rpc.call( |
| 838 | "renepay", {"invstring": inv_with_hash, "description": "paying for cookies"} |
| 839 | ) |
| 840 | |
| 841 | details = l1.rpc.call( |
| 842 | "renepay", {"invstring": inv_with_hash, "description": "paying for coffee"} |
| 843 | ) |
| 844 | assert details["status"] == "complete" |
| 845 | |
| 846 | |
| 847 | def test_offers(node_factory): |
nothing calls this directly
no test coverage detected