Skip to content

Commit

Permalink
itest: allow public taproot chan tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ellemouton committed Oct 10, 2023
1 parent 21c241d commit 11fa696
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 155 deletions.
15 changes: 0 additions & 15 deletions itest/lnd_channel_backup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,6 @@ func newChanRestoreScenario(ht *lntest.HarnessTest, ct lnrpc.CommitmentType,
// with a portion pushed.
ht.ConnectNodes(dave, carol)

// If the commitment type is taproot, then the channel must also be
// private.
var privateChan bool
if ct == lnrpc.CommitmentType_SIMPLE_TAPROOT {
privateChan = true
}

return &chanRestoreScenario{
carol: carol,
dave: dave,
Expand All @@ -124,7 +117,6 @@ func newChanRestoreScenario(ht *lntest.HarnessTest, ct lnrpc.CommitmentType,
PushAmt: pushAmt,
ZeroConf: zeroConf,
CommitmentType: ct,
Private: privateChan,
},
}
}
Expand Down Expand Up @@ -649,13 +641,6 @@ func runChanRestoreScenarioCommitTypes(ht *lntest.HarnessTest,
multi, err := ioutil.ReadFile(backupFilePath)
require.NoError(ht, err)

// If this was a zero conf taproot channel, then since it's private,
// we'll need to mine an extra block (framework won't mine extra blocks
// otherwise).
if ct == lnrpc.CommitmentType_SIMPLE_TAPROOT && zeroConf {
ht.MineBlocksAndAssertNumTxes(1, 1)
}

// Now that we have Dave's backup file, we'll create a new nodeRestorer
// that we'll restore using the on-disk channels.backup.
restoredNodeFunc := chanRestoreViaRPC(
Expand Down
10 changes: 0 additions & 10 deletions itest/lnd_channel_force_close_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,18 +268,8 @@ func channelForceClosureTest(ht *lntest.HarnessTest,
carolBalResp := carol.RPC.WalletBalance()
carolStartingBalance := carolBalResp.ConfirmedBalance

// If the channel is a taproot channel, then we'll need to create a
// private channel.
//
// TODO(roasbeef): lift after G175
var privateChan bool
if channelType == lnrpc.CommitmentType_SIMPLE_TAPROOT {
privateChan = true
}

chanPoint := ht.OpenChannel(
alice, carol, lntest.OpenChannelParams{
Private: privateChan,
Amt: chanAmt,
PushAmt: pushAmt,
CommitmentType: channelType,
Expand Down
13 changes: 1 addition & 12 deletions itest/lnd_funding_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,6 @@ func testBasicChannelFunding(ht *lntest.HarnessTest) {
// connected to the funding flow can properly be executed.
ht.EnsureConnected(carol, dave)

var privateChan bool

// If this is to be a taproot channel type, then it needs to be
// private, otherwise it'll be rejected by Dave.
//
// TODO(roasbeef): lift after gossip 1.75
if carolCommitType == lnrpc.CommitmentType_SIMPLE_TAPROOT {
privateChan = true
}

// If carol wants taproot, but dave wants something
// else, then we'll assert that the channel negotiation
// attempt fails.
Expand All @@ -81,7 +71,6 @@ func testBasicChannelFunding(ht *lntest.HarnessTest) {
amt := funding.MaxBtcFundingAmount
ht.OpenChannelAssertErr(
carol, dave, lntest.OpenChannelParams{
Private: privateChan,
Amt: amt,
CommitmentType: carolCommitType,
}, expectedErr,
Expand All @@ -91,7 +80,7 @@ func testBasicChannelFunding(ht *lntest.HarnessTest) {
}

carolChan, daveChan, closeChan := basicChannelFundingTest(
ht, carol, dave, nil, privateChan, &carolCommitType,
ht, carol, dave, nil, false, &carolCommitType,
)

// Both nodes should report the same commitment
Expand Down
102 changes: 3 additions & 99 deletions itest/lnd_multi-hop_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,21 +193,13 @@ func runMultiHopHtlcLocalTimeout(ht *lntest.HarnessTest,
dustPayHash := ht.Random32Bytes()
payHash := ht.Random32Bytes()

// If this is a taproot channel, then we'll need to make some manual
// route hints so Alice can actually find a route.
var routeHints []*lnrpc.RouteHint
if c == lnrpc.CommitmentType_SIMPLE_TAPROOT {
routeHints = makeRouteHints(bob, carol, zeroConf)
}

alice.RPC.SendPayment(&routerrpc.SendPaymentRequest{
Dest: carolPubKey,
Amt: int64(dustHtlcAmt),
PaymentHash: dustPayHash,
FinalCltvDelta: finalCltvDelta,
TimeoutSeconds: 60,
FeeLimitMsat: noFeeLimitMsat,
RouteHints: routeHints,
})

alice.RPC.SendPayment(&routerrpc.SendPaymentRequest{
Expand All @@ -217,7 +209,6 @@ func runMultiHopHtlcLocalTimeout(ht *lntest.HarnessTest,
FinalCltvDelta: finalCltvDelta,
TimeoutSeconds: 60,
FeeLimitMsat: noFeeLimitMsat,
RouteHints: routeHints,
})

// Verify that all nodes in the path now have two HTLC's with the
Expand Down Expand Up @@ -357,13 +348,6 @@ func runMultiHopReceiverChainClaim(ht *lntest.HarnessTest,
ht, alice, bob, false, c, zeroConf,
)

// If this is a taproot channel, then we'll need to make some manual
// route hints so Alice can actually find a route.
var routeHints []*lnrpc.RouteHint
if c == lnrpc.CommitmentType_SIMPLE_TAPROOT {
routeHints = makeRouteHints(bob, carol, zeroConf)
}

// With the network active, we'll now add a new hodl invoice at Carol's
// end. Make sure the cltv expiry delta is large enough, otherwise Bob
// won't send out the outgoing htlc.
Expand All @@ -375,7 +359,6 @@ func runMultiHopReceiverChainClaim(ht *lntest.HarnessTest,
Value: invoiceAmt,
CltvExpiry: finalCltvDelta,
Hash: payHash[:],
RouteHints: routeHints,
}
carolInvoice := carol.RPC.AddHoldInvoice(invoiceReq)

Expand Down Expand Up @@ -574,13 +557,6 @@ func runMultiHopLocalForceCloseOnChainHtlcTimeout(ht *lntest.HarnessTest,
// opens up the base for out tests.
const htlcAmt = btcutil.Amount(300_000)

// If this is a taproot channel, then we'll need to make some manual
// route hints so Alice can actually find a route.
var routeHints []*lnrpc.RouteHint
if c == lnrpc.CommitmentType_SIMPLE_TAPROOT {
routeHints = makeRouteHints(bob, carol, zeroConf)
}

// We'll now send a single HTLC across our multi-hop network.
carolPubKey := carol.PubKey[:]
payHash := ht.Random32Bytes()
Expand All @@ -591,7 +567,6 @@ func runMultiHopLocalForceCloseOnChainHtlcTimeout(ht *lntest.HarnessTest,
FinalCltvDelta: finalCltvDelta,
TimeoutSeconds: 60,
FeeLimitMsat: noFeeLimitMsat,
RouteHints: routeHints,
}
alice.RPC.SendPayment(req)

Expand Down Expand Up @@ -744,13 +719,6 @@ func runMultiHopRemoteForceCloseOnChainHtlcTimeout(ht *lntest.HarnessTest,
// opens up the base for out tests.
const htlcAmt = btcutil.Amount(30000)

// If this is a taproot channel, then we'll need to make some manual
// route hints so Alice can actually find a route.
var routeHints []*lnrpc.RouteHint
if c == lnrpc.CommitmentType_SIMPLE_TAPROOT {
routeHints = makeRouteHints(bob, carol, zeroConf)
}

// We'll now send a single HTLC across our multi-hop network.
var preimage lntypes.Preimage
copy(preimage[:], ht.Random32Bytes())
Expand All @@ -759,7 +727,6 @@ func runMultiHopRemoteForceCloseOnChainHtlcTimeout(ht *lntest.HarnessTest,
Value: int64(htlcAmt),
CltvExpiry: finalCltvDelta,
Hash: payHash[:],
RouteHints: routeHints,
}
carolInvoice := carol.RPC.AddHoldInvoice(invoiceReq)

Expand Down Expand Up @@ -911,13 +878,6 @@ func runMultiHopHtlcLocalChainClaim(ht *lntest.HarnessTest,
ht, alice, bob, false, c, zeroConf,
)

// If this is a taproot channel, then we'll need to make some manual
// route hints so Alice can actually find a route.
var routeHints []*lnrpc.RouteHint
if c == lnrpc.CommitmentType_SIMPLE_TAPROOT {
routeHints = makeRouteHints(bob, carol, zeroConf)
}

// With the network active, we'll now add a new hodl invoice at Carol's
// end. Make sure the cltv expiry delta is large enough, otherwise Bob
// won't send out the outgoing htlc.
Expand All @@ -929,7 +889,6 @@ func runMultiHopHtlcLocalChainClaim(ht *lntest.HarnessTest,
Value: invoiceAmt,
CltvExpiry: finalCltvDelta,
Hash: payHash[:],
RouteHints: routeHints,
}
carolInvoice := carol.RPC.AddHoldInvoice(invoiceReq)

Expand Down Expand Up @@ -1223,13 +1182,6 @@ func runMultiHopHtlcRemoteChainClaim(ht *lntest.HarnessTest,
ht, alice, bob, false, c, zeroConf,
)

// If this is a taproot channel, then we'll need to make some manual
// route hints so Alice can actually find a route.
var routeHints []*lnrpc.RouteHint
if c == lnrpc.CommitmentType_SIMPLE_TAPROOT {
routeHints = makeRouteHints(bob, carol, zeroConf)
}

// With the network active, we'll now add a new hodl invoice at Carol's
// end. Make sure the cltv expiry delta is large enough, otherwise Bob
// won't send out the outgoing htlc.
Expand All @@ -1241,7 +1193,6 @@ func runMultiHopHtlcRemoteChainClaim(ht *lntest.HarnessTest,
Value: invoiceAmt,
CltvExpiry: finalCltvDelta,
Hash: payHash[:],
RouteHints: routeHints,
}
carolInvoice := carol.RPC.AddHoldInvoice(invoiceReq)

Expand Down Expand Up @@ -1510,23 +1461,11 @@ func runMultiHopHtlcAggregation(ht *lntest.HarnessTest,
ht, alice, bob, false, c, zeroConf,
)

// If this is a taproot channel, then we'll need to make some manual
// route hints so Alice+Carol can actually find a route.
var (
carolRouteHints []*lnrpc.RouteHint
aliceRouteHints []*lnrpc.RouteHint
)
if c == lnrpc.CommitmentType_SIMPLE_TAPROOT {
carolRouteHints = makeRouteHints(bob, carol, zeroConf)
aliceRouteHints = makeRouteHints(bob, alice, zeroConf)
}

// To ensure we have capacity in both directions of the route, we'll
// make a fairly large payment Alice->Carol and settle it.
const reBalanceAmt = 500_000
invoice := &lnrpc.Invoice{
Value: reBalanceAmt,
RouteHints: carolRouteHints,
Value: reBalanceAmt,
}
resp := carol.RPC.AddInvoice(invoice)
ht.CompletePaymentRequests(alice, []string{resp.PaymentRequest})
Expand Down Expand Up @@ -1558,7 +1497,6 @@ func runMultiHopHtlcAggregation(ht *lntest.HarnessTest,
Value: invoiceAmt,
CltvExpiry: finalCltvDelta,
Hash: payHash[:],
RouteHints: carolRouteHints,
}
carolInvoice := carol.RPC.AddHoldInvoice(invoiceReq)

Expand All @@ -1580,7 +1518,6 @@ func runMultiHopHtlcAggregation(ht *lntest.HarnessTest,
Value: invoiceAmt,
CltvExpiry: thawHeightDelta - 4,
Hash: payHash[:],
RouteHints: aliceRouteHints,
}
aliceInvoice := alice.RPC.AddHoldInvoice(invoiceReq)

Expand Down Expand Up @@ -1946,13 +1883,7 @@ func createThreeHopNetwork(ht *lntest.HarnessTest,
)
}

var privateChan bool
if c == lnrpc.CommitmentType_SIMPLE_TAPROOT {
privateChan = true
}

aliceParams := lntest.OpenChannelParams{
Private: privateChan,
Amt: chanAmt,
CommitmentType: c,
FundingShim: aliceFundingShim,
Expand All @@ -1977,7 +1908,6 @@ func createThreeHopNetwork(ht *lntest.HarnessTest,
// Prepare params for Bob.
bobParams := lntest.OpenChannelParams{
Amt: chanAmt,
Private: privateChan,
CommitmentType: c,
FundingShim: bobFundingShim,
ZeroConf: zeroConf,
Expand Down Expand Up @@ -2022,18 +1952,8 @@ func createThreeHopNetwork(ht *lntest.HarnessTest,
}

// Make sure alice and carol know each other's channels.
//
// We'll only do this though if it wasn't a private channel we opened
// earlier.
if !privateChan {
ht.AssertTopologyChannelOpen(alice, bobChanPoint)
ht.AssertTopologyChannelOpen(carol, aliceChanPoint)
} else {
// Otherwise, we want to wait for all the channels to be shown
// as active before we proceed.
ht.AssertChannelExists(alice, aliceChanPoint)
ht.AssertChannelExists(carol, bobChanPoint)
}
ht.AssertTopologyChannelOpen(alice, bobChanPoint)
ht.AssertTopologyChannelOpen(carol, aliceChanPoint)

return aliceChanPoint, bobChanPoint, carol
}
Expand Down Expand Up @@ -2061,13 +1981,6 @@ func runExtraPreimageFromRemoteCommit(ht *lntest.HarnessTest,
ht, alice, bob, false, c, zeroConf,
)

// If this is a taproot channel, then we'll need to make some manual
// route hints so Alice can actually find a route.
var routeHints []*lnrpc.RouteHint
if c == lnrpc.CommitmentType_SIMPLE_TAPROOT {
routeHints = makeRouteHints(bob, carol, zeroConf)
}

// With the network active, we'll now add a new hodl invoice at Carol's
// end. Make sure the cltv expiry delta is large enough, otherwise Bob
// won't send out the outgoing htlc.
Expand All @@ -2077,7 +1990,6 @@ func runExtraPreimageFromRemoteCommit(ht *lntest.HarnessTest,
Value: 100_000,
CltvExpiry: finalCltvDelta,
Hash: payHash[:],
RouteHints: routeHints,
}
eveInvoice := carol.RPC.AddHoldInvoice(invoiceReq)

Expand Down Expand Up @@ -2220,13 +2132,6 @@ func runExtraPreimageFromLocalCommit(ht *lntest.HarnessTest,
ht, alice, bob, false, c, zeroConf,
)

// If this is a taproot channel, then we'll need to make some manual
// route hints so Alice can actually find a route.
var routeHints []*lnrpc.RouteHint
if c == lnrpc.CommitmentType_SIMPLE_TAPROOT {
routeHints = makeRouteHints(bob, carol, zeroConf)
}

// With the network active, we'll now add a new hodl invoice at Carol's
// end. Make sure the cltv expiry delta is large enough, otherwise Bob
// won't send out the outgoing htlc.
Expand All @@ -2236,7 +2141,6 @@ func runExtraPreimageFromLocalCommit(ht *lntest.HarnessTest,
Value: 100_000,
CltvExpiry: finalCltvDelta,
Hash: payHash[:],
RouteHints: routeHints,
}
eveInvoice := carol.RPC.AddHoldInvoice(invoiceReq)

Expand Down
4 changes: 0 additions & 4 deletions itest/lnd_payment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,6 @@ func testSendDirectPayment(ht *lntest.HarnessTest) {
CommitmentType: ct,
}

// Open private channel for taproot channels.
params.Private = ct ==
lnrpc.CommitmentType_SIMPLE_TAPROOT

testSendPayment(st, params)
})
}
Expand Down
Loading

0 comments on commit 11fa696

Please sign in to comment.