Skip to content

Commit

Permalink
itest: further reduce block mined in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
yyforyongyu committed Nov 9, 2024
1 parent dcb1149 commit 13277b7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
2 changes: 1 addition & 1 deletion itest/lnd_hold_invoice_force_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
21 changes: 16 additions & 5 deletions itest/lnd_route_blinding_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"crypto/sha256"
"encoding/hex"
"errors"
"fmt"
"time"

"github.com/btcsuite/btcd/btcec/v2"
Expand All @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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)

Expand Down
3 changes: 0 additions & 3 deletions itest/lnd_wipe_fwdpkgs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

0 comments on commit 13277b7

Please sign in to comment.