itest: reduce blocks mined to save sync time
This commit is contained in:
11 files changed
+46
-29
No files matched your search
+23
-2
@@ -292,10 +292,22 @@ func (h *HarnessTest) Subtest(t *testing.T) (*HarnessTest, func()) {
|
||||
// Inherit context from the main test.
|
||||
st.runCtx, st.cancel = context.WithCancel(h.runCtx)
|
||||
|
||||
// Inherit the subtest for the miner.
|
||||
st.Miner.T = st.T
|
||||
|
||||
// Reset the standby nodes.
|
||||
st.resetStandbyNodes(t)
|
||||
|
||||
// Record block height.
|
||||
_, startHeight := h.Miner.GetBestBlock()
|
||||
|
||||
cleanup := func() {
|
||||
_, endHeight := h.Miner.GetBestBlock()
|
||||
|
||||
st.Logf("finished test: %s, start height=%d, end height=%d, "+
|
||||
"mined blocks=%d", st.manager.currentTestCase,
|
||||
startHeight, endHeight, endHeight-startHeight)
|
||||
|
||||
// Don't bother run the cleanups if the test is failed.
|
||||
if st.Failed() {
|
||||
st.Log("test failed, skipped cleanup")
|
||||
@@ -920,10 +932,10 @@ func (h *HarnessTest) fundCoins(amt btcutil.Amount, target *node.HarnessNode,
|
||||
return
|
||||
}
|
||||
|
||||
// Otherwise, we'll generate 2 new blocks to ensure the output gains a
|
||||
// Otherwise, we'll generate 1 new blocks to ensure the output gains a
|
||||
// sufficient number of confirmations and wait for the balance to
|
||||
// reflect what's expected.
|
||||
h.Miner.MineBlocks(2)
|
||||
h.Miner.MineBlocks(1)
|
||||
|
||||
expectedBalance := btcutil.Amount(initialBalance.ConfirmedBalance) + amt
|
||||
h.WaitForBalanceConfirmed(target, expectedBalance)
|
||||
@@ -936,6 +948,15 @@ func (h *HarnessTest) FundCoins(amt btcutil.Amount, hn *node.HarnessNode) {
|
||||
h.fundCoins(amt, hn, lnrpc.AddressType_WITNESS_PUBKEY_HASH, true)
|
||||
}
|
||||
|
||||
// FundCoinsUnconfirmed attempts to send amt satoshis from the internal mining
|
||||
// node to the targeted lightning node using a P2WKH address. No blocks are
|
||||
// mined after and the UTXOs are unconfirmed.
|
||||
func (h *HarnessTest) FundCoinsUnconfirmed(amt btcutil.Amount,
|
||||
hn *node.HarnessNode) {
|
||||
|
||||
h.fundCoins(amt, hn, lnrpc.AddressType_WITNESS_PUBKEY_HASH, false)
|
||||
}
|
||||
|
||||
// CompletePaymentRequests sends payments from a node to complete all payment
|
||||
// requests. This function does not return until all payments successfully
|
||||
// complete without errors.
|
||||
|
||||
@@ -990,7 +990,7 @@ func testChanRestoreScenario(ht *lntemp.HarnessTest,
|
||||
var fundingShim *lnrpc.FundingShim
|
||||
if testCase.commitmentType == lnrpc.CommitmentType_SCRIPT_ENFORCED_LEASE {
|
||||
_, minerHeight := ht.Miner.GetBestBlock()
|
||||
thawHeight := uint32(minerHeight + 144)
|
||||
thawHeight := uint32(minerHeight + thawHeightDelta)
|
||||
|
||||
fundingShim, _, _ = deriveFundingShim(
|
||||
ht, from, to, chanAmt, thawHeight, true,
|
||||
@@ -1512,7 +1512,7 @@ func assertTimeLockSwept(ht *lntemp.HarnessTest,
|
||||
// The commit sweep resolver publishes the sweep tx at defaultCSV-1 and
|
||||
// we already mined one block after the commitment was published, so
|
||||
// take that into account.
|
||||
ht.Miner.MineBlocks(defaultCSV - 1 - 1)
|
||||
ht.MineBlocksAssertNodesSync(defaultCSV - 1 - 1)
|
||||
daveSweep := ht.Miner.AssertNumTxsInMempool(1)[0]
|
||||
block := ht.Miner.MineBlocksAndAssertNumTxes(1, 1)[0]
|
||||
ht.Miner.AssertTxInBlock(block, daveSweep)
|
||||
|
||||
@@ -23,8 +23,6 @@ import (
|
||||
func testMultiHopHtlcAggregation(ht *lntemp.HarnessTest,
|
||||
alice, bob *node.HarnessNode, c lnrpc.CommitmentType, zeroConf bool) {
|
||||
|
||||
const finalCltvDelta = 40
|
||||
|
||||
// First, we'll create a three hop network: Alice -> Bob -> Carol.
|
||||
aliceChanPoint, bobChanPoint, carol := createThreeHopNetwork(
|
||||
ht, alice, bob, false, c, zeroConf,
|
||||
|
||||
@@ -35,7 +35,7 @@ func testMultiHopHtlcLocalChainClaim(ht *lntemp.HarnessTest,
|
||||
payHash := preimage.Hash()
|
||||
invoiceReq := &invoicesrpc.AddHoldInvoiceRequest{
|
||||
Value: invoiceAmt,
|
||||
CltvExpiry: 40,
|
||||
CltvExpiry: finalCltvDelta,
|
||||
Hash: payHash[:],
|
||||
}
|
||||
carolInvoice := carol.RPC.AddHoldInvoice(invoiceReq)
|
||||
|
||||
@@ -30,9 +30,8 @@ func testMultiHopHtlcLocalTimeout(ht *lntemp.HarnessTest,
|
||||
// to Carol. The first HTLC will be universally considered "dust",
|
||||
// while the second will be a proper fully valued HTLC.
|
||||
const (
|
||||
dustHtlcAmt = btcutil.Amount(100)
|
||||
htlcAmt = btcutil.Amount(300_000)
|
||||
finalCltvDelta = 40
|
||||
dustHtlcAmt = btcutil.Amount(100)
|
||||
htlcAmt = btcutil.Amount(300_000)
|
||||
)
|
||||
|
||||
// We'll create two random payment hashes unknown to carol, then send
|
||||
|
||||
@@ -37,7 +37,7 @@ func testMultiHopReceiverChainClaim(ht *lntemp.HarnessTest,
|
||||
payHash := preimage.Hash()
|
||||
invoiceReq := &invoicesrpc.AddHoldInvoiceRequest{
|
||||
Value: invoiceAmt,
|
||||
CltvExpiry: 40,
|
||||
CltvExpiry: finalCltvDelta,
|
||||
Hash: payHash[:],
|
||||
}
|
||||
carolInvoice := carol.RPC.AddHoldInvoice(invoiceReq)
|
||||
|
||||
@@ -36,7 +36,7 @@ func testMultiHopHtlcRemoteChainClaim(ht *lntemp.HarnessTest,
|
||||
payHash := preimage.Hash()
|
||||
invoiceReq := &invoicesrpc.AddHoldInvoiceRequest{
|
||||
Value: invoiceAmt,
|
||||
CltvExpiry: 40,
|
||||
CltvExpiry: finalCltvDelta,
|
||||
Hash: payHash[:],
|
||||
}
|
||||
carolInvoice := carol.RPC.AddHoldInvoice(invoiceReq)
|
||||
|
||||
@@ -28,10 +28,7 @@ func testMultiHopLocalForceCloseOnChainHtlcTimeout(ht *lntemp.HarnessTest,
|
||||
// With our channels set up, we'll then send a single HTLC from Alice
|
||||
// to Carol. As Carol is in hodl mode, she won't settle this HTLC which
|
||||
// opens up the base for out tests.
|
||||
const (
|
||||
finalCltvDelta = 40
|
||||
htlcAmt = btcutil.Amount(300_000)
|
||||
)
|
||||
const htlcAmt = btcutil.Amount(300_000)
|
||||
|
||||
// We'll now send a single HTLC across our multi-hop network.
|
||||
carolPubKey := carol.PubKey[:]
|
||||
|
||||
@@ -30,10 +30,7 @@ func testMultiHopRemoteForceCloseOnChainHtlcTimeout(ht *lntemp.HarnessTest,
|
||||
// With our channels set up, we'll then send a single HTLC from Alice
|
||||
// to Carol. As Carol is in hodl mode, she won't settle this HTLC which
|
||||
// opens up the base for out tests.
|
||||
const (
|
||||
finalCltvDelta = 40
|
||||
htlcAmt = btcutil.Amount(30000)
|
||||
)
|
||||
const htlcAmt = btcutil.Amount(30000)
|
||||
|
||||
// We'll now send a single HTLC across our multi-hop network.
|
||||
var preimage lntypes.Preimage
|
||||
@@ -41,7 +38,7 @@ func testMultiHopRemoteForceCloseOnChainHtlcTimeout(ht *lntemp.HarnessTest,
|
||||
payHash := preimage.Hash()
|
||||
invoiceReq := &invoicesrpc.AddHoldInvoiceRequest{
|
||||
Value: int64(htlcAmt),
|
||||
CltvExpiry: 40,
|
||||
CltvExpiry: finalCltvDelta,
|
||||
Hash: payHash[:],
|
||||
}
|
||||
carolInvoice := carol.RPC.AddHoldInvoice(invoiceReq)
|
||||
|
||||
@@ -15,6 +15,12 @@ import (
|
||||
"github.com/lightningnetwork/lnd/lntemp/rpc"
|
||||
"github.com/lightningnetwork/lnd/lntest"
|
||||
"github.com/lightningnetwork/lnd/lntypes"
|
||||
"github.com/lightningnetwork/lnd/routing"
|
||||
)
|
||||
|
||||
const (
|
||||
finalCltvDelta = routing.MinCLTVDelta // 18.
|
||||
thawHeightDelta = finalCltvDelta * 2 // 36.
|
||||
)
|
||||
|
||||
func testMultiHopHtlcClaims(ht *lntemp.HarnessTest) {
|
||||
@@ -280,9 +286,12 @@ func createThreeHopNetwork(ht *lntemp.HarnessTest,
|
||||
// needs to be attached as an additional input. This can still lead to
|
||||
// a positively-yielding transaction.
|
||||
for i := 0; i < 2; i++ {
|
||||
ht.FundCoins(btcutil.SatoshiPerBitcoin, alice)
|
||||
ht.FundCoins(btcutil.SatoshiPerBitcoin, bob)
|
||||
ht.FundCoins(btcutil.SatoshiPerBitcoin, carol)
|
||||
ht.FundCoinsUnconfirmed(btcutil.SatoshiPerBitcoin, alice)
|
||||
ht.FundCoinsUnconfirmed(btcutil.SatoshiPerBitcoin, bob)
|
||||
ht.FundCoinsUnconfirmed(btcutil.SatoshiPerBitcoin, carol)
|
||||
|
||||
// Mine 1 block to get the above coins confirmed.
|
||||
ht.MineBlocksAssertNodesSync(1)
|
||||
}
|
||||
|
||||
// We'll start the test by creating a channel between Alice and Bob,
|
||||
@@ -292,7 +301,7 @@ func createThreeHopNetwork(ht *lntemp.HarnessTest,
|
||||
var thawHeight uint32
|
||||
if c == lnrpc.CommitmentType_SCRIPT_ENFORCED_LEASE {
|
||||
_, minerHeight := ht.Miner.GetBestBlock()
|
||||
thawHeight = uint32(minerHeight + 144)
|
||||
thawHeight = uint32(minerHeight + thawHeightDelta)
|
||||
aliceFundingShim, _, _ = deriveFundingShim(
|
||||
ht, alice, bob, chanAmt, thawHeight, true,
|
||||
)
|
||||
|
||||
@@ -127,10 +127,6 @@ func TestLightningNetworkDaemonTemp(t *testing.T) {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
_, height := harnessTest.Miner.GetBestBlock()
|
||||
t.Logf("=========> tests finished for tranche: %v, tested %d "+
|
||||
"cases, end height: %d\n", trancheIndex, len(testCases), height)
|
||||
}
|
||||
|
||||
// getTestCaseSplitTranche returns the sub slice of the test cases that should
|
||||
|
||||
Reference in new issue
Block a user