itest: further reduce block mined in tests
This commit is contained in:
5 files changed
+30
-51
No files matched your search
@@ -1499,7 +1499,6 @@ func assertTimeLockSwept(ht *lntest.HarnessTest, carol, dave *node.HarnessNode,
|
|||||||
ht.AssertNumPendingSweeps(dave, 2)
|
ht.AssertNumPendingSweeps(dave, 2)
|
||||||
|
|
||||||
// Mine a block to trigger the sweeps.
|
// Mine a block to trigger the sweeps.
|
||||||
ht.MineEmptyBlocks(1)
|
|
||||||
daveSweep := ht.AssertNumTxsInMempool(1)[0]
|
daveSweep := ht.AssertNumTxsInMempool(1)[0]
|
||||||
block := ht.MineBlocksAndAssertNumTxes(1, 1)[0]
|
block := ht.MineBlocksAndAssertNumTxes(1, 1)[0]
|
||||||
ht.AssertTxInBlock(block, daveSweep)
|
ht.AssertTxInBlock(block, daveSweep)
|
||||||
|
|||||||
@@ -94,21 +94,17 @@ func testEstimateRouteFee(ht *lntest.HarnessTest) {
|
|||||||
// added to the invoice always have enough liquidity, but here we check
|
// added to the invoice always have enough liquidity, but here we check
|
||||||
// that the prober uses the more expensive route.
|
// that the prober uses the more expensive route.
|
||||||
ht.EnsureConnected(mts.bob, paula)
|
ht.EnsureConnected(mts.bob, paula)
|
||||||
channelPointBobPaula := ht.OpenChannel(
|
ht.OpenChannel(mts.bob, paula, lntest.OpenChannelParams{
|
||||||
mts.bob, paula, lntest.OpenChannelParams{
|
Private: true,
|
||||||
Private: true,
|
Amt: 90_000,
|
||||||
Amt: 90_000,
|
PushAmt: 69_000,
|
||||||
PushAmt: 69_000,
|
})
|
||||||
},
|
|
||||||
)
|
|
||||||
|
|
||||||
ht.EnsureConnected(mts.eve, paula)
|
ht.EnsureConnected(mts.eve, paula)
|
||||||
channelPointEvePaula := ht.OpenChannel(
|
ht.OpenChannel(mts.eve, paula, lntest.OpenChannelParams{
|
||||||
mts.eve, paula, lntest.OpenChannelParams{
|
Private: true,
|
||||||
Private: true,
|
Amt: 1_000_000,
|
||||||
Amt: 1_000_000,
|
})
|
||||||
},
|
|
||||||
)
|
|
||||||
|
|
||||||
bobsPrivChannels := mts.bob.RPC.ListChannels(&lnrpc.ListChannelsRequest{
|
bobsPrivChannels := mts.bob.RPC.ListChannels(&lnrpc.ListChannelsRequest{
|
||||||
PrivateOnly: true,
|
PrivateOnly: true,
|
||||||
@@ -243,6 +239,8 @@ func testEstimateRouteFee(ht *lntest.HarnessTest) {
|
|||||||
locktime := initialBlockHeight + defaultTimelock +
|
locktime := initialBlockHeight + defaultTimelock +
|
||||||
int64(routing.BlockPadding)
|
int64(routing.BlockPadding)
|
||||||
|
|
||||||
|
noChanNode := ht.NewNode("ImWithoutChannels", nil)
|
||||||
|
|
||||||
var testCases = []*estimateRouteFeeTestCase{
|
var testCases = []*estimateRouteFeeTestCase{
|
||||||
// Single hop payment is free.
|
// Single hop payment is free.
|
||||||
{
|
{
|
||||||
@@ -304,10 +302,8 @@ func testEstimateRouteFee(ht *lntest.HarnessTest) {
|
|||||||
{
|
{
|
||||||
name: "single hop hint, destination " +
|
name: "single hop hint, destination " +
|
||||||
"without channels",
|
"without channels",
|
||||||
probing: true,
|
probing: true,
|
||||||
destination: ht.NewNode(
|
destination: noChanNode,
|
||||||
"ImWithoutChannels", nil,
|
|
||||||
),
|
|
||||||
routeHints: singleRouteHint,
|
routeHints: singleRouteHint,
|
||||||
expectedRoutingFeesMsat: feeACBP,
|
expectedRoutingFeesMsat: feeACBP,
|
||||||
expectedCltvDelta: locktime + deltaACBP,
|
expectedCltvDelta: locktime + deltaACBP,
|
||||||
@@ -357,12 +353,6 @@ func testEstimateRouteFee(ht *lntest.HarnessTest) {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mts.ht.CloseChannelAssertPending(mts.bob, channelPointBobPaula, false)
|
|
||||||
mts.ht.CloseChannelAssertPending(mts.eve, channelPointEvePaula, false)
|
|
||||||
ht.MineBlocksAndAssertNumTxes(1, 2)
|
|
||||||
|
|
||||||
mts.closeChannels()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// runTestCase runs a single test case asserting that test conditions are met.
|
// runTestCase runs a single test case asserting that test conditions are met.
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ func testHoldInvoiceForceClose(ht *lntest.HarnessTest) {
|
|||||||
)
|
)
|
||||||
invoiceReq := &invoicesrpc.AddHoldInvoiceRequest{
|
invoiceReq := &invoicesrpc.AddHoldInvoiceRequest{
|
||||||
Value: 30000,
|
Value: 30000,
|
||||||
CltvExpiry: 40,
|
CltvExpiry: finalCltvDelta,
|
||||||
Hash: payHash[:],
|
Hash: payHash[:],
|
||||||
}
|
}
|
||||||
bobInvoice := bob.RPC.AddHoldInvoice(invoiceReq)
|
bobInvoice := bob.RPC.AddHoldInvoice(invoiceReq)
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import (
|
|||||||
"crypto/sha256"
|
"crypto/sha256"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/btcsuite/btcd/btcec/v2"
|
"github.com/btcsuite/btcd/btcec/v2"
|
||||||
@@ -19,6 +20,10 @@ import (
|
|||||||
"github.com/stretchr/testify/require"
|
"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,
|
// 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
|
// 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
|
// that uses Carol as the introduction node (plus dummy hops to cover multiple
|
||||||
@@ -346,14 +351,18 @@ func newBlindedForwardTest(ht *lntest.HarnessTest) (context.Context,
|
|||||||
func (b *blindedForwardTest) setupNetwork(ctx context.Context,
|
func (b *blindedForwardTest) setupNetwork(ctx context.Context,
|
||||||
withInterceptor bool) {
|
withInterceptor bool) {
|
||||||
|
|
||||||
const chanAmt = btcutil.Amount(100_000)
|
carolArgs := []string{
|
||||||
|
"--bitcoin.timelockdelta=18",
|
||||||
carolArgs := []string{"--bitcoin.timelockdelta=18"}
|
fmt.Sprintf("--bitcoin.defaultremotedelay=%v", toLocalCSV),
|
||||||
|
}
|
||||||
if withInterceptor {
|
if withInterceptor {
|
||||||
carolArgs = append(carolArgs, "--requireinterceptor")
|
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}
|
cfgs := [][]string{nil, nil, carolArgs, daveArgs}
|
||||||
param := lntest.OpenChannelParams{
|
param := lntest.OpenChannelParams{
|
||||||
Amt: chanAmt,
|
Amt: chanAmt,
|
||||||
@@ -780,11 +789,11 @@ func testErrorHandlingOnChainFailure(ht *lntest.HarnessTest) {
|
|||||||
|
|
||||||
// SuspendCarol so that she can't interfere with the resolution of the
|
// SuspendCarol so that she can't interfere with the resolution of the
|
||||||
// HTLC from now on.
|
// HTLC from now on.
|
||||||
restartCarol := ht.SuspendNode(testCase.carol)
|
ht.SuspendNode(testCase.carol)
|
||||||
|
|
||||||
// Mine blocks so that Bob will claim his CSV delayed local commitment,
|
// 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.
|
// 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.AssertNumPendingSweeps(bob, 1)
|
||||||
ht.MineBlocksAndAssertNumTxes(1, 1)
|
ht.MineBlocksAndAssertNumTxes(1, 1)
|
||||||
|
|
||||||
@@ -797,6 +806,7 @@ func testErrorHandlingOnChainFailure(ht *lntest.HarnessTest) {
|
|||||||
// value.
|
// value.
|
||||||
info := bob.RPC.GetInfo()
|
info := bob.RPC.GetInfo()
|
||||||
target := carolHTLC.IncomingExpiry - info.BlockHeight
|
target := carolHTLC.IncomingExpiry - info.BlockHeight
|
||||||
|
ht.Log(carolHTLC.IncomingExpiry, info.BlockHeight, target)
|
||||||
ht.MineBlocks(int(target))
|
ht.MineBlocks(int(target))
|
||||||
|
|
||||||
// Wait for Bob's timeout transaction in the mempool, since we've
|
// Wait for Bob's timeout transaction in the mempool, since we've
|
||||||
@@ -819,23 +829,6 @@ func testErrorHandlingOnChainFailure(ht *lntest.HarnessTest) {
|
|||||||
lnrpc.Failure_INVALID_ONION_BLINDING,
|
lnrpc.Failure_INVALID_ONION_BLINDING,
|
||||||
)
|
)
|
||||||
|
|
||||||
// Clean up the rest of our force close: mine blocks so that Bob's CSV
|
|
||||||
// expires to trigger his sweep and then mine it.
|
|
||||||
ht.MineBlocks(node.DefaultCSV)
|
|
||||||
ht.AssertNumPendingSweeps(bob, 1)
|
|
||||||
ht.MineBlocksAndAssertNumTxes(1, 1)
|
|
||||||
|
|
||||||
// Bring carol back up so that we can close out the rest of our
|
|
||||||
// channels cooperatively. She requires an interceptor to start up
|
|
||||||
// so we just re-register our interceptor.
|
|
||||||
require.NoError(ht, restartCarol())
|
|
||||||
_, err = testCase.carol.RPC.Router.HtlcInterceptor(ctx)
|
|
||||||
require.NoError(ht, err, "interceptor")
|
|
||||||
|
|
||||||
// Assert that Carol has started up and reconnected to dave so that
|
|
||||||
// we can close out channels cooperatively.
|
|
||||||
ht.EnsureConnected(testCase.carol, testCase.dave)
|
|
||||||
|
|
||||||
// Manually close out the rest of our channels and cancel (don't use
|
// Manually close out the rest of our channels and cancel (don't use
|
||||||
// built in cleanup which will try close the already-force-closed
|
// built in cleanup which will try close the already-force-closed
|
||||||
// channel).
|
// channel).
|
||||||
|
|||||||
@@ -106,7 +106,4 @@ func testWipeForwardingPackages(ht *lntest.HarnessTest) {
|
|||||||
|
|
||||||
// Mine 1 block to get Alice's sweeping tx confirmed.
|
// Mine 1 block to get Alice's sweeping tx confirmed.
|
||||||
ht.MineBlocksAndAssertNumTxes(1, 1)
|
ht.MineBlocksAndAssertNumTxes(1, 1)
|
||||||
|
|
||||||
// Clean up the force closed channel.
|
|
||||||
ht.CleanupForceClose(bob)
|
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user