2020-07-02 06:06:44 +02:00
|
|
|
package itest
|
|
|
|
|
|
|
|
import (
|
|
|
|
"strings"
|
|
|
|
|
2022-02-23 14:48:00 +01:00
|
|
|
"github.com/btcsuite/btcd/btcutil"
|
2020-11-17 00:28:56 +01:00
|
|
|
"github.com/lightningnetwork/lnd/funding"
|
2020-07-02 06:06:44 +02:00
|
|
|
"github.com/lightningnetwork/lnd/lntest"
|
|
|
|
)
|
|
|
|
|
|
|
|
// testWumboChannels tests that only a node that signals wumbo channel
|
|
|
|
// acceptances will allow a wumbo channel to be created. Additionally, if a
|
|
|
|
// node is running with mini channels only enabled, then they should reject any
|
|
|
|
// inbound wumbo channel requests.
|
|
|
|
func testWumboChannels(net *lntest.NetworkHarness, t *harnessTest) {
|
|
|
|
// With all the channel types exercised, we'll now make sure the wumbo
|
|
|
|
// signalling support works properly.
|
|
|
|
//
|
|
|
|
// We'll make two new nodes, with one of them signalling support for
|
|
|
|
// wumbo channels while the other doesn't.
|
2021-06-07 22:05:12 +02:00
|
|
|
wumboNode := net.NewNode(
|
|
|
|
t.t, "wumbo", []string{"--protocol.wumbo-channels"},
|
2020-07-02 06:06:44 +02:00
|
|
|
)
|
|
|
|
defer shutdownAndAssert(net, t, wumboNode)
|
2021-06-07 22:05:12 +02:00
|
|
|
miniNode := net.NewNode(t.t, "mini", nil)
|
2020-07-02 06:06:44 +02:00
|
|
|
defer shutdownAndAssert(net, t, miniNode)
|
|
|
|
|
|
|
|
// We'll send coins to the wumbo node, as it'll be the one imitating
|
|
|
|
// the channel funding.
|
2021-08-19 14:49:39 +02:00
|
|
|
net.SendCoins(t.t, btcutil.SatoshiPerBitcoin, wumboNode)
|
2020-07-02 06:06:44 +02:00
|
|
|
|
|
|
|
// Next we'll connect both nodes, then attempt to make a wumbo channel
|
|
|
|
// funding request to the mini node we created above. The wumbo request
|
|
|
|
// should fail as the node isn't advertising wumbo channels.
|
2021-08-19 15:00:21 +02:00
|
|
|
net.EnsureConnected(t.t, wumboNode, miniNode)
|
2020-07-02 06:06:44 +02:00
|
|
|
|
2020-11-17 00:28:56 +01:00
|
|
|
chanAmt := funding.MaxBtcFundingAmount + 1
|
2021-06-11 06:35:30 +02:00
|
|
|
_, err := net.OpenChannel(
|
2021-08-19 19:48:27 +02:00
|
|
|
wumboNode, miniNode, lntest.OpenChannelParams{
|
2020-07-02 06:06:44 +02:00
|
|
|
Amt: chanAmt,
|
|
|
|
},
|
|
|
|
)
|
|
|
|
if err == nil {
|
|
|
|
t.Fatalf("expected wumbo channel funding to fail")
|
|
|
|
}
|
|
|
|
|
|
|
|
// The test should indicate a failure due to the channel being too
|
|
|
|
// large.
|
2020-09-15 04:16:32 +02:00
|
|
|
if !strings.Contains(err.Error(), "exceeds maximum chan size") {
|
2020-07-02 06:06:44 +02:00
|
|
|
t.Fatalf("channel should be rejected due to size, instead "+
|
|
|
|
"error was: %v", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
// We'll now make another wumbo node to accept our wumbo channel
|
|
|
|
// funding.
|
2021-06-07 22:05:12 +02:00
|
|
|
wumboNode2 := net.NewNode(
|
|
|
|
t.t, "wumbo2", []string{"--protocol.wumbo-channels"},
|
2020-07-02 06:06:44 +02:00
|
|
|
)
|
|
|
|
defer shutdownAndAssert(net, t, wumboNode2)
|
|
|
|
|
|
|
|
// Creating a wumbo channel between these two nodes should succeed.
|
2021-08-19 15:00:21 +02:00
|
|
|
net.EnsureConnected(t.t, wumboNode, wumboNode2)
|
2020-07-02 06:06:44 +02:00
|
|
|
chanPoint := openChannelAndAssert(
|
2021-08-19 14:12:50 +02:00
|
|
|
t, net, wumboNode, wumboNode2,
|
2020-07-02 06:06:44 +02:00
|
|
|
lntest.OpenChannelParams{
|
|
|
|
Amt: chanAmt,
|
|
|
|
},
|
|
|
|
)
|
2021-08-11 06:29:40 +02:00
|
|
|
closeChannelAndAssert(t, net, wumboNode, chanPoint, false)
|
2020-07-02 06:06:44 +02:00
|
|
|
}
|