Skip to content

Commit

Permalink
itest: shuffle test cases to even out blocks mined in tranches
Browse files Browse the repository at this point in the history
This commit shuffles all the test cases before running them so tests
which require lots of blocks to be mined are less likely to be run in
the same tranch.

The other benefit is this approach provides a more efficient way to
figure which tests are broken since all the differnet backends are
running different tranches in their builds, we can identify more failed
tests in one push.
  • Loading branch information
yyforyongyu committed Oct 24, 2024
1 parent 8fac9a0 commit 50e5738
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 11 deletions.
14 changes: 13 additions & 1 deletion itest/list_on_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

package itest

import "github.com/lightningnetwork/lnd/lntest"
import (
"math/rand"

"github.com/lightningnetwork/lnd/lntest"
)

var allTestCases = []*lntest.TestCase{
{
Expand Down Expand Up @@ -683,4 +687,12 @@ var allTestCases = []*lntest.TestCase{
func init() {
// Register subtests.
allTestCases = append(allTestCases, multiHopForceCloseTestCases...)

// Shuffle the test cases so they are executed in a random order. This
// is done to even out the blocks mined in each test tranche so they
// can run faster.
rand.Shuffle(len(allTestCases), func(i, j int) {
allTestCases[i], allTestCases[j] =
allTestCases[j], allTestCases[i]
})
}
18 changes: 8 additions & 10 deletions itest/lnd_payment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -466,17 +466,15 @@ func testSendDirectPayment(ht *lntest.HarnessTest) {
}

func testListPayments(ht *lntest.HarnessTest) {
alice, bob := ht.Alice, ht.Bob

// Check that there are no payments before test.
ht.AssertNumPayments(alice, 0)
// Prepare test params.
chanAmt := btcutil.Amount(100000)
params := lntest.OpenChannelParams{Amt: chanAmt}

// Open a channel with 100k satoshis between Alice and Bob with Alice
// being the sole funder of the channel.
chanAmt := btcutil.Amount(100000)
chanPoint := ht.OpenChannel(
alice, bob, lntest.OpenChannelParams{Amt: chanAmt},
)
// being the sole funder of the channel. We use fresh nodes here so
// they don't have old invoices or payments.
chanPoints, nodes := createSimpleNetwork(ht, nil, 2, params)

Check failure on line 476 in itest/lnd_payment_test.go

View workflow job for this annotation

GitHub Actions / run macOS itest

undefined: createSimpleNetwork

Check failure on line 476 in itest/lnd_payment_test.go

View workflow job for this annotation

GitHub Actions / run windows itest

undefined: createSimpleNetwork

Check failure on line 476 in itest/lnd_payment_test.go

View workflow job for this annotation

GitHub Actions / lint code

undefined: createSimpleNetwork (typecheck)
alice, bob := nodes[0], nodes[1]

// Now that the channel is open, create an invoice for Bob which
// expects a payment of 1000 satoshis from Alice paid via a particular
Expand Down Expand Up @@ -645,7 +643,7 @@ func testListPayments(ht *lntest.HarnessTest) {
time.Sleep(2 * time.Second)

// Close the channel.
ht.CloseChannel(alice, chanPoint)
ht.CloseChannel(alice, chanPoints[0])
}

// testPaymentFollowingChannelOpen tests that the channel transition from
Expand Down

0 comments on commit 50e5738

Please sign in to comment.