From 73e7708f15d867b0b10a9d47384d9fa40bb7e09c Mon Sep 17 00:00:00 2001 From: Yash Bhutwala Date: Tue, 13 Jan 2026 09:37:19 -0500 Subject: [PATCH] itest: add fundMax with maxChanSize test Add integration test to verify that fundMax uses the protocol-level maximum channel size instead of the user-configured maxChanSize. The test uses a table-driven approach to cover both non-wumbo and wumbo scenarios, creating nodes with restrictive maxChanSize (5M sats) and verifying that fundMax still creates channels at the protocol maximum. --- itest/list_on_test.go | 4 ++ itest/lnd_channel_funding_fund_max_test.go | 77 ++++++++++++++++++++++ 2 files changed, 81 insertions(+) diff --git a/itest/list_on_test.go b/itest/list_on_test.go index 18732b179..a09c4c1f6 100644 --- a/itest/list_on_test.go +++ b/itest/list_on_test.go @@ -567,6 +567,10 @@ var allTestCases = []*lntest.TestCase{ Name: "channel fundmax anchor reserve", TestFunc: testChannelFundMaxAnchorReserve, }, + { + Name: "channel fundmax maxchansize", + TestFunc: testChannelFundMaxMaxChanSize, + }, { Name: "htlc timeout resolver extract preimage remote", TestFunc: testHtlcTimeoutResolverExtractPreimageRemote, diff --git a/itest/lnd_channel_funding_fund_max_test.go b/itest/lnd_channel_funding_fund_max_test.go index f2c73851d..34718623f 100644 --- a/itest/lnd_channel_funding_fund_max_test.go +++ b/itest/lnd_channel_funding_fund_max_test.go @@ -6,6 +6,7 @@ import ( "github.com/btcsuite/btcd/btcutil" "github.com/lightningnetwork/lnd" + "github.com/lightningnetwork/lnd/funding" "github.com/lightningnetwork/lnd/input" "github.com/lightningnetwork/lnd/lnrpc" "github.com/lightningnetwork/lnd/lnrpc/walletrpc" @@ -408,3 +409,79 @@ func sweepNodeWalletAndAssert(ht *lntest.HarnessTest, node *node.HarnessNode) { // Ensure that the node's balance is 0 checkChannelBalance(ht, node, 0, 0) } + +// testChannelFundMaxMaxChanSize verifies that fundMax uses the protocol-level +// maximum channel size, not the user-configured maxChanSize. The maxChanSize +// config option is intended only for limiting incoming channel requests, not +// outgoing ones. +func testChannelFundMaxMaxChanSize(ht *lntest.HarnessTest) { + testCases := []struct { + name string + wumbo bool + expectedMax btcutil.Amount + }{ + { + name: "non-wumbo", + wumbo: false, + expectedMax: funding.MaxBtcFundingAmount, + }, + { + name: "wumbo", + wumbo: true, + expectedMax: funding.MaxBtcFundingAmountWumbo, + }, + } + + for _, tc := range testCases { + success := ht.Run(tc.name, func(t *testing.T) { + st := ht.Subtest(t) + + // Configure Alice with a restrictive maxChanSize (5M + // sats), which is below both protocol maximums. + aliceArgs := []string{ + "--maxchansize=5000000", + } + if tc.wumbo { + aliceArgs = append( + aliceArgs, "--protocol.wumbo-channels", + ) + } + + alice := st.NewNode("Alice", aliceArgs) + + // Bob needs wumbo enabled to accept large channels. + var bobArgs []string + if tc.wumbo { + bobArgs = []string{"--protocol.wumbo-channels"} + } + bob := st.NewNode("Bob", bobArgs) + + st.EnsureConnected(alice, bob) + + // Fund Alice with more than the protocol maximum. + fundAmt := tc.expectedMax + btcutil.SatoshiPerBitcoin + st.FundCoins(fundAmt, alice) + + // Open channel with fundMax. This should use the + // protocol maximum, not the configured maxChanSize. + chanPoint := st.OpenChannel( + alice, bob, lntest.OpenChannelParams{ + FundMax: true, + }, + ) + + cType := st.GetChannelCommitType(alice, chanPoint) + + // The expected balance is the protocol maximum minus + // the commitment fee. + expectedBalance := tc.expectedMax - + lntest.CalcStaticFee(cType, 0) + + checkChannelBalance(st, alice, expectedBalance, 0) + checkChannelBalance(st, bob, 0, expectedBalance) + }) + if !success { + break + } + } +}