Browse Source

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 <rusty@rustcorp.com.au>
htlc_accepted_hook
Rusty Russell 6 years ago
parent
commit
71460ac073
  1. 6
      plugins/pay.c
  2. 7
      tests/test_pay.py

6
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");
}

7
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)

Loading…
Cancel
Save