itest: add payment test with max htlc restriction
What changed, and why it matters
This commit only adds a new integration test to the LND project. It checks that when a Lightning channel has a maximum HTLC (payment chunk) size set, the software correctly splits a larger payment into smaller pieces that fit within that limit. There is no code fix or behavior change in the main application—only a test was added.
No security action required. Treat as routine test coverage addition. If reviewing a larger patch series, verify whether a preceding commit actually fixed the behavior this test exercises.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit introduces itest/lnd_max_htlc_path_test.go and registers testMaxHtlcPathPayment in itest/list_on_test.go. The test creates an Alice→Bob channel, sets Alice’s routing policy with MaxHtlcMsat to 50,000,000 msat, then asks Alice to pay a 60,000,000 msat invoice from Bob. The assertion is that the payment succeeds by being split into multiple HTLCs respecting the max HTLC constraint. No production logic is modified.
Changed components
itest/lnd_max_htlc_path_test.goitest/list_on_test.goInspect captured patch +78 / −0
diff --git a/itest/list_on_test.go b/itest/list_on_test.go
index 851662f..7f9eaf5 100644
--- a/itest/list_on_test.go
+++ b/itest/list_on_test.go
@@ -242,6 +242,10 @@ var allTestCases = []*lntest.TestCase{
Name: "wumbo channels",
TestFunc: testWumboChannels,
},
+ {
+ Name: "max htlc path payment",
+ TestFunc: testMaxHtlcPathPayment,
+ },
{
Name: "max htlc pathfind",
TestFunc: testMaxHtlcPathfind,
diff --git a/itest/lnd_max_htlc_path_test.go b/itest/lnd_max_htlc_path_test.go
new file mode 100644
index 0000000..3e8db16
--- /dev/null
+++ b/itest/lnd_max_htlc_path_test.go
@@ -0,0 +1,74 @@
+package itest
+
+import (
+ "github.com/lightningnetwork/lnd/lnrpc"
+ "github.com/lightningnetwork/lnd/lnrpc/routerrpc"
+ "github.com/lightningnetwork/lnd/lntest"
+)
+
+// testMaxHtlcPathPayment tests that when a payment is attempted, the path
+// finding logic correctly takes into account the max_htlc value of the first
+// channel.
+func testMaxHtlcPathPayment(ht *lntest.HarnessTest) {
+ // Create a channel Alice->Bob.
+ chanPoints, nodes := ht.CreateSimpleNetwork(
+ [][]string{nil, nil}, lntest.OpenChannelParams{
+ Amt: 1000000,
+ },
+ )
+ alice, bob := nodes[0], nodes[1]
+ chanPoint := chanPoints[0]
+
+ // Alice and Bob should have one channel open with each other now.
+ ht.AssertNodeNumChannels(alice, 1)
+ ht.AssertNodeNumChannels(bob, 1)
+
+ // Define a max_htlc value that is lower than the default.
+ const (
+ maxHtlcMsat = 50000000
+ minHtlcMsat = 1000
+ timeLockDelta = 80
+ baseFeeMsat = 0
+ feeRate = 0
+ )
+
+ // Update Alice's channel policy to set the new max_htlc value.
+ req := &lnrpc.PolicyUpdateRequest{
+ Scope: &lnrpc.PolicyUpdateRequest_ChanPoint{
+ ChanPoint: chanPoint,
+ },
+ MaxHtlcMsat: maxHtlcMsat,
+ MinHtlcMsat: minHtlcMsat,
+ BaseFeeMsat: baseFeeMsat,
+ FeeRate: feeRate,
+ TimeLockDelta: timeLockDelta,
+ }
+ alice.RPC.UpdateChannelPolicy(req)
+
+ expectedPolicy := &lnrpc.RoutingPolicy{
+ FeeBaseMsat: baseFeeMsat,
+ FeeRateMilliMsat: feeRate,
+ TimeLockDelta: timeLockDelta,
+ MinHtlc: minHtlcMsat,
+ MaxHtlcMsat: maxHtlcMsat,
+ }
+
+ // Wait for the policy update to propagate to Bob.
+ ht.AssertChannelPolicyUpdate(
+ bob, alice, expectedPolicy, chanPoint, false,
+ )
+
+ // Create an invoice for an amount greater than the max htlc value.
+ invoiceAmt := int64(maxHtlcMsat + 10_000_000)
+ invoice := &lnrpc.Invoice{ValueMsat: invoiceAmt}
+ resp := bob.RPC.AddInvoice(invoice)
+
+ // Attempt to pay the invoice from Alice. The payment should be
+ // splitted into two parts, one for the max_htlc value and one for the
+ // remaining amount and succeed.
+ payReq := &routerrpc.SendPaymentRequest{
+ PaymentRequest: resp.PaymentRequest,
+ FeeLimitMsat: noFeeLimitMsat,
+ }
+ ht.SendPaymentAssertSettled(alice, payReq)
+}
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.