diff --git a/tests/plugins/fail_htlcs.py b/tests/plugins/fail_htlcs.py index 67cde7ce1..e36b67b0b 100755 --- a/tests/plugins/fail_htlcs.py +++ b/tests/plugins/fail_htlcs.py @@ -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() diff --git a/tests/test_plugin.py b/tests/test_plugin.py index b6cc95149..1e253ef91 100644 --- a/tests/test_plugin.py +++ b/tests/test_plugin.py @@ -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