renepay: add test to check for wrong CLTV computation
What changed, and why it matters
This commit only adds a new test case to the Core Lightning test suite. The test is marked as expected to fail (xfail) and checks whether the renepay plugin computes the CLTV (a timeout value used in Lightning payments) correctly. It does not change any production code, fix a bug, or introduce a vulnerability. It is a regression test that documents a suspected miscalculation.
No security action required. This is a test-only commit. If the test is meant to catch a real bug, the actual fix would be a separate commit changing the renepay CLTV computation logic.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff adds a single pytest function, test_cltv_value, to tests/test_renepay.py. The test sets up a three-node line graph with cltv-delta=5, creates a BOLT-11 invoice, pays it via renepay, and asserts that the HTLC’s cltv value equals blockheight + 1 + cltv_delta + final_cltv. The test is decorated with @pytest.mark.xfail(strict=True), meaning it is currently expected to fail and the test suite will fail if it unexpectedly passes. No plugin, library, or daemon code is modified.
Changed components
tests/test_renepay.pyInspect captured patch +28 / −0
diff --git a/tests/test_renepay.py b/tests/test_renepay.py
index 3d1c1da3..12ef1fde 100644
--- a/tests/test_renepay.py
+++ b/tests/test_renepay.py
@@ -874,3 +874,31 @@ def test_unannounced(node_factory):
b12 = l1.rpc.fetchinvoice(offer, "21sat")["invoice"]
ret = l1.rpc.call("renepay", {"invstring": b12})
assert ret["status"] == "complete"
+
+
+@pytest.mark.xfail(strict=True)
+def test_cltv_value(node_factory, bitcoind):
+ cltv_delta = 5
+ l1, l2, l3 = node_factory.line_graph(
+ 3,
+ wait_for_announce=True,
+ opts={
+ "allow-deprecated-apis": True,
+ "cltv-delta": cltv_delta,
+ "fee-base": 0,
+ "fee-per-satoshi": 0,
+ },
+ )
+ blockheight = l1.rpc.waitblockheight(0)["blockheight"]
+ # BOLT-11 direct peer
+ b11 = l3.rpc.invoice(
+ "100sat", "test_renepay_expiry_too_far", "test_renepay_expiry_too_far"
+ )["bolt11"]
+ decoded_b11 = l1.rpc.decode(b11)
+ final_cltv = decoded_b11["min_final_cltv_expiry"]
+ ret = l1.rpc.call("renepay", {"invstring": b11})
+ assert ret["status"] == "complete"
+ pattern = r"Adding HTLC 0 amount=100000msat cltv=(\d+)"
+ line = l1.daemon.wait_for_log(pattern)
+ cltv = int(re.search(pattern, line).group(1))
+ assert cltv == (blockheight + 1) + cltv_delta + final_cltv
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.