Skip to content

Commit

Permalink
renepay: add command notifications
Browse files Browse the repository at this point in the history
These show that we should clean up our notes.  Here's the result from test_hardmpp:

# we have computed a set of 1 flows with probability 0.328, fees 0msat and delay 23
# No MPP, so added 0msat shadow fee
# Shadow route on flow 0/1 added 0 block delay. now 5
# sendpay flow groupid=1, partid=1, delivering=1800000000msat, probability=0.328
# Update chan knowledge scid=103x2x0, dir=0: [0msat,1799999999msat]
# onion error WIRE_TEMPORARY_CHANNEL_FAILURE from node #1 103x2x0: failed: WIRE_TEMPORARY_CHANNEL_FAILURE (reply from remote)
# we have computed a set of 2 flows with probability 0.115, fees 0msat and delay 23
# Shadow route on flow 0/2 added 0 block delay. now 5
# Shadow route on flow 1/2 added 0 block delay. now 5
# sendpay flow groupid=1, partid=3, delivering=500000000msat, probability=0.475
# sendpay flow groupid=1, partid=2, delivering=1300000000msat, probability=0.242
# Update chan knowledge scid=103x2x0, dir=0: [0msat,1299999999msat]
# onion error WIRE_TEMPORARY_CHANNEL_FAILURE from node #1 103x2x0: failed: WIRE_TEMPORARY_CHANNEL_FAILURE (reply from remote)
# we have computed a set of 2 flows with probability 0.084, fees 0msat and delay 23
# Shadow route on flow 0/2 added 0 block delay. now 5
# Shadow route on flow 1/2 added 0 block delay. now 5
# sendpay flow groupid=1, partid=5, delivering=260000000msat, probability=0.467
# sendpay flow groupid=1, partid=4, delivering=1040000000msat, probability=0.179
# Update chan knowledge scid=103x2x0, dir=0: [0msat,1039999999msat]
# onion error WIRE_TEMPORARY_CHANNEL_FAILURE from node #1 103x2x0: failed: WIRE_TEMPORARY_CHANNEL_FAILURE (reply from remote)
# we have computed a set of 2 flows with probability 0.052, fees 0msat and delay 23
# Shadow route on flow 0/2 added 0 block delay. now 5
# Shadow route on flow 1/2 added 0 block delay. now 5
# sendpay flow groupid=1, partid=7, delivering=120000000msat, probability=0.494
# sendpay flow groupid=1, partid=6, delivering=920000000msat, probability=0.105

Ideally it would look something like:

# Computed 1 flows, probability=0.328:
#  Flow 1: 103x2x0 1800000000msat fee=0msat probability=0.328 shadow=+0msat/0blocks
#  Flow 1: FAIL: TEMPORARY_CHANNEL_FAILURE for 103x2x0.
# Computed 2 flows, probability=0.115:
#  Flow 2: XXX->XXX 1300000000msat fee=XXX, probability=0.475 shadow=+0msat/0blocks
#  Flow 3: XXX->XXX 500000000msat fee=XXX, probability=0.475 shadow=+0msat/0blocks
#  Flow 2: FAIL: TEMPORARY_CHANNEL_FAILURE from node #1 103x2x0
# Computed 2 flows (3 total), probability=0.084, fee=0msat, delay=23
...
#  Flow 4: SUCCESS, 2 in progress should succeed soon.

Signed-off-by: Rusty Russell <[email protected]>
  • Loading branch information
rustyrussell committed Aug 12, 2023
1 parent 5c9a107 commit efc0264
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
3 changes: 3 additions & 0 deletions plugins/renepay/payment.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ void payment_note(struct payment *p, const char *fmt, ...)
va_end(ap);
tal_arr_expand(&p->paynotes, str);
debug_info("%s",str);

if (p->cmd)
plugin_notify_message(p->cmd, LOG_INFORM, "%s", str);
}

void payment_assert_delivering_incomplete(const struct payment *p)
Expand Down
18 changes: 15 additions & 3 deletions tests/test_renepay.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from fixtures import * # noqa: F401,F403
from pyln.client import RpcError, Millisatoshi
from utils import only_one, wait_for, mine_funding_to_announce, sync_blockheight
from utils import only_one, wait_for, mine_funding_to_announce, sync_blockheight, TEST_NETWORK
import pytest
import random
import time
import json
import subprocess


def test_simple(node_factory):
Expand Down Expand Up @@ -309,8 +310,19 @@ def test_hardmpp(node_factory):
print(json.dumps(l3.rpc.listpeerchannels()), file=f)

inv2 = l6.rpc.invoice("1800000sat", "inv2", 'description')
l1.rpc.call(
'renepay', {'invstring': inv2['bolt11']})

out = subprocess.check_output(['cli/lightning-cli',
'--network={}'.format(TEST_NETWORK),
'--lightning-dir={}'
.format(l1.daemon.lightning_dir),
'-k',
'renepay', 'invstring={}'.format(inv2['bolt11'])]).decode('utf-8')
lines = out.split('\n')
# First comes commentry
assert any([l.startswith('#') for l in lines])

# Now comes JSON
json.loads("".join([l for l in lines if not l.startswith('#')]))
l1.wait_for_htlcs()
invoice = only_one(l6.rpc.listinvoices('inv2')['invoices'])
assert isinstance(invoice['amount_received_msat'], Millisatoshi)
Expand Down

0 comments on commit efc0264

Please sign in to comment.