pytest: test xpay for routehint when channel is to itself.
What changed, and why it matters
This commit only adds a new test case for the xpay payment feature. It checks that xpay can handle a malformed invoice route hint where a node points to itself, and that the payment still succeeds through a normal direct channel. There is no code fix or behavior change in this commit.
No action required. This is a test-only commit. If the test is expected to pass in the future, ensure the underlying xpay logic already handles circular route hints gracefully.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff adds a pytest test test_xpay_circular_routehint marked as @pytest.mark.xfail(strict=True). The test creates a two-node line graph, constructs a circular route hint where the same node ID appears twice, creates a BOLT11 invoice with that route hint, and asserts that xpay still succeeds via the direct channel and logs ‘Invoice gave bad self-node route’. This is purely a regression/behavior test; no production code is modified.
Changed components
tests/test_xpay.pyInspect captured patch +27 / −0
diff --git a/tests/test_xpay.py b/tests/test_xpay.py
index 0f8475bc..99d91034 100644
--- a/tests/test_xpay.py
+++ b/tests/test_xpay.py
@@ -975,6 +975,33 @@ def test_xpay_offer(node_factory):
l1.rpc.xpay(offer2, 5000)
+@pytest.mark.xfail(strict=True)
+def test_xpay_circular_routehint(node_factory):
+ """Test that xpay gracefully skips a circular bolt11 routehint (src == dst)."""
+ l1, l2 = node_factory.line_graph(2)
+
+ # A routehint containing a same-node channel (example is l3 in this case)
+ circular_hint = [{'id': '03cecbfdc68544cc596223b68ce0710c9e5d2c9cb317ee07822d95079acc703d31',
+ 'short_channel_id': '1x2x3',
+ 'fee_base_msat': 0,
+ 'fee_proportional_millionths': 0,
+ 'cltv_expiry_delta': 6},
+ {'id': '03cecbfdc68544cc596223b68ce0710c9e5d2c9cb317ee07822d95079acc703d31',
+ 'short_channel_id': '1x2x4',
+ 'fee_base_msat': 0,
+ 'fee_proportional_millionths': 0,
+ 'cltv_expiry_delta': 6}]
+ inv = l2.dev_invoice(amount_msat=10000,
+ label='circular_hint',
+ description='circular hint test',
+ dev_routes=[circular_hint])
+
+ # Payment should still succeed via the direct channel.
+ ret = l1.rpc.xpay(inv['bolt11'])
+ assert ret['successful_parts'] == 1
+ l1.daemon.wait_for_log('Invoice gave bad self-node route')
+
+
def test_xpay_currency_offer(node_factory):
"""Test that xpay and sendamount correctly report the currency name when rejecting non-msat offers."""
plugin = Path(__file__).parent / "plugins" / "currencyUSDAUD5000.py"
Why this scored 12/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.