github.com/decred/dcrlnd@v0.7.6/lntest/itest/lnd_wumbo_channels_test.go (about) 1 package itest 2 3 import ( 4 "strings" 5 6 "github.com/decred/dcrlnd" 7 "github.com/decred/dcrlnd/lntest" 8 ) 9 10 // testWumboChannels tests that only a node that signals wumbo channel 11 // acceptances will allow a wumbo channel to be created. Additionally, if a 12 // node is running with mini channels only enabled, then they should reject any 13 // inbound wumbo channel requests. 14 func testWumboChannels(net *lntest.NetworkHarness, t *harnessTest) { 15 // With all the channel types exercised, we'll now make sure the wumbo 16 // signalling support works properly. 17 // 18 // We'll make two new nodes, with one of them signalling support for 19 // wumbo channels while the other doesn't. 20 wumboNode := net.NewNode( 21 t.t, "wumbo", []string{"--protocol.wumbo-channels"}, 22 ) 23 defer shutdownAndAssert(net, t, wumboNode) 24 miniNode := net.NewNode(t.t, "mini", nil) 25 defer shutdownAndAssert(net, t, miniNode) 26 27 // We'll send coins to the wumbo node, as it'll be the one imitating 28 // the channel funding. 29 net.SendCoins(t.t, dcrlnd.MaxFundingAmount+1e8, wumboNode) 30 31 // Next we'll connect both nodes, then attempt to make a wumbo channel 32 // funding request to the mini node we created above. The wumbo request 33 // should fail as the node isn't advertising wumbo channels. 34 net.EnsureConnected(t.t, wumboNode, miniNode) 35 36 chanAmt := dcrlnd.MaxFundingAmount + 1 37 _, err := net.OpenChannel( 38 wumboNode, miniNode, lntest.OpenChannelParams{ 39 Amt: chanAmt, 40 }, 41 ) 42 if err == nil { 43 t.Fatalf("expected wumbo channel funding to fail") 44 } 45 46 // The test should indicate a failure due to the channel being too 47 // large. 48 if !strings.Contains(err.Error(), "exceeds maximum chan size") { 49 t.Fatalf("channel should be rejected due to size, instead "+ 50 "error was: %v", err) 51 } 52 53 // We'll now make another wumbo node to accept our wumbo channel 54 // funding. 55 wumboNode2 := net.NewNode( 56 t.t, "wumbo2", []string{"--protocol.wumbo-channels"}, 57 ) 58 defer shutdownAndAssert(net, t, wumboNode2) 59 60 // Creating a wumbo channel between these two nodes should succeed. 61 net.EnsureConnected(t.t, wumboNode, wumboNode2) 62 chanPoint := openChannelAndAssert( 63 t, net, wumboNode, wumboNode2, 64 lntest.OpenChannelParams{ 65 Amt: chanAmt, 66 }, 67 ) 68 closeChannelAndAssert(t, net, wumboNode, chanPoint, false) 69 }