From 13277b7cff55d63c87067ab25246563f514941ed Mon Sep 17 00:00:00 2001 From: yyforyongyu Date: Sat, 9 Nov 2024 14:39:12 +0800 Subject: [PATCH] itest: further reduce block mined in tests --- itest/lnd_hold_invoice_force_test.go | 2 +- itest/lnd_route_blinding_test.go | 21 ++++++++++++++++----- itest/lnd_wipe_fwdpkgs_test.go | 3 --- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/itest/lnd_hold_invoice_force_test.go b/itest/lnd_hold_invoice_force_test.go index 19e44a8375..5fe8ea0daa 100644 --- a/itest/lnd_hold_invoice_force_test.go +++ b/itest/lnd_hold_invoice_force_test.go @@ -30,7 +30,7 @@ func testHoldInvoiceForceClose(ht *lntest.HarnessTest) { ) invoiceReq := &invoicesrpc.AddHoldInvoiceRequest{ Value: 30000, - CltvExpiry: 40, + CltvExpiry: finalCltvDelta, Hash: payHash[:], } bobInvoice := bob.RPC.AddHoldInvoice(invoiceReq) diff --git a/itest/lnd_route_blinding_test.go b/itest/lnd_route_blinding_test.go index d85f3fcac4..097c5c5876 100644 --- a/itest/lnd_route_blinding_test.go +++ b/itest/lnd_route_blinding_test.go @@ -5,6 +5,7 @@ import ( "crypto/sha256" "encoding/hex" "errors" + "fmt" "time" "github.com/btcsuite/btcd/btcec/v2" @@ -19,6 +20,10 @@ import ( "github.com/stretchr/testify/require" ) +// toLocalCSV is the CSV delay for the node's to_local output. We use a small +// value to save us from mining blocks. +var toLocalCSV = 2 + // testQueryBlindedRoutes tests querying routes to blinded routes. To do this, // it sets up a nework of Alice - Bob - Carol and creates a mock blinded route // that uses Carol as the introduction node (plus dummy hops to cover multiple @@ -346,12 +351,18 @@ func newBlindedForwardTest(ht *lntest.HarnessTest) (context.Context, func (b *blindedForwardTest) setupNetwork(ctx context.Context, withInterceptor bool) { - carolArgs := []string{"--bitcoin.timelockdelta=18"} + carolArgs := []string{ + "--bitcoin.timelockdelta=18", + fmt.Sprintf("--bitcoin.defaultremotedelay=%v", toLocalCSV), + } if withInterceptor { carolArgs = append(carolArgs, "--requireinterceptor") } - daveArgs := []string{"--bitcoin.timelockdelta=18"} + daveArgs := []string{ + "--bitcoin.timelockdelta=18", + fmt.Sprintf("--bitcoin.defaultremotedelay=%v", toLocalCSV), + } cfgs := [][]string{nil, nil, carolArgs, daveArgs} param := lntest.OpenChannelParams{ Amt: chanAmt, @@ -782,9 +793,8 @@ func testErrorHandlingOnChainFailure(ht *lntest.HarnessTest) { // Mine blocks so that Bob will claim his CSV delayed local commitment, // we've already mined 1 block so we need one less than our CSV. - ht.MineBlocks(node.DefaultCSV - 1) + ht.MineBlocks(toLocalCSV - 1) ht.AssertNumPendingSweeps(bob, 1) - ht.MineEmptyBlocks(1) ht.MineBlocksAndAssertNumTxes(1, 1) // Restart bob so that we can test that he's able to recover everything @@ -796,6 +806,7 @@ func testErrorHandlingOnChainFailure(ht *lntest.HarnessTest) { // value. info := bob.RPC.GetInfo() target := carolHTLC.IncomingExpiry - info.BlockHeight + ht.Log(carolHTLC.IncomingExpiry, info.BlockHeight, target) ht.MineBlocks(int(target)) // Wait for Bob's timeout transaction in the mempool, since we've @@ -806,7 +817,7 @@ func testErrorHandlingOnChainFailure(ht *lntest.HarnessTest) { // Clean up the rest of our force close: mine blocks so that Bob's CSV // expires plus one block to trigger his sweep and then mine it. - ht.MineBlocks(node.DefaultCSV - 1) + ht.MineBlocks(toLocalCSV - 1) ht.AssertNumPendingSweeps(bob, 1) ht.MineBlocksAndAssertNumTxes(1, 1) diff --git a/itest/lnd_wipe_fwdpkgs_test.go b/itest/lnd_wipe_fwdpkgs_test.go index 10ef35ad19..fda9916f9a 100644 --- a/itest/lnd_wipe_fwdpkgs_test.go +++ b/itest/lnd_wipe_fwdpkgs_test.go @@ -105,7 +105,4 @@ func testWipeForwardingPackages(ht *lntest.HarnessTest) { // Mine 1 block to get Alice's sweeping tx confirmed. ht.MineBlocksAndAssertNumTxes(1, 1) - - // Clean up the force closed channel. - ht.CleanupForceClose(bob) }