mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-18 05:12:45 +01:00
pytest: Let fail_htlcs.py
plugin generates TEMPORARY_NODE_FAILURE
error
This commit is contained in:
parent
22e8d242fc
commit
a3a0f651e3
@ -9,7 +9,9 @@ plugin = Plugin()
|
||||
def on_htlc_accepted(onion, plugin, **kwargs):
|
||||
plugin.log("Failing htlc on purpose")
|
||||
plugin.log("onion: %r" % (onion))
|
||||
return {"result": "fail", "failure_code": 16399}
|
||||
# FIXME: Define this!
|
||||
WIRE_TEMPORARY_NODE_FAILURE = 0x2002
|
||||
return {"result": "fail", "failure_code": WIRE_TEMPORARY_NODE_FAILURE}
|
||||
|
||||
|
||||
plugin.run()
|
||||
|
@ -426,10 +426,16 @@ def test_htlc_accepted_hook_fail(node_factory):
|
||||
], wait_for_announce=True)
|
||||
|
||||
# This must fail
|
||||
inv = l2.rpc.invoice(1000, "lbl", "desc")['bolt11']
|
||||
phash = l2.rpc.invoice(1000, "lbl", "desc")['payment_hash']
|
||||
route = l1.rpc.getroute(l2.info['id'], 1000, 1)['route']
|
||||
|
||||
# Here shouldn't use `pay` command because l2 rejects with WIRE_TEMPORARY_NODE_FAILURE,
|
||||
# then it will be excluded when l1 try another pay attempt.
|
||||
# Note if the destination is excluded, the route result is undefined.
|
||||
l1.rpc.sendpay(route, phash)
|
||||
with pytest.raises(RpcError) as excinfo:
|
||||
l1.rpc.pay(inv)
|
||||
assert excinfo.value.error['data']['failcode'] == 16399
|
||||
l1.rpc.waitsendpay(phash)
|
||||
assert excinfo.value.error['data']['failcode'] == 0x2002
|
||||
assert excinfo.value.error['data']['erring_index'] == 1
|
||||
|
||||
# And the invoice must still be unpaid
|
||||
@ -439,7 +445,7 @@ def test_htlc_accepted_hook_fail(node_factory):
|
||||
# Now try with forwarded HTLCs: l2 should still fail them
|
||||
# This must fail
|
||||
inv = l3.rpc.invoice(1000, "lbl", "desc")['bolt11']
|
||||
with pytest.raises(RpcError) as excinfo:
|
||||
with pytest.raises(RpcError):
|
||||
l1.rpc.pay(inv)
|
||||
|
||||
# And the invoice must still be unpaid
|
||||
|
Loading…
Reference in New Issue
Block a user