Test preapprove calls implicitly made by pay and keysend
(node_factory, bitcoind, xkeysend)
| 5104 | |
| 5105 | @pytest.mark.parametrize("xkeysend", [False, True]) |
| 5106 | def test_preapprove_use(node_factory, bitcoind, xkeysend): |
| 5107 | """Test preapprove calls implicitly made by pay and keysend""" |
| 5108 | l1, l2 = node_factory.line_graph(2, opts=[{}, {'dev-hsmd-fail-preapprove': None, |
| 5109 | 'allow-deprecated-apis': True}]) |
| 5110 | |
| 5111 | # Create some balance, make sure it's entirely settled. |
| 5112 | l1.pay(l2, 200000000) |
| 5113 | wait_for(lambda: only_one(l2.rpc.listpeerchannels()['channels'])['htlcs'] == []) |
| 5114 | |
| 5115 | # This will fail at the preapprove step. |
| 5116 | inv = l1.rpc.invoice(123000, 'label', 'description', 3700)['bolt11'] |
| 5117 | with pytest.raises(RpcError, match='invoice was declined'): |
| 5118 | l2.rpc.xpay(inv) |
| 5119 | |
| 5120 | # This will fail the same way |
| 5121 | with pytest.raises(RpcError, match='invoice was declined'): |
| 5122 | l2.rpc.check('xpay', invstring=inv) |
| 5123 | |
| 5124 | # Now keysend. |
| 5125 | with pytest.raises(RpcError, match='keysend was declined'): |
| 5126 | if xkeysend: |
| 5127 | l2.rpc.xkeysend(l1.info['id'], 1000) |
| 5128 | else: |
| 5129 | l2.rpc.keysend(l1.info['id'], 1000) |
| 5130 | with pytest.raises(RpcError, match='keysend was declined'): |
| 5131 | if xkeysend: |
| 5132 | l2.rpc.check('xkeysend', destination=l1.info['id'], amount_msat=1000) |
| 5133 | else: |
| 5134 | l2.rpc.check('keysend', destination=l1.info['id'], amount_msat=1000) |
| 5135 | |
| 5136 | |
| 5137 | def test_badparam_discretion(node_factory): |
nothing calls this directly
no test coverage detected