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 [1/3]: remove the usage of standby nodes #9306

Merged
merged 12 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 3 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ jobs:
run: ./scripts/install_bitcoind.sh $BITCOIN_VERSION

- name: run ${{ matrix.name }}
run: make itest-parallel tranches=${{ env.TRANCHES }} ${{ matrix.args }}
run: make itest-parallel tranches=${{ env.TRANCHES }} ${{ matrix.args }} shuffleseed=${{ github.run_id }}${{ strategy.job-index }}

- name: Send coverage
if: ${{ contains(matrix.args, 'cover=1') }}
Expand Down Expand Up @@ -340,7 +340,7 @@ jobs:
key-prefix: integration-test

- name: run itest
run: make itest-parallel tranches=${{ env.TRANCHES }} windows=1
run: make itest-parallel tranches=${{ env.TRANCHES }} windows=1 shuffleseed=${{ github.run_id }}

- name: kill any remaining lnd processes
if: ${{ failure() }}
Expand Down Expand Up @@ -390,7 +390,7 @@ jobs:
mv bitcoin-${BITCOIN_VERSION}.0 /tmp/bitcoin

- name: run itest
run: PATH=$PATH:/tmp/bitcoin/bin make itest-parallel tranches=${{ env.TRANCHES }} backend=bitcoind
run: PATH=$PATH:/tmp/bitcoin/bin make itest-parallel tranches=${{ env.TRANCHES }} backend=bitcoind shuffleseed=${{ github.run_id }}

- name: Zip log files on failure
if: ${{ failure() }}
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ endif
itest-only: db-instance
@$(call print, "Running integration tests with ${backend} backend.")
rm -rf itest/*.log itest/.logs-*; date
EXEC_SUFFIX=$(EXEC_SUFFIX) scripts/itest_part.sh 0 1 $(TEST_FLAGS) $(ITEST_FLAGS) -test.v
EXEC_SUFFIX=$(EXEC_SUFFIX) scripts/itest_part.sh 0 1 $(SHUFFLE_SEED) $(TEST_FLAGS) $(ITEST_FLAGS) -test.v
$(COLLECT_ITEST_COVERAGE)

#? itest: Build and run integration tests
Expand All @@ -221,7 +221,7 @@ itest-race: build-itest-race itest-only
itest-parallel: build-itest db-instance
@$(call print, "Running tests")
rm -rf itest/*.log itest/.logs-*; date
EXEC_SUFFIX=$(EXEC_SUFFIX) scripts/itest_parallel.sh $(ITEST_PARALLELISM) $(NUM_ITEST_TRANCHES) $(TEST_FLAGS) $(ITEST_FLAGS)
EXEC_SUFFIX=$(EXEC_SUFFIX) scripts/itest_parallel.sh $(ITEST_PARALLELISM) $(NUM_ITEST_TRANCHES) $(SHUFFLE_SEED) $(TEST_FLAGS) $(ITEST_FLAGS)
$(COLLECT_ITEST_COVERAGE)

#? itest-clean: Kill all running itest processes
Expand Down
4 changes: 3 additions & 1 deletion itest/list_on_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

package itest

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

var allTestCases = []*lntest.TestCase{
{
Expand Down
4 changes: 2 additions & 2 deletions itest/lnd_channel_backup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -844,7 +844,7 @@ func runChanRestoreScenarioForceClose(ht *lntest.HarnessTest, zeroConf bool) {
// and the on-disk channel.backup are updated each time a channel is
// opened/closed.
func testChannelBackupUpdates(ht *lntest.HarnessTest) {
alice := ht.Alice
alice := ht.NewNodeWithCoins("Alice", nil)

// First, we'll make a temp directory that we'll use to store our
// backup file, so we can check in on it during the test easily.
Expand Down Expand Up @@ -1052,7 +1052,7 @@ func testExportChannelBackup(ht *lntest.HarnessTest) {

// With Carol up, we'll now connect her to Alice, and open a channel
// between them.
alice := ht.Alice
alice := ht.NewNodeWithCoins("Alice", nil)
ht.ConnectNodes(carol, alice)

// Next, we'll open two channels between Alice and Carol back to back.
Expand Down
12 changes: 3 additions & 9 deletions itest/lnd_channel_balance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ func testChannelBalance(ht *lntest.HarnessTest) {
}

// Before beginning, make sure alice and bob are connected.
alice, bob := ht.Alice, ht.Bob
alice := ht.NewNodeWithCoins("Alice", nil)
bob := ht.NewNode("Bob", nil)
ht.EnsureConnected(alice, bob)

chanPoint := ht.OpenChannel(
Expand All @@ -62,10 +63,6 @@ func testChannelBalance(ht *lntest.HarnessTest) {

// Ensure Bob currently has no available balance within the channel.
checkChannelBalance(bob, 0, amount-lntest.CalcStaticFee(cType, 0))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How are channels and nodes now closed/shutdown to get a fresh state for the next test? Maybe I missed that in the review so far.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So from now on all the nodes are created in each test independently, and are destroyed when the test ends, which means no more standby nodes that will carry their states into other tests.


// Finally close the channel between Alice and Bob, asserting that the
// channel has been properly closed on-chain.
ht.CloseChannel(alice, chanPoint)
}

// testChannelUnsettledBalance will test that the UnsettledBalance field
Expand Down Expand Up @@ -118,7 +115,7 @@ func testChannelUnsettledBalance(ht *lntest.HarnessTest) {
carol := ht.NewNode("Carol", []string{"--hodl.exit-settle"})

// Connect Alice to Carol.
alice := ht.Alice
alice := ht.NewNodeWithCoins("Alice", nil)
ht.ConnectNodes(alice, carol)

// Open a channel between Alice and Carol.
Expand Down Expand Up @@ -207,7 +204,4 @@ func testChannelUnsettledBalance(ht *lntest.HarnessTest) {
// balance that equals to the amount of invoices * payAmt. The local
// balance remains zero.
checkChannelBalance(carol, 0, aliceLocal, numInvoices*payAmt, 0)

// Force and assert the channel closure.
ht.ForceCloseChannel(alice, chanPointAlice)
}
2 changes: 1 addition & 1 deletion itest/lnd_channel_force_close_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -771,7 +771,7 @@ func testFailingChannel(ht *lntest.HarnessTest) {
// totally unrelated preimage.
carol := ht.NewNode("Carol", []string{"--hodl.bogus-settle"})

alice := ht.Alice
alice := ht.NewNodeWithCoins("Alice", nil)
ht.ConnectNodes(alice, carol)

// Let Alice connect and open a channel to Carol,
Expand Down
6 changes: 1 addition & 5 deletions itest/lnd_channel_funding_fund_max_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,7 @@ func testChannelFundMax(ht *lntest.HarnessTest) {
// tests.
args := lntest.NodeArgsForCommitType(lnrpc.CommitmentType_ANCHORS)
alice := ht.NewNode("Alice", args)
defer ht.Shutdown(alice)

bob := ht.NewNode("Bob", args)
defer ht.Shutdown(bob)

// Ensure both sides are connected so the funding flow can be properly
// executed.
Expand Down Expand Up @@ -229,13 +226,12 @@ func runFundMaxTestCase(ht *lntest.HarnessTest, alice, bob *node.HarnessNode,

// Otherwise, if we expect to open a channel use the helper function.
chanPoint := ht.OpenChannel(alice, bob, chanParams)
cType := ht.GetChannelCommitType(alice, chanPoint)

// Close the channel between Alice and Bob, asserting
// that the channel has been properly closed on-chain.
defer ht.CloseChannel(alice, chanPoint)

cType := ht.GetChannelCommitType(alice, chanPoint)

// Alice's balance should be her amount subtracted by the commitment
// transaction fee.
checkChannelBalance(
Expand Down
3 changes: 0 additions & 3 deletions itest/lnd_channel_funding_utxo_selection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,7 @@ func testChannelUtxoSelection(ht *lntest.HarnessTest) {
// tests.
args := lntest.NodeArgsForCommitType(lnrpc.CommitmentType_ANCHORS)
alice := ht.NewNode("Alice", args)
defer ht.Shutdown(alice)

bob := ht.NewNode("Bob", args)
defer ht.Shutdown(bob)

// Ensure both sides are connected so the funding flow can be properly
// executed.
Expand Down
39 changes: 14 additions & 25 deletions itest/lnd_channel_graph_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,9 @@ func testUpdateChanStatus(ht *lntest.HarnessTest) {
// describeGraph RPC request unless explicitly asked for.
func testUnannouncedChannels(ht *lntest.HarnessTest) {
amount := funding.MaxBtcFundingAmount
alice, bob := ht.Alice, ht.Bob
alice := ht.NewNodeWithCoins("Alice", nil)
bob := ht.NewNode("Bob", nil)
ht.EnsureConnected(alice, bob)

// Open a channel between Alice and Bob, ensuring the
// channel has been opened properly.
Expand All @@ -232,7 +234,7 @@ func testUnannouncedChannels(ht *lntest.HarnessTest) {

// One block is enough to make the channel ready for use, since the
// nodes have defaultNumConfs=1 set.
fundingChanPoint := ht.WaitForChannelOpenEvent(chanOpenUpdate)
ht.WaitForChannelOpenEvent(chanOpenUpdate)

// Alice should have 1 edge in her graph.
ht.AssertNumActiveEdges(alice, 1, true)
Expand All @@ -246,9 +248,6 @@ func testUnannouncedChannels(ht *lntest.HarnessTest) {

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

// Close the channel used during the test.
ht.CloseChannel(alice, fundingChanPoint)
}

func testGraphTopologyNotifications(ht *lntest.HarnessTest) {
Expand All @@ -267,14 +266,10 @@ func testGraphTopologyNtfns(ht *lntest.HarnessTest, pinned bool) {

// Spin up Bob first, since we will need to grab his pubkey when
// starting Alice to test pinned syncing.
bob := ht.Bob
bob := ht.NewNodeWithCoins("Bob", nil)
bobInfo := bob.RPC.GetInfo()
bobPubkey := bobInfo.IdentityPubkey

// Restart Bob as he may have leftover announcements from previous
// tests, causing the graph to be unsynced.
ht.RestartNodeWithExtraArgs(bob, nil)

// For unpinned syncing, start Alice as usual. Otherwise grab Bob's
// pubkey to include in his pinned syncer set.
var aliceArgs []string
Expand All @@ -285,8 +280,7 @@ func testGraphTopologyNtfns(ht *lntest.HarnessTest, pinned bool) {
}
}

alice := ht.Alice
ht.RestartNodeWithExtraArgs(alice, aliceArgs)
alice := ht.NewNodeWithCoins("Alice", aliceArgs)

// Connect Alice and Bob.
ht.EnsureConnected(alice, bob)
Expand Down Expand Up @@ -370,16 +364,15 @@ func testGraphTopologyNtfns(ht *lntest.HarnessTest, pinned bool) {
// Bob's new node announcement, and the channel between Bob and Carol.
ht.AssertNumChannelUpdates(alice, chanPoint, 2)
ht.AssertNumNodeAnns(alice, bob.PubKeyStr, 1)

// Close the channel between Bob and Carol.
ht.CloseChannel(bob, chanPoint)
}

// testNodeAnnouncement ensures that when a node is started with one or more
// external IP addresses specified on the command line, that those addresses
// announced to the network and reported in the network graph.
func testNodeAnnouncement(ht *lntest.HarnessTest) {
alice, bob := ht.Alice, ht.Bob
alice := ht.NewNode("Alice", nil)
bob := ht.NewNodeWithCoins("Bob", nil)
ht.EnsureConnected(alice, bob)

advertisedAddrs := []string{
"192.168.1.1:8333",
Expand All @@ -403,7 +396,7 @@ func testNodeAnnouncement(ht *lntest.HarnessTest) {
// We'll then go ahead and open a channel between Bob and Dave. This
// ensures that Alice receives the node announcement from Bob as part of
// the announcement broadcast.
chanPoint := ht.OpenChannel(
ht.OpenChannel(
bob, dave, lntest.OpenChannelParams{Amt: 1000000},
)

Expand All @@ -425,16 +418,15 @@ func testNodeAnnouncement(ht *lntest.HarnessTest) {
allUpdates := ht.AssertNumNodeAnns(alice, dave.PubKeyStr, 1)
nodeUpdate := allUpdates[len(allUpdates)-1]
assertAddrs(nodeUpdate.Addresses, advertisedAddrs...)

// Close the channel between Bob and Dave.
ht.CloseChannel(bob, chanPoint)
}

// testUpdateNodeAnnouncement ensures that the RPC endpoint validates
// the requests correctly and that the new node announcement is broadcast
// with the right information after updating our node.
func testUpdateNodeAnnouncement(ht *lntest.HarnessTest) {
alice, bob := ht.Alice, ht.Bob
alice := ht.NewNode("Alice", nil)
bob := ht.NewNodeWithCoins("Bob", nil)
ht.EnsureConnected(alice, bob)

var lndArgs []string

Expand Down Expand Up @@ -530,7 +522,7 @@ func testUpdateNodeAnnouncement(ht *lntest.HarnessTest) {
// Go ahead and open a channel between Bob and Dave. This
// ensures that Alice receives the node announcement from Bob as part of
// the announcement broadcast.
chanPoint := ht.OpenChannel(
ht.OpenChannel(
bob, dave, lntest.OpenChannelParams{
Amt: 1000000,
},
Expand Down Expand Up @@ -660,9 +652,6 @@ func testUpdateNodeAnnouncement(ht *lntest.HarnessTest) {
FeatureUpdates: updateFeatureActions,
}
dave.RPC.UpdateNodeAnnouncementErr(nodeAnnReq)

// Close the channel between Bob and Dave.
ht.CloseChannel(bob, chanPoint)
}

// assertSyncType asserts that the peer has an expected syncType.
Expand Down
39 changes: 13 additions & 26 deletions itest/lnd_channel_policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,16 @@ func testUpdateChannelPolicy(ht *lntest.HarnessTest) {
chanAmt := funding.MaxBtcFundingAmount
pushAmt := chanAmt / 2

alice, bob := ht.Alice, ht.Bob

// Create a channel Alice->Bob.
chanPoint := ht.OpenChannel(
alice, bob, lntest.OpenChannelParams{
chanPoints, nodes := ht.CreateSimpleNetwork(
[][]string{nil, nil}, lntest.OpenChannelParams{
Amt: chanAmt,
PushAmt: pushAmt,
},
)

// We add all the nodes' update channels to a slice, such that we can
// make sure they all receive the expected updates.
nodes := []*node.HarnessNode{alice, bob}
alice, bob := nodes[0], nodes[1]
chanPoint := chanPoints[0]

// Alice and Bob should see each other's ChannelUpdates, advertising the
// default routing policies. We do not currently set any inbound fees.
Expand Down Expand Up @@ -423,11 +420,6 @@ func testUpdateChannelPolicy(ht *lntest.HarnessTest) {
ht.AssertChannelPolicy(
carol, alice.PubKeyStr, expectedPolicy, chanPoint3,
)

// Close all channels.
ht.CloseChannel(alice, chanPoint)
ht.CloseChannel(bob, chanPoint2)
ht.CloseChannel(alice, chanPoint3)
}

// testSendUpdateDisableChannel ensures that a channel update with the disable
Expand All @@ -441,7 +433,8 @@ func testUpdateChannelPolicy(ht *lntest.HarnessTest) {
func testSendUpdateDisableChannel(ht *lntest.HarnessTest) {
const chanAmt = 100000

alice, bob := ht.Alice, ht.Bob
alice := ht.NewNodeWithCoins("Alice", nil)
bob := ht.NewNode("Bob", nil)

// Create a new node Eve, which will be restarted later with a config
// that has an inactive channel timeout of just 6 seconds (down from
Expand Down Expand Up @@ -678,7 +671,9 @@ func testUpdateChannelPolicyForPrivateChannel(ht *lntest.HarnessTest) {

// We'll create the following topology first,
// Alice <--public:100k--> Bob <--private:100k--> Carol
alice, bob := ht.Alice, ht.Bob
alice := ht.NewNodeWithCoins("Alice", nil)
bob := ht.NewNodeWithCoins("Bob", nil)
ht.EnsureConnected(alice, bob)

// Open a channel with 100k satoshis between Alice and Bob.
chanPointAliceBob := ht.OpenChannel(
Expand Down Expand Up @@ -773,10 +768,6 @@ func testUpdateChannelPolicyForPrivateChannel(ht *lntest.HarnessTest) {
// Alice should have sent 20k satoshis + fee to Bob.
ht.AssertAmountPaid("Alice(local) => Bob(remote)",
alice, chanPointAliceBob, amtExpected, 0)

// Finally, close the channels.
ht.CloseChannel(alice, chanPointAliceBob)
ht.CloseChannel(bob, chanPointBobCarol)
}

// testUpdateChannelPolicyFeeRateAccuracy tests that updating the channel policy
Expand All @@ -787,16 +778,14 @@ func testUpdateChannelPolicyFeeRateAccuracy(ht *lntest.HarnessTest) {
pushAmt := chanAmt / 2

// Create a channel Alice -> Bob.
alice, bob := ht.Alice, ht.Bob
chanPoint := ht.OpenChannel(
alice, bob, lntest.OpenChannelParams{
chanPoints, nodes := ht.CreateSimpleNetwork(
[][]string{nil, nil}, lntest.OpenChannelParams{
Amt: chanAmt,
PushAmt: pushAmt,
},
)

// Nodes that we need to make sure receive the channel updates.
nodes := []*node.HarnessNode{alice, bob}
alice := nodes[0]
chanPoint := chanPoints[0]

baseFee := int64(1500)
timeLockDelta := uint32(66)
Expand Down Expand Up @@ -847,8 +836,6 @@ func testUpdateChannelPolicyFeeRateAccuracy(ht *lntest.HarnessTest) {

// Make sure that both Alice and Bob sees the same policy after update.
assertNodesPolicyUpdate(ht, nodes, alice, expectedPolicy, chanPoint)

ht.CloseChannel(alice, chanPoint)
}

// assertNodesPolicyUpdate checks that a given policy update has been received
Expand Down
3 changes: 2 additions & 1 deletion itest/lnd_coop_close_external_delivery_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ func testCoopCloseWithExternalDelivery(ht *lntest.HarnessTest) {
func testCoopCloseWithExternalDeliveryImpl(ht *lntest.HarnessTest,
upfrontShutdown bool, deliveryAddressType lnrpc.AddressType) {

alice, bob := ht.Alice, ht.Bob
alice := ht.NewNodeWithCoins("Alice", nil)
bob := ht.NewNodeWithCoins("bob", nil)
ht.ConnectNodes(alice, bob)

// Here we generate a final delivery address in bob's wallet but set by
Expand Down
Loading
Loading