Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Beat itest [2/3]: document and fix itest flakes #9307

Open
wants to merge 19 commits into
base: yy-beat-itest-shuffle
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
a51913b
itest: fix spawning temp miner
yyforyongyu Oct 29, 2024
488eedd
itest: fix flake for neutrino backend
yyforyongyu Oct 30, 2024
2e1b6f0
itest: flatten PSBT funding test cases
yyforyongyu Oct 30, 2024
9a7b423
itest: fix and document flake in sweeping tests
yyforyongyu Oct 30, 2024
25579b2
itest: remove loop in `wsTestCaseBiDirectionalSubscription`
yyforyongyu Oct 30, 2024
9429aa2
itest: fix flake in `testRevokedCloseRetributionZeroValueRemoteOutput`
yyforyongyu Nov 2, 2024
443df7d
itest: fix flake in `testSwitchOfflineDelivery`
yyforyongyu Nov 3, 2024
8a96956
itest+routing: fix flake in `runFeeEstimationTestCase`
yyforyongyu Nov 3, 2024
ea80377
itest: use `ht.CreateSimpleNetwork` whenever applicable
yyforyongyu Nov 3, 2024
51dd469
itest: put mpp tests in one file
yyforyongyu Nov 4, 2024
4b41ac0
lntest+itest: remove `AssertNumActiveEdges`
yyforyongyu Nov 8, 2024
1ed44c7
itest: fix flake in runPsbtChanFundingWithNodes
yyforyongyu Nov 10, 2024
f6a4f73
itest: fix flake in `testPrivateUpdateAlias`
yyforyongyu Nov 16, 2024
bfa28f5
itest: fix flake in `update_pending_open_channels`
yyforyongyu Nov 16, 2024
f535600
lntest: increase `rpcmaxwebsockets` for `btcd`
yyforyongyu Nov 20, 2024
1f1ba67
itest: document details about MPP-related tests
yyforyongyu Nov 21, 2024
88e6a96
itest+lntest: fix flake in MPP-related tests
yyforyongyu Nov 21, 2024
1037156
lntest: fix flakeness in `openChannelsForNodes`
yyforyongyu Nov 22, 2024
8abca8c
itest: document a rare flake found in `macOS`
yyforyongyu Dec 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions itest/list_on_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,10 +283,6 @@ var allTestCases = []*lntest.TestCase{
Name: "open channel reorg test",
TestFunc: testOpenChannelAfterReorg,
},
{
Name: "psbt channel funding",
TestFunc: testPsbtChanFunding,
},
{
Name: "sign psbt",
TestFunc: testSignPsbt,
Expand Down Expand Up @@ -573,8 +569,12 @@ var allTestCases = []*lntest.TestCase{
TestFunc: testChannelUtxoSelection,
},
{
Name: "update pending open channels",
TestFunc: testUpdateOnPendingOpenChannels,
Name: "update pending open channels on funder side",
TestFunc: testUpdateOnFunderPendingOpenChannels,
},
{
Name: "update pending open channels on fundee side",
TestFunc: testUpdateOnFundeePendingOpenChannels,
},
{
Name: "blinded payment htlc re-forward",
Expand Down Expand Up @@ -694,4 +694,5 @@ func init() {
// Register subtests.
allTestCases = append(allTestCases, multiHopForceCloseTestCases...)
allTestCases = append(allTestCases, watchtowerTestCases...)
allTestCases = append(allTestCases, psbtFundingTestCases...)
}
47 changes: 7 additions & 40 deletions itest/lnd_amp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ func testSendPaymentAMPInvoiceCase(ht *lntest.HarnessTest,
req := &lnrpc.InvoiceSubscription{}
bobInvoiceSubscription := mts.bob.RPC.SubscribeInvoices(req)

const paymentAmt = btcutil.Amount(300000)

// Set up a network with three different paths Alice <-> Bob. Channel
// capacities are set such that the payment can only succeed if (at
// least) three paths are used.
Expand All @@ -59,15 +57,8 @@ func testSendPaymentAMPInvoiceCase(ht *lntest.HarnessTest,
// \ /
// \__ Dave ____/
//
mppReq := &mppOpenChannelRequest{
amtAliceCarol: 285000,
amtAliceDave: 155000,
amtCarolBob: 200000,
amtCarolEve: 155000,
amtDaveBob: 155000,
amtEveBob: 155000,
}
mts.openChannels(mppReq)
paymentAmt := mts.setupSendPaymentCase()

chanPointAliceDave := mts.channelPoints[1]
chanPointDaveBob := mts.channelPoints[4]

Expand Down Expand Up @@ -373,7 +364,6 @@ func testSendPaymentAMPInvoiceRepeat(ht *lntest.HarnessTest) {
// destination using SendPaymentV2.
func testSendPaymentAMP(ht *lntest.HarnessTest) {
mts := newMppTestScenario(ht)
const paymentAmt = btcutil.Amount(300000)

// Set up a network with three different paths Alice <-> Bob. Channel
// capacities are set such that the payment can only succeed if (at
Expand All @@ -385,15 +375,8 @@ func testSendPaymentAMP(ht *lntest.HarnessTest) {
// \ /
// \__ Dave ____/
//
mppReq := &mppOpenChannelRequest{
amtAliceCarol: 285000,
amtAliceDave: 155000,
amtCarolBob: 200000,
amtCarolEve: 155000,
amtDaveBob: 155000,
amtEveBob: 155000,
}
mts.openChannels(mppReq)
paymentAmt := mts.setupSendPaymentCase()

chanPointAliceDave := mts.channelPoints[1]

// Increase Dave's fee to make the test deterministic. Otherwise, it
Expand Down Expand Up @@ -497,12 +480,6 @@ func testSendPaymentAMP(ht *lntest.HarnessTest) {

func testSendToRouteAMP(ht *lntest.HarnessTest) {
mts := newMppTestScenario(ht)
const (
paymentAmt = btcutil.Amount(300000)
numShards = 3
shardAmt = paymentAmt / numShards
chanAmt = shardAmt * 3 / 2
)

// Subscribe to bob's invoices.
req := &lnrpc.InvoiceSubscription{}
Expand All @@ -515,20 +492,10 @@ func testSendToRouteAMP(ht *lntest.HarnessTest) {
// \ /
// \__ Dave ____/
//
mppReq := &mppOpenChannelRequest{
// Since the channel Alice-> Carol will have to carry two
// shards, we make it larger.
amtAliceCarol: chanAmt + shardAmt,
amtAliceDave: chanAmt,
amtCarolBob: chanAmt,
amtCarolEve: chanAmt,
amtDaveBob: chanAmt,
amtEveBob: chanAmt,
}
mts.openChannels(mppReq)
paymentAmt, shardAmt := mts.setupSendToRouteCase()

// We'll send shards along three routes from Alice.
sendRoutes := [numShards][]*node.HarnessNode{
sendRoutes := [][]*node.HarnessNode{
{mts.carol, mts.bob},
{mts.dave, mts.bob},
{mts.carol, mts.eve, mts.bob},
Expand Down Expand Up @@ -662,7 +629,7 @@ func testSendToRouteAMP(ht *lntest.HarnessTest) {

// Finally, assert that the proper set id is recorded for each htlc, and
// that the preimage hash pair is valid.
require.Equal(ht, numShards, len(rpcInvoice.Htlcs))
require.Equal(ht, 3, len(rpcInvoice.Htlcs))
for _, htlc := range rpcInvoice.Htlcs {
require.NotNil(ht, htlc.Amp)
require.Equal(ht, setID, htlc.Amp.SetId)
Expand Down
16 changes: 16 additions & 0 deletions itest/lnd_channel_force_close_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,22 @@ func runChannelForceClosureTest(ht *lntest.HarnessTest,
"sweep transaction not spending from commit")
}

// For neutrino backend, due to it has no mempool, we need to check the
// sweep tx has already been saved to db before restarting. This is due
// to the possible race,
// - the fee bumper returns a TxPublished event, which is received by
// the sweeper and the sweep tx is saved to db.
// - the sweeper receives a shutdown signal before it receives the
// above event.
//
// TODO(yy): fix the above race.
if ht.IsNeutrinoBackend() {
// Check that we can find the commitment sweep in our set of
// known sweeps, using the simple transaction id ListSweeps
// output.
ht.AssertSweepFound(alice, sweepingTXID.String(), false, 0)
}

// Restart Alice to ensure that she resumes watching the finalized
// commitment sweep txid.
ht.RestartNode(alice)
Expand Down
6 changes: 3 additions & 3 deletions itest/lnd_channel_graph_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,17 +237,17 @@ func testUnannouncedChannels(ht *lntest.HarnessTest) {
ht.WaitForChannelOpenEvent(chanOpenUpdate)

// Alice should have 1 edge in her graph.
ht.AssertNumActiveEdges(alice, 1, true)
ht.AssertNumEdges(alice, 1, true)

// Channels should not be announced yet, hence Alice should have no
// announced edges in her graph.
ht.AssertNumActiveEdges(alice, 0, false)
ht.AssertNumEdges(alice, 0, false)

// Mine 4 more blocks, and check that the channel is now announced.
ht.MineBlocks(4)

// Give the network a chance to learn that auth proof is confirmed.
ht.AssertNumActiveEdges(alice, 1, false)
ht.AssertNumEdges(alice, 1, false)
}

func testGraphTopologyNotifications(ht *lntest.HarnessTest) {
Expand Down
3 changes: 2 additions & 1 deletion itest/lnd_estimate_route_fee_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/lightningnetwork/lnd/lnrpc/routerrpc"
"github.com/lightningnetwork/lnd/lntest"
"github.com/lightningnetwork/lnd/lntest/node"
"github.com/lightningnetwork/lnd/lntest/wait"
"github.com/lightningnetwork/lnd/routing"
"github.com/stretchr/testify/require"
)
Expand Down Expand Up @@ -376,7 +377,7 @@ func runFeeEstimationTestCase(ht *lntest.HarnessTest,
)
feeReq = &routerrpc.RouteFeeRequest{
PaymentRequest: payReqs[0],
Timeout: 10,
Timeout: uint32(wait.PaymentTimeout.Seconds()),
}
} else {
feeReq = &routerrpc.RouteFeeRequest{
Expand Down
34 changes: 8 additions & 26 deletions itest/lnd_experimental_endorsement.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/lightningnetwork/lnd/lnrpc"
"github.com/lightningnetwork/lnd/lnrpc/routerrpc"
"github.com/lightningnetwork/lnd/lntest"
"github.com/lightningnetwork/lnd/lntest/node"
"github.com/lightningnetwork/lnd/lntest/rpc"
"github.com/lightningnetwork/lnd/lntest/wait"
"github.com/lightningnetwork/lnd/lntypes"
Expand All @@ -24,37 +25,18 @@ func testExperimentalEndorsement(ht *lntest.HarnessTest) {
// testEndorsement sets up a 5 hop network and tests propagation of
// experimental endorsement signals.
func testEndorsement(ht *lntest.HarnessTest, aliceEndorse bool) {
alice := ht.NewNodeWithCoins("Alice", nil)
bob := ht.NewNodeWithCoins("Bob", nil)
carol := ht.NewNode(
"carol", []string{"--protocol.no-experimental-endorsement"},
cfg := node.CfgAnchor
carolCfg := append(
[]string{"--protocol.no-experimental-endorsement"}, cfg...,
)
dave := ht.NewNode("dave", nil)
eve := ht.NewNode("eve", nil)
cfgs := [][]string{cfg, cfg, carolCfg, cfg, cfg}

ht.EnsureConnected(alice, bob)
ht.EnsureConnected(bob, carol)
ht.EnsureConnected(carol, dave)
ht.EnsureConnected(dave, eve)

ht.FundCoins(btcutil.SatoshiPerBitcoin, carol)
ht.FundCoins(btcutil.SatoshiPerBitcoin, dave)
// Open and wait for channels.
const chanAmt = btcutil.Amount(300000)
p := lntest.OpenChannelParams{Amt: chanAmt}
reqs := []*lntest.OpenChannelRequest{
{Local: alice, Remote: bob, Param: p},
{Local: bob, Remote: carol, Param: p},
{Local: carol, Remote: dave, Param: p},
{Local: dave, Remote: eve, Param: p},
}
resp := ht.OpenMultiChannelsAsync(reqs)
_, cpBC, cpCD, cpDE := resp[0], resp[1], resp[2], resp[3]

// Make sure Alice is aware of Bob=>Carol=>Dave=>Eve channels.
ht.AssertChannelInGraph(alice, cpBC)
ht.AssertChannelInGraph(alice, cpCD)
ht.AssertChannelInGraph(alice, cpDE)
_, nodes := ht.CreateSimpleNetwork(cfgs, p)
alice, bob, carol, dave, eve := nodes[0], nodes[1], nodes[2], nodes[3],
nodes[4]

bobIntercept, cancelBob := bob.RPC.HtlcInterceptor()
defer cancelBob()
Expand Down
Loading
Loading