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

Function test_preapprove_use

tests/test_misc.py:5106–5134  ·  view source on GitHub ↗

Test preapprove calls implicitly made by pay and keysend

(node_factory, bitcoind, xkeysend)

Source from the content-addressed store, hash-verified

5104
5105@pytest.mark.parametrize("xkeysend", [False, True])
5106def 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
5137def test_badparam_discretion(node_factory):

Callers

nothing calls this directly

Calls 10

wait_forFunction · 0.90
only_oneFunction · 0.90
line_graphMethod · 0.80
listpeerchannelsMethod · 0.80
keysendMethod · 0.80
payMethod · 0.45
invoiceMethod · 0.45
xpayMethod · 0.45
checkMethod · 0.45
xkeysendMethod · 0.45

Tested by

no test coverage detected