From 71460ac073a8846a744d0e88c335d0f5455b8fca Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Tue, 21 May 2019 09:55:02 +0930 Subject: [PATCH] pay: don't say "Could not find a route" unless we never tried a payment. It's deeply confusing: we say this after exhausting all other routes. Signed-off-by: Rusty Russell --- plugins/pay.c | 6 ++++++ tests/test_pay.py | 7 ++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/plugins/pay.c b/plugins/pay.c index 076dcf0f7..39e3d7def 100644 --- a/plugins/pay.c +++ b/plugins/pay.c @@ -199,6 +199,12 @@ static struct command_result *next_routehint(struct command *cmd, return command_fail(cmd, PAY_ROUTE_TOO_EXPENSIVE, "%s", pc->expensive_route); + if (tal_count(pc->ps->attempts) > 1) + return command_fail(cmd, PAY_STOPPED_RETRYING, + "Ran out of routes to try after" + " %zu attempts: see paystatus", + tal_count(pc->ps->attempts)); + return command_fail(cmd, PAY_ROUTE_NOT_FOUND, "Could not find a route"); } diff --git a/tests/test_pay.py b/tests/test_pay.py index 0be57e267..2ba6edc07 100644 --- a/tests/test_pay.py +++ b/tests/test_pay.py @@ -1465,7 +1465,7 @@ def test_pay_retry(node_factory, bitcoind): # This should make it fail. exhaust_channel(l4, l5, scid45, 10**8) - with pytest.raises(RpcError): + with pytest.raises(RpcError, match=r'5 attempts'): l1.rpc.pay(l5.rpc.invoice(10**8, 'test_retry2', 'test_retry2')['bolt11']) @@ -1475,6 +1475,11 @@ def test_pay_routeboost(node_factory, bitcoind): # l1->l2->l3--private-->l4 l1, l2 = node_factory.line_graph(2, announce_channels=True, wait_for_announce=True) l3, l4, l5 = node_factory.line_graph(3, announce_channels=False, wait_for_announce=False) + + # This should a "could not find a route" because that's true. + with pytest.raises(RpcError, match=r'Could not find a route'): + l1.rpc.pay(l5.rpc.invoice(10**8, 'test_retry', 'test_retry')['bolt11']) + l2.rpc.connect(l3.info['id'], 'localhost', l3.port) scidl2l3 = l2.fund_channel(l3, 10**6)