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.
This commit is contained in:
Yash Bhutwala committed 2026-01-13 10:54:55 -05:00
1 parent 0764f27b6f
commit 73e7708f15
2 files changed
+81

No files matched your search

+4
View File
@@ -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,
@@ -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
}
}
}