itest: remove unnecessary channel close and node shutdown

Since we don't have standby nodes anymore, we don't need to close the
channels when the test finishes. Previously we would do so to make sure
the standby nodes have a clean state for the next test case, which is no
longer relevant.
This commit is contained in:
yyforyongyu 2024-10-29 16:48:23 +08:00
parent 00772ae281
commit 72f3f41d41
No known key found for this signature in database
GPG key ID: 9BCD95C4FF296868
33 changed files with 47 additions and 447 deletions

View file

@ -63,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))
// 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
@ -208,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)
}

View file

@ -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.
@ -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(

View file

@ -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.

View file

@ -234,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)
@ -248,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) {
@ -367,9 +364,6 @@ 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
@ -402,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},
)
@ -424,9 +418,6 @@ 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
@ -531,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,
},
@ -661,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.

View file

@ -420,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
@ -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
@ -845,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

View file

@ -29,11 +29,10 @@ func testCustomFeatures(ht *lntest.HarnessTest) {
}
cfgs := [][]string{extraArgs, nil}
chanPoints, nodes := ht.CreateSimpleNetwork(
_, nodes := ht.CreateSimpleNetwork(
cfgs, lntest.OpenChannelParams{Amt: 1000000},
)
alice, bob := nodes[0], nodes[1]
chanPoint := chanPoints[0]
// Check that Alice's custom feature bit was sent to Bob in her init
// message.
@ -79,8 +78,6 @@ func testCustomFeatures(ht *lntest.HarnessTest) {
},
}
alice.RPC.UpdateNodeAnnouncementErr(nodeAnnReq)
ht.CloseChannel(alice, chanPoint)
}
// assertFeatureNotInSet checks that the features provided aren't contained in

View file

@ -49,7 +49,7 @@ func testEndorsement(ht *lntest.HarnessTest, aliceEndorse bool) {
{Local: dave, Remote: eve, Param: p},
}
resp := ht.OpenMultiChannelsAsync(reqs)
cpAB, cpBC, cpCD, cpDE := resp[0], resp[1], resp[2], resp[3]
_, 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)
@ -95,11 +95,6 @@ func testEndorsement(ht *lntest.HarnessTest, aliceEndorse bool) {
var preimage lntypes.Preimage
copy(preimage[:], invoice.RPreimage)
ht.AssertPaymentStatus(alice, preimage, lnrpc.Payment_SUCCEEDED)
ht.CloseChannel(alice, cpAB)
ht.CloseChannel(bob, cpBC)
ht.CloseChannel(carol, cpCD)
ht.CloseChannel(dave, cpDE)
}
func validateEndorsedAndResume(ht *lntest.HarnessTest,

View file

@ -177,10 +177,6 @@ func testForwardInterceptorDedupHtlc(ht *lntest.HarnessTest) {
case <-time.After(defaultTimeout):
require.Fail(ht, "timeout waiting for interceptor error")
}
// Finally, close channels.
ht.CloseChannel(alice, cpAB)
ht.CloseChannel(bob, cpBC)
}
// testForwardInterceptorBasic tests the forward interceptor RPC layer.
@ -345,10 +341,6 @@ func testForwardInterceptorBasic(ht *lntest.HarnessTest) {
case <-time.After(defaultTimeout):
require.Fail(ht, "timeout waiting for interceptor error")
}
// Finally, close channels.
ht.CloseChannel(alice, cpAB)
ht.CloseChannel(bob, cpBC)
}
// testForwardInterceptorModifiedHtlc tests that the interceptor can modify the
@ -367,7 +359,7 @@ func testForwardInterceptorModifiedHtlc(ht *lntest.HarnessTest) {
{Local: bob, Remote: carol, Param: p},
}
resp := ht.OpenMultiChannelsAsync(reqs)
cpAB, cpBC := resp[0], resp[1]
cpBC := resp[1]
// Make sure Alice is aware of channel Bob=>Carol.
ht.AssertChannelInGraph(alice, cpBC)
@ -451,10 +443,6 @@ func testForwardInterceptorModifiedHtlc(ht *lntest.HarnessTest) {
var preimage lntypes.Preimage
copy(preimage[:], invoice.RPreimage)
ht.AssertPaymentStatus(alice, preimage, lnrpc.Payment_SUCCEEDED)
// Finally, close channels.
ht.CloseChannel(alice, cpAB)
ht.CloseChannel(bob, cpBC)
}
// testForwardInterceptorWireRecords tests that the interceptor can read any
@ -475,7 +463,7 @@ func testForwardInterceptorWireRecords(ht *lntest.HarnessTest) {
{Local: carol, Remote: dave, Param: p},
}
resp := ht.OpenMultiChannelsAsync(reqs)
cpAB, cpBC, cpCD := resp[0], resp[1], resp[2]
cpBC := resp[1]
// Make sure Alice is aware of channel Bob=>Carol.
ht.AssertChannelInGraph(alice, cpBC)
@ -579,11 +567,6 @@ func testForwardInterceptorWireRecords(ht *lntest.HarnessTest) {
return nil
},
)
// Finally, close channels.
ht.CloseChannel(alice, cpAB)
ht.CloseChannel(bob, cpBC)
ht.CloseChannel(carol, cpCD)
}
// testForwardInterceptorRestart tests that the interceptor can read any wire
@ -605,7 +588,7 @@ func testForwardInterceptorRestart(ht *lntest.HarnessTest) {
{Local: carol, Remote: dave, Param: p},
}
resp := ht.OpenMultiChannelsAsync(reqs)
cpAB, cpBC, cpCD := resp[0], resp[1], resp[2]
cpBC, cpCD := resp[1], resp[2]
// Make sure Alice is aware of channels Bob=>Carol and Carol=>Dave.
ht.AssertChannelInGraph(alice, cpBC)
@ -742,11 +725,6 @@ func testForwardInterceptorRestart(ht *lntest.HarnessTest) {
return nil
},
)
// Finally, close channels.
ht.CloseChannel(alice, cpAB)
ht.CloseChannel(bob, cpBC)
ht.CloseChannel(carol, cpCD)
}
// interceptorTestScenario is a helper struct to hold the test context and

View file

@ -86,7 +86,7 @@ func testBasicChannelFunding(ht *lntest.HarnessTest) {
return
}
carolChan, daveChan, closeChan := basicChannelFundingTest(
carolChan, daveChan := basicChannelFundingTest(
ht, carol, dave, nil, privateChan, &carolCommitType,
)
@ -152,10 +152,6 @@ func testBasicChannelFunding(ht *lntest.HarnessTest) {
"commit type %v, instead got "+
"%v", expType, chansCommitType)
}
// As we've concluded this sub-test case we'll now close out
// the channel for both sides.
closeChan()
}
test:
@ -190,7 +186,7 @@ test:
func basicChannelFundingTest(ht *lntest.HarnessTest,
alice, bob *node.HarnessNode, fundingShim *lnrpc.FundingShim,
privateChan bool, commitType *lnrpc.CommitmentType) (*lnrpc.Channel,
*lnrpc.Channel, func()) {
*lnrpc.Channel) {
chanAmt := funding.MaxBtcFundingAmount
pushAmt := btcutil.Amount(100000)
@ -262,14 +258,7 @@ func basicChannelFundingTest(ht *lntest.HarnessTest,
aliceChannel := ht.GetChannelByChanPoint(alice, chanPoint)
bobChannel := ht.GetChannelByChanPoint(bob, chanPoint)
closeChan := func() {
// Finally, immediately close the channel. This function will
// also block until the channel is closed and will additionally
// assert the relevant channel closing post conditions.
ht.CloseChannel(alice, chanPoint)
}
return aliceChannel, bobChannel, closeChan
return aliceChannel, bobChannel
}
// testUnconfirmedChannelFunding tests that our unconfirmed change outputs can
@ -377,25 +366,12 @@ func testUnconfirmedChannelFunding(ht *lntest.HarnessTest) {
// spend and the funding tx.
ht.MineBlocksAndAssertNumTxes(6, 2)
chanPoint := ht.WaitForChannelOpenEvent(chanOpenUpdate)
ht.WaitForChannelOpenEvent(chanOpenUpdate)
// With the channel open, we'll check the balances on each side of the
// channel as a sanity check to ensure things worked out as intended.
checkChannelBalance(carol, carolLocalBalance, pushAmt, 0, 0)
checkChannelBalance(alice, pushAmt, carolLocalBalance, 0, 0)
// TODO(yy): remove the sleep once the following bug is fixed.
//
// We may get the error `unable to gracefully close channel while peer
// is offline (try force closing it instead): channel link not found`.
// This happens because the channel link hasn't been added yet but we
// now proceed to closing the channel. We may need to revisit how the
// channel open event is created and make sure the event is only sent
// after all relevant states have been updated.
time.Sleep(2 * time.Second)
// Now that we're done with the test, the channel can be closed.
ht.CloseChannel(carol, chanPoint)
}
// testChannelFundingInputTypes tests that any type of supported input type can
@ -602,7 +578,7 @@ func runExternalFundingScriptEnforced(ht *lntest.HarnessTest) {
// At this point, we'll now carry out the normal basic channel funding
// test as everything should now proceed as normal (a regular channel
// funding flow).
carolChan, daveChan, _ := basicChannelFundingTest(
carolChan, daveChan := basicChannelFundingTest(
ht, carol, dave, fundingShim2, false, nil,
)
@ -718,7 +694,7 @@ func runExternalFundingTaproot(ht *lntest.HarnessTest) {
// At this point, we'll now carry out the normal basic channel funding
// test as everything should now proceed as normal (a regular channel
// funding flow).
carolChan, daveChan, _ := basicChannelFundingTest(
carolChan, daveChan := basicChannelFundingTest(
ht, carol, dave, fundingShim2, true, &commitmentType,
)
@ -931,11 +907,6 @@ func testChannelFundingPersistence(ht *lntest.HarnessTest) {
shortChanID := lnwire.NewShortChanIDFromInt(chanAlice.ChanId)
label = labels.MakeLabel(labels.LabelTypeChannelOpen, &shortChanID)
require.Equal(ht, label, tx.Label, "open channel label not updated")
// Finally, immediately close the channel. This function will also
// block until the channel is closed and will additionally assert the
// relevant channel closing post conditions.
ht.CloseChannel(alice, chanPoint)
}
// testBatchChanFunding makes sure multiple channels can be opened in one batch
@ -1128,15 +1099,6 @@ func testBatchChanFunding(ht *lntest.HarnessTest) {
chainreg.DefaultBitcoinBaseFeeMSat,
chainreg.DefaultBitcoinFeeRate,
)
// To conclude, we'll close the newly created channel between Carol and
// Dave. This function will also block until the channel is closed and
// will additionally assert the relevant channel closing post
// conditions.
ht.CloseChannel(alice, chanPoint1)
ht.CloseChannel(alice, chanPoint2)
ht.CloseChannel(alice, chanPoint3)
ht.CloseChannel(alice, chanPoint4)
}
// ensurePolicy ensures that the peer sees alice's channel fee settings.
@ -1210,13 +1172,12 @@ func testChannelFundingWithUnstableUtxos(ht *lntest.HarnessTest) {
// Open a channel to dave with an unconfirmed utxo. Although this utxo
// is unconfirmed it can be used to open a channel because it did not
// originated from the sweeper subsystem.
update := ht.OpenChannelAssertPending(carol, dave,
ht.OpenChannelAssertPending(carol, dave,
lntest.OpenChannelParams{
Amt: chanSize,
SpendUnconfirmed: true,
CommitmentType: cType,
})
chanPoint1 := lntest.ChanPointFromPendingUpdate(update)
// Verify that both nodes know about the channel.
ht.AssertNumPendingOpenChannels(carol, 1)
@ -1228,7 +1189,7 @@ func testChannelFundingWithUnstableUtxos(ht *lntest.HarnessTest) {
// so unconfirmed utxos originated from prior channel opening are safe
// to use because channel opening should not be RBFed, at least not for
// now.
update = ht.OpenChannelAssertPending(carol, dave,
update := ht.OpenChannelAssertPending(carol, dave,
lntest.OpenChannelParams{
Amt: chanSize,
SpendUnconfirmed: true,
@ -1347,20 +1308,16 @@ func testChannelFundingWithUnstableUtxos(ht *lntest.HarnessTest) {
// Now after the sweep utxo is confirmed it is stable and can be used
// for channel openings again.
update = ht.OpenChannelAssertPending(carol, dave,
ht.OpenChannelAssertPending(carol, dave,
lntest.OpenChannelParams{
Amt: chanSize,
SpendUnconfirmed: true,
CommitmentType: cType,
})
chanPoint4 := lntest.ChanPointFromPendingUpdate(update)
// Verify that both nodes know about the channel.
ht.AssertNumPendingOpenChannels(carol, 1)
ht.AssertNumPendingOpenChannels(dave, 1)
ht.MineBlocksAndAssertNumTxes(1, 1)
ht.CloseChannel(carol, chanPoint1)
ht.CloseChannel(carol, chanPoint4)
}

View file

@ -140,7 +140,4 @@ func testHoldInvoiceForceClose(ht *lntest.HarnessTest) {
// outgoing HTLCs in her channel as the only HTLC has already been
// canceled.
ht.AssertNumPendingForceClose(alice, 0)
// Clean up the channel.
ht.CloseChannel(alice, chanPoint)
}

View file

@ -35,7 +35,7 @@ func testHoldInvoicePersistence(ht *lntest.HarnessTest) {
// Open a channel between Alice and Carol which is private so that we
// cover the addition of hop hints for hold invoices.
chanPointAlice := ht.OpenChannel(
ht.OpenChannel(
alice, carol, lntest.OpenChannelParams{
Amt: chanAmt,
Private: true,
@ -222,8 +222,4 @@ func testHoldInvoicePersistence(ht *lntest.HarnessTest) {
"wrong failure reason")
}
}
// Finally, close all channels.
ht.CloseChannel(alice, chanPointBob)
ht.CloseChannel(alice, chanPointAlice)
}

View file

@ -24,7 +24,6 @@ func testLookupHtlcResolution(ht *lntest.HarnessTest) {
cp := ht.OpenChannel(
alice, carol, lntest.OpenChannelParams{Amt: chanAmt},
)
defer ht.CloseChannel(alice, cp)
// Channel should be ready for payments.
const payAmt = 100

View file

@ -32,7 +32,7 @@ func testInvoiceHtlcModifierBasic(ht *lntest.HarnessTest) {
{Local: bob, Remote: carol, Param: p},
}
resp := ht.OpenMultiChannelsAsync(reqs)
cpAB, cpBC := resp[0], resp[1]
cpBC := resp[1]
// Make sure Alice is aware of channel Bob=>Carol.
ht.AssertChannelInGraph(alice, cpBC)
@ -208,10 +208,6 @@ func testInvoiceHtlcModifierBasic(ht *lntest.HarnessTest) {
}
cancelModifier()
// Finally, close channels.
ht.CloseChannel(alice, cpAB)
ht.CloseChannel(bob, cpBC)
}
// acceptorTestCase is a helper struct to hold test case data.

View file

@ -56,9 +56,7 @@ func testMaxChannelSize(ht *lntest.HarnessTest) {
// Creating a wumbo channel between these two nodes should succeed.
ht.EnsureConnected(wumboNode, wumboNode3)
chanPoint := ht.OpenChannel(
ht.OpenChannel(
wumboNode, wumboNode3, lntest.OpenChannelParams{Amt: chanAmt},
)
ht.CloseChannel(wumboNode, chanPoint)
}

View file

@ -25,14 +25,13 @@ func testMaxHtlcPathfind(ht *lntest.HarnessTest) {
cfgs := [][]string{cfg, cfg}
// Create a channel Alice->Bob.
chanPoints, nodes := ht.CreateSimpleNetwork(
_, nodes := ht.CreateSimpleNetwork(
cfgs, lntest.OpenChannelParams{
Amt: 1000000,
PushAmt: 800000,
RemoteMaxHtlcs: uint16(maxHtlcs),
},
)
chanPoint := chanPoints[0]
alice, bob := nodes[0], nodes[1]
// Alice and bob should have one channel open with each other now.
@ -78,8 +77,6 @@ func testMaxHtlcPathfind(ht *lntest.HarnessTest) {
ht.AssertNumActiveHtlcs(alice, 0)
ht.AssertNumActiveHtlcs(bob, 0)
ht.CloseChannel(alice, chanPoint)
}
type holdSubscription struct {

View file

@ -156,7 +156,6 @@ func testSphinxReplayPersistence(ht *lntest.HarnessTest) {
Amt: chanAmt,
},
)
defer ht.CloseChannel(fred, chanPointFC)
// Now that the channel is open, create an invoice for Dave which
// expects a payment of 1000 satoshis from Carol paid via a particular
@ -225,9 +224,6 @@ func testSphinxReplayPersistence(ht *lntest.HarnessTest) {
// unaltered.
ht.AssertAmountPaid("carol => dave", carol, chanPoint, 0, 0)
ht.AssertAmountPaid("dave <= carol", dave, chanPoint, 0, 0)
// Cleanup by mining the force close and sweep transaction.
ht.ForceCloseChannel(carol, chanPoint)
}
// testListChannels checks that the response from ListChannels is correct. It
@ -420,12 +416,6 @@ func testMaxPendingChannels(ht *lntest.HarnessTest) {
chanPoints[i] = fundingChanPoint
}
// Next, close the channel between Alice and Carol, asserting that the
// channel has been properly closed on-chain.
for _, chanPoint := range chanPoints {
ht.CloseChannel(alice, chanPoint)
}
}
// testGarbageCollectLinkNodes tests that we properly garbage collect link
@ -464,7 +454,7 @@ func testGarbageCollectLinkNodes(ht *lntest.HarnessTest) {
dave := ht.NewNode("Dave", nil)
ht.ConnectNodes(alice, dave)
persistentChanPoint := ht.OpenChannel(
ht.OpenChannel(
alice, dave, lntest.OpenChannelParams{
Amt: chanAmt,
},
@ -537,9 +527,6 @@ func testGarbageCollectLinkNodes(ht *lntest.HarnessTest) {
"did not expect to find bob in the channel graph, but did")
require.NotContains(ht, channelGraph.Nodes, carol.PubKeyStr,
"did not expect to find carol in the channel graph, but did")
// Now that the test is done, we can also close the persistent link.
ht.CloseChannel(alice, persistentChanPoint)
}
// testRejectHTLC tests that a node can be created with the flag --rejecthtlc.
@ -566,14 +553,14 @@ func testRejectHTLC(ht *lntest.HarnessTest) {
ht.FundCoins(btcutil.SatoshiPerBitcoin, carol)
// Open a channel between Alice and Carol.
chanPointAlice := ht.OpenChannel(
ht.OpenChannel(
alice, carol, lntest.OpenChannelParams{
Amt: chanAmt,
},
)
// Open a channel between Carol and Bob.
chanPointCarol := ht.OpenChannel(
ht.OpenChannel(
carol, bob, lntest.OpenChannelParams{
Amt: chanAmt,
},
@ -636,10 +623,6 @@ func testRejectHTLC(ht *lntest.HarnessTest) {
)
ht.AssertLastHTLCError(alice, lnrpc.Failure_CHANNEL_DISABLED)
// Close all channels.
ht.CloseChannel(alice, chanPointAlice)
ht.CloseChannel(carol, chanPointCarol)
}
// testNodeSignVerify checks that only connected nodes are allowed to perform
@ -654,9 +637,8 @@ func testNodeSignVerify(ht *lntest.HarnessTest) {
// Create a channel between alice and bob.
cfgs := [][]string{nil, nil}
chanPoints, nodes := ht.CreateSimpleNetwork(cfgs, p)
_, nodes := ht.CreateSimpleNetwork(cfgs, p)
alice, bob := nodes[0], nodes[1]
aliceBobCh := chanPoints[0]
// alice signs "alice msg" and sends her signature to bob.
aliceMsg := []byte("alice msg")
@ -684,9 +666,6 @@ func testNodeSignVerify(ht *lntest.HarnessTest) {
require.False(ht, verifyResp.Valid, "carol's signature didn't validate")
require.Equal(ht, verifyResp.Pubkey, carol.PubKeyStr,
"carol's signature doesn't contain alice's pubkey.")
// Close the channel between alice and bob.
ht.CloseChannel(alice, aliceBobCh)
}
// testAbandonChannel abandons a channel and asserts that it is no longer open
@ -702,7 +681,7 @@ func testAbandonChannel(ht *lntest.HarnessTest) {
// Create a channel between alice and bob.
cfgs := [][]string{nil, nil}
chanPoints, nodes := ht.CreateSimpleNetwork(cfgs, channelParam)
alice, bob := nodes[0], nodes[1]
alice := nodes[0]
chanPoint := chanPoints[0]
// Now that the channel is open, we'll obtain its channel ID real quick
@ -755,11 +734,6 @@ func testAbandonChannel(ht *lntest.HarnessTest) {
// Calling AbandonChannel again, should result in no new errors, as the
// channel has already been removed.
alice.RPC.AbandonChannel(abandonChannelRequest)
// Now that we're done with the test, the channel can be closed. This
// is necessary to avoid unexpected outcomes of other tests that use
// Bob's lnd instance.
ht.ForceCloseChannel(bob, chanPoint)
}
// testSendAllCoins tests that we're able to properly sweep all coins from the

View file

@ -365,12 +365,4 @@ func testHtlcErrorPropagation(ht *lntest.HarnessTest) {
ht.AssertHtlcEventTypes(
bobEvents, routerrpc.HtlcEvent_UNKNOWN, lntest.HtlcEventFinal,
)
// Finally, immediately close the channel. This function will also
// block until the channel is closed and will additionally assert the
// relevant channel closing post conditions.
ht.CloseChannel(alice, chanPointAlice)
// Force close Bob's final channel.
ht.ForceCloseChannel(bob, chanPointBob)
}

View file

@ -235,11 +235,6 @@ func testMultiHopPayments(ht *lntest.HarnessTest) {
ht.AssertHtlcEvents(
bobEvents, 0, 0, numPayments, 0, routerrpc.HtlcEvent_RECEIVE,
)
// Finally, close all channels.
ht.CloseChannel(alice, chanPointAlice)
ht.CloseChannel(dave, chanPointDave)
ht.CloseChannel(carol, chanPointCarol)
}
// updateChannelPolicy updates the channel policy of node to the given fees and

View file

@ -133,9 +133,7 @@ func testReconnectAfterIPChange(ht *lntest.HarnessTest) {
// We'll then go ahead and open a channel between Alice and Dave. This
// ensures that Charlie receives the node announcement from Alice as
// part of the announcement broadcast.
chanPoint := ht.OpenChannel(
alice, dave, lntest.OpenChannelParams{Amt: 1000000},
)
ht.OpenChannel(alice, dave, lntest.OpenChannelParams{Amt: 1000000})
// waitForNodeAnnouncement is a closure used to wait on the given graph
// subscription for a node announcement from a node with the given
@ -210,9 +208,6 @@ func testReconnectAfterIPChange(ht *lntest.HarnessTest) {
// address to one not listed in Dave's original advertised list of
// addresses.
ht.AssertConnected(dave, charlie)
// Finally, close the channel.
ht.CloseChannel(alice, chanPoint)
}
// testAddPeerConfig tests that the "--addpeer" config flag successfully adds

View file

@ -153,7 +153,7 @@ func testChainKitSendOutputsAnchorReserve(ht *lntest.HarnessTest) {
// Charlie opens an anchor channel and keeps twice the amount of the
// anchor reserve in her wallet.
chanAmt := fundingAmount - 2*btcutil.Amount(reserve.RequiredReserve)
outpoint := ht.OpenChannel(charlie, bob, lntest.OpenChannelParams{
ht.OpenChannel(charlie, bob, lntest.OpenChannelParams{
Amt: chanAmt,
CommitmentType: lnrpc.CommitmentType_ANCHORS,
SatPerVByte: 1,
@ -207,11 +207,7 @@ func testChainKitSendOutputsAnchorReserve(ht *lntest.HarnessTest) {
// This second transaction should be published correctly.
charlie.RPC.SendOutputs(req)
ht.MineBlocksAndAssertNumTxes(1, 1)
// Clean up our test setup.
ht.CloseChannel(charlie, outpoint)
}
// testAnchorReservedValue tests that we won't allow sending transactions when

View file

@ -4,7 +4,6 @@ import (
"fmt"
"strings"
"testing"
"time"
"github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/chaincfg/chainhash"
@ -119,8 +118,6 @@ func testOpenChannelAfterReorg(ht *lntest.HarnessTest) {
// Cleanup by mining the funding tx again, then closing the channel.
block = ht.MineBlocksAndAssertNumTxes(1, 1)[0]
ht.AssertTxInBlock(block, *fundingTxID)
ht.CloseChannel(alice, chanPoint)
}
// testOpenChannelFeePolicy checks if different channel fee scenarios are
@ -256,15 +253,13 @@ func testOpenChannelUpdateFeePolicy(ht *lntest.HarnessTest) {
// Create a channel Alice->Bob.
chanPoint := ht.OpenChannel(alice, bob, chanParams)
defer ht.CloseChannel(alice, chanPoint)
// Create a channel Carol->Alice.
chanPoint2 := ht.OpenChannel(
ht.OpenChannel(
carol, alice, lntest.OpenChannelParams{
Amt: 500000,
},
)
defer ht.CloseChannel(carol, chanPoint2)
// Alice and Bob should see each other's ChannelUpdates,
// advertising the preferred routing policies.
@ -542,13 +537,7 @@ func testUpdateOnFunderPendingOpenChannels(ht *lntest.HarnessTest) {
Amt: funding.MaxBtcFundingAmount,
PushAmt: funding.MaxBtcFundingAmount / 2,
}
pendingChan := ht.OpenChannelAssertPending(alice, bob, params)
chanPoint := &lnrpc.ChannelPoint{
FundingTxid: &lnrpc.ChannelPoint_FundingTxidBytes{
FundingTxidBytes: pendingChan.Txid,
},
OutputIndex: pendingChan.OutputIndex,
}
ht.OpenChannelAssertPending(alice, bob, params)
// Alice and Bob should both consider the channel pending open.
ht.AssertNumPendingOpenChannels(alice, 1)
@ -598,9 +587,6 @@ func testUpdateOnFunderPendingOpenChannels(ht *lntest.HarnessTest) {
// Once Alice sees the channel as active, she will process the cached
// premature `update_add_htlc` and settles the payment.
ht.AssertPaymentStatusFromStream(bobStream, lnrpc.Payment_SUCCEEDED)
// Close the channel.
ht.CloseChannel(alice, chanPoint)
}
// testUpdateOnFundeePendingOpenChannels checks that when the funder sends an
@ -625,13 +611,7 @@ func testUpdateOnFundeePendingOpenChannels(ht *lntest.HarnessTest) {
params := lntest.OpenChannelParams{
Amt: funding.MaxBtcFundingAmount,
}
pendingChan := ht.OpenChannelAssertPending(alice, bob, params)
chanPoint := &lnrpc.ChannelPoint{
FundingTxid: &lnrpc.ChannelPoint_FundingTxidBytes{
FundingTxidBytes: pendingChan.Txid,
},
OutputIndex: pendingChan.OutputIndex,
}
ht.OpenChannelAssertPending(alice, bob, params)
// Alice and Bob should both consider the channel pending open.
ht.AssertNumPendingOpenChannels(alice, 1)
@ -681,9 +661,6 @@ func testUpdateOnFundeePendingOpenChannels(ht *lntest.HarnessTest) {
// Once Bob sees the channel as active, he will process the cached
// premature `update_add_htlc` and settles the payment.
ht.AssertPaymentStatusFromStream(aliceStream, lnrpc.Payment_SUCCEEDED)
// Close the channel.
ht.CloseChannel(alice, chanPoint)
}
// verifyCloseUpdate is used to verify that a closed channel update is of the
@ -756,7 +733,7 @@ func testFundingExpiryBlocksOnPending(ht *lntest.HarnessTest) {
ht.EnsureConnected(alice, bob)
param := lntest.OpenChannelParams{Amt: 100000}
update := ht.OpenChannelAssertPending(alice, bob, param)
ht.OpenChannelAssertPending(alice, bob, param)
// At this point, the channel's funding transaction will have been
// broadcast, but not confirmed. Alice and Bob's nodes should reflect
@ -777,20 +754,6 @@ func testFundingExpiryBlocksOnPending(ht *lntest.HarnessTest) {
// Mine 1 block to confirm the funding transaction, and then close the
// channel.
ht.MineBlocksAndAssertNumTxes(1, 1)
chanPoint := lntest.ChanPointFromPendingUpdate(update)
// TODO(yy): remove the sleep once the following bug is fixed.
//
// We may get the error `unable to gracefully close channel
// while peer is offline (try force closing it instead):
// channel link not found`. This happens because the channel
// link hasn't been added yet but we now proceed to closing the
// channel. We may need to revisit how the channel open event
// is created and make sure the event is only sent after all
// relevant states have been updated.
time.Sleep(2 * time.Second)
ht.CloseChannel(alice, chanPoint)
}
// testSimpleTaprootChannelActivation ensures that a simple taproot channel is
@ -803,9 +766,7 @@ func testSimpleTaprootChannelActivation(ht *lntest.HarnessTest) {
// Make the new set of participants.
alice := ht.NewNode("alice", simpleTaprootChanArgs)
defer ht.Shutdown(alice)
bob := ht.NewNode("bob", simpleTaprootChanArgs)
defer ht.Shutdown(bob)
ht.FundCoins(btcutil.SatoshiPerBitcoin, alice)
@ -842,9 +803,6 @@ func testSimpleTaprootChannelActivation(ht *lntest.HarnessTest) {
// Verify that Alice sees an active channel to Bob.
ht.AssertChannelActive(alice, chanPoint)
// Our test is done and Alice closes her channel to Bob.
ht.CloseChannel(alice, chanPoint)
}
// testOpenChannelLockedBalance tests that when a funding reservation is

View file

@ -477,9 +477,7 @@ func testListPayments(ht *lntest.HarnessTest) {
// 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},
)
ht.OpenChannel(alice, bob, lntest.OpenChannelParams{Amt: chanAmt})
// Now that the channel is open, create an invoice for Bob which
// expects a payment of 1000 satoshis from Alice paid via a particular
@ -638,17 +636,6 @@ func testListPayments(ht *lntest.HarnessTest) {
// Check that there are no payments after test.
ht.AssertNumPayments(alice, 0)
// TODO(yy): remove the sleep once the following bug is fixed.
// When the invoice is reported settled, the commitment dance is not
// yet finished, which can cause an error when closing the channel,
// saying there's active HTLCs. We need to investigate this issue and
// reverse the order to, first finish the commitment dance, then report
// the invoice as settled.
time.Sleep(2 * time.Second)
// Close the channel.
ht.CloseChannel(alice, chanPoint)
}
// testPaymentFollowingChannelOpen tests that the channel transition from
@ -698,19 +685,6 @@ func testPaymentFollowingChannelOpen(ht *lntest.HarnessTest) {
// Send payment to Bob so that a channel update to disk will be
// executed.
ht.CompletePaymentRequests(alice, []string{bobPayReqs[0]})
// TODO(yy): remove the sleep once the following bug is fixed.
// When the invoice is reported settled, the commitment dance is not
// yet finished, which can cause an error when closing the channel,
// saying there's active HTLCs. We need to investigate this issue and
// reverse the order to, first finish the commitment dance, then report
// the invoice as settled.
time.Sleep(2 * time.Second)
// Finally, immediately close the channel. This function will also
// block until the channel is closed and will additionally assert the
// relevant channel closing post conditions.
ht.CloseChannel(alice, chanPoint)
}
// testAsyncPayments tests the performance of the async payments.
@ -818,11 +792,6 @@ func runAsyncPayments(ht *lntest.HarnessTest, alice, bob *node.HarnessNode,
ht.Log("\tBenchmark info: Elapsed time: ", timeTaken)
ht.Log("\tBenchmark info: TPS: ",
float64(numInvoices)/timeTaken.Seconds())
// Finally, immediately close the channel. This function will also
// block until the channel is closed and will additionally assert the
// relevant channel closing post conditions.
ht.CloseChannel(alice, chanPoint)
}
// testBidirectionalAsyncPayments tests that nodes are able to send the
@ -930,11 +899,6 @@ func testBidirectionalAsyncPayments(ht *lntest.HarnessTest) {
// Next query for Bob's and Alice's channel states, in order to confirm
// that all payment have been successfully transmitted.
assertChannelState(ht, bob, chanPoint, bobAmt, aliceAmt)
// Finally, immediately close the channel. This function will also
// block until the channel is closed and will additionally assert the
// relevant channel closing post conditions.
ht.CloseChannel(alice, chanPoint)
}
func testInvoiceSubscriptions(ht *lntest.HarnessTest) {
@ -951,9 +915,7 @@ func testInvoiceSubscriptions(ht *lntest.HarnessTest) {
// Open a channel with 500k satoshis between Alice and Bob with Alice
// being the sole funder of the channel.
chanPoint := ht.OpenChannel(
alice, bob, lntest.OpenChannelParams{Amt: chanAmt},
)
ht.OpenChannel(alice, bob, lntest.OpenChannelParams{Amt: chanAmt})
// Next create a new invoice for Bob requesting 1k satoshis.
const paymentAmt = 1000
@ -1055,16 +1017,6 @@ func testInvoiceSubscriptions(ht *lntest.HarnessTest) {
// At this point, all the invoices should be fully settled.
require.Empty(ht, settledInvoices, "not all invoices settled")
// TODO(yy): remove the sleep once the following bug is fixed.
// When the invoice is reported settled, the commitment dance is not
// yet finished, which can cause an error when closing the channel,
// saying there's active HTLCs. We need to investigate this issue and
// reverse the order to, first finish the commitment dance, then report
// the invoice as settled.
time.Sleep(2 * time.Second)
ht.CloseChannel(alice, chanPoint)
}
// assertChannelState asserts the channel state by checking the values in
@ -1151,10 +1103,6 @@ func testPaymentFailureReasonCanceled(ht *lntest.HarnessTest) {
ht, ts, cpAB, routerrpc.ResolveHoldForwardAction_FAIL,
lnrpc.Payment_FAILED, interceptor,
)
// Finally, close channels.
ht.CloseChannel(alice, cpAB)
ht.CloseChannel(bob, cpBC)
}
func sendPaymentInterceptAndCancel(ht *lntest.HarnessTest,

View file

@ -324,13 +324,6 @@ func runPsbtChanFunding(ht *lntest.HarnessTest, carol, dave *node.HarnessNode,
}
resp := dave.RPC.AddInvoice(invoice)
ht.CompletePaymentRequests(carol, []string{resp.PaymentRequest})
// To conclude, we'll close the newly created channel between Carol and
// Dave. This function will also block until the channel is closed and
// will additionally assert the relevant channel closing post
// conditions.
ht.CloseChannel(carol, chanPoint)
ht.CloseChannel(carol, chanPoint2)
}
// runPsbtChanFundingExternal makes sure a channel can be opened between carol
@ -499,13 +492,6 @@ func runPsbtChanFundingExternal(ht *lntest.HarnessTest, carol,
}
resp := dave.RPC.AddInvoice(invoice)
ht.CompletePaymentRequests(carol, []string{resp.PaymentRequest})
// To conclude, we'll close the newly created channel between Carol and
// Dave. This function will also block until the channels are closed and
// will additionally assert the relevant channel closing post
// conditions.
ht.CloseChannel(carol, chanPoint)
ht.CloseChannel(carol, chanPoint2)
}
// runPsbtChanFundingSingleStep checks whether PSBT funding works also when
@ -649,12 +635,6 @@ func runPsbtChanFundingSingleStep(ht *lntest.HarnessTest, carol,
}
resp := dave.RPC.AddInvoice(invoice)
ht.CompletePaymentRequests(carol, []string{resp.PaymentRequest})
// To conclude, we'll close the newly created channel between Carol and
// Dave. This function will also block until the channel is closed and
// will additionally assert the relevant channel closing post
// conditions.
ht.CloseChannel(carol, chanPoint)
}
// testSignPsbt tests that the SignPsbt RPC works correctly.

View file

@ -22,7 +22,6 @@ func testQuiescence(ht *lntest.HarnessTest) {
chanPoint := ht.OpenChannel(bob, alice, lntest.OpenChannelParams{
Amt: btcutil.Amount(1000000),
})
defer ht.CloseChannel(bob, chanPoint)
res := alice.RPC.Quiesce(&devrpc.QuiescenceRequest{
ChanId: chanPoint,

View file

@ -94,6 +94,4 @@ func testResHandoff(ht *lntest.HarnessTest) {
// Assert that Alice's payment failed.
ht.AssertFirstHTLCError(alice, lnrpc.Failure_PERMANENT_CHANNEL_FAILURE)
ht.CloseChannel(alice, chanPointAlice)
}

View file

@ -529,10 +529,9 @@ func wsTestCaseBiDirectionalSubscription(ht *lntest.HarnessTest) {
// sent over the web socket.
const numChannels = 3
for i := 0; i < numChannels; i++ {
chanPoint := ht.OpenChannel(
ht.OpenChannel(
bob, alice, lntest.OpenChannelParams{Amt: 500000},
)
defer ht.CloseChannel(bob, chanPoint)
select {
case <-msgChan:

View file

@ -309,9 +309,6 @@ func testQueryBlindedRoutes(ht *lntest.HarnessTest) {
require.Len(ht, resp.Routes, 1)
require.Len(ht, resp.Routes[0].Hops, 2)
require.Equal(ht, resp.Routes[0].TotalTimeLock, sendToIntroTimelock)
ht.CloseChannel(alice, chanPointAliceBob)
ht.CloseChannel(bob, chanPointBobCarol)
}
type blindedForwardTest struct {
@ -412,10 +409,6 @@ func (b *blindedForwardTest) buildBlindedPath() *lnrpc.BlindedPaymentPath {
// cleanup tears down all channels created by the test and cancels the top
// level context used in the test.
func (b *blindedForwardTest) cleanup() {
b.ht.CloseChannel(b.alice, b.channels[0])
b.ht.CloseChannel(b.bob, b.channels[1])
b.ht.CloseChannel(b.carol, b.channels[2])
b.cancel()
}
@ -846,8 +839,6 @@ func testErrorHandlingOnChainFailure(ht *lntest.HarnessTest) {
// Manually close out the rest of our channels and cancel (don't use
// built in cleanup which will try close the already-force-closed
// channel).
ht.CloseChannel(alice, testCase.channels[0])
ht.CloseChannel(testCase.carol, testCase.channels[2])
testCase.cancel()
}

View file

@ -101,7 +101,6 @@ func testSingleHopSendToRouteCase(ht *lntest.HarnessTest,
chanPointCarol := ht.OpenChannel(
carol, dave, lntest.OpenChannelParams{Amt: chanAmt},
)
defer ht.CloseChannel(carol, chanPointCarol)
// Create invoices for Dave, which expect a payment from Carol.
payReqs, rHashes, _ := ht.CreatePayReqs(
@ -328,7 +327,6 @@ func runMultiHopSendToRoute(ht *lntest.HarnessTest, useGraphCache bool) {
chanPointAlice := ht.OpenChannel(
alice, bob, lntest.OpenChannelParams{Amt: chanAmt},
)
defer ht.CloseChannel(alice, chanPointAlice)
// Create Carol and establish a channel from Bob. Bob is the sole
// funder of the channel with 100k satoshis. The network topology
@ -340,7 +338,6 @@ func runMultiHopSendToRoute(ht *lntest.HarnessTest, useGraphCache bool) {
chanPointBob := ht.OpenChannel(
bob, carol, lntest.OpenChannelParams{Amt: chanAmt},
)
defer ht.CloseChannel(carol, chanPointBob)
// Make sure Alice knows the channel between Bob and Carol.
ht.AssertChannelInGraph(alice, chanPointBob)
@ -420,9 +417,7 @@ func testSendToRouteErrorPropagation(ht *lntest.HarnessTest) {
bob := ht.NewNode("Bob", nil)
ht.EnsureConnected(alice, bob)
chanPointAlice := ht.OpenChannel(
alice, bob, lntest.OpenChannelParams{Amt: chanAmt},
)
ht.OpenChannel(alice, bob, lntest.OpenChannelParams{Amt: chanAmt})
// Create a new nodes (Carol and Charlie), load her with some funds,
// then establish a connection between Carol and Charlie with a channel
@ -476,8 +471,6 @@ func testSendToRouteErrorPropagation(ht *lntest.HarnessTest) {
require.NoError(ht, err, "payment stream has been closed but fake "+
"route has consumed")
require.Contains(ht, event.PaymentError, "UnknownNextPeer")
ht.CloseChannel(alice, chanPointAlice)
}
// testPrivateChannels tests that a private channel can be used for
@ -602,12 +595,6 @@ func testPrivateChannels(ht *lntest.HarnessTest) {
ht.AssertNumActiveEdges(carol, 4, true)
ht.AssertNumActiveEdges(carol, 3, false)
ht.AssertNumActiveEdges(dave, 3, true)
// Close all channels.
ht.CloseChannel(alice, chanPointAlice)
ht.CloseChannel(dave, chanPointDave)
ht.CloseChannel(carol, chanPointCarol)
ht.CloseChannel(carol, chanPointPrivate)
}
// testInvoiceRoutingHints tests that the routing hints for an invoice are
@ -641,7 +628,7 @@ func testInvoiceRoutingHints(ht *lntest.HarnessTest) {
carol := ht.NewNode("Carol", nil)
ht.ConnectNodes(alice, carol)
chanPointCarol := ht.OpenChannel(
ht.OpenChannel(
alice, carol, lntest.OpenChannelParams{
Amt: chanAmt,
PushAmt: chanAmt / 2,
@ -654,7 +641,7 @@ func testInvoiceRoutingHints(ht *lntest.HarnessTest) {
// advertised, otherwise we'd end up leaking information about nodes
// that wish to stay unadvertised.
ht.ConnectNodes(bob, carol)
chanPointBobCarol := ht.OpenChannel(
ht.OpenChannel(
bob, carol, lntest.OpenChannelParams{
Amt: chanAmt,
PushAmt: chanAmt / 2,
@ -668,7 +655,7 @@ func testInvoiceRoutingHints(ht *lntest.HarnessTest) {
dave := ht.NewNode("Dave", nil)
ht.ConnectNodes(alice, dave)
chanPointDave := ht.OpenChannel(
ht.OpenChannel(
alice, dave, lntest.OpenChannelParams{
Amt: chanAmt,
Private: true,
@ -681,7 +668,7 @@ func testInvoiceRoutingHints(ht *lntest.HarnessTest) {
// inactive channels.
eve := ht.NewNode("Eve", nil)
ht.ConnectNodes(alice, eve)
chanPointEve := ht.OpenChannel(
ht.OpenChannel(
alice, eve, lntest.OpenChannelParams{
Amt: chanAmt,
PushAmt: chanAmt / 2,
@ -742,17 +729,6 @@ func testInvoiceRoutingHints(ht *lntest.HarnessTest) {
Private: true,
}
checkInvoiceHints(invoice)
// Now that we've confirmed the routing hints were added correctly, we
// can close all the channels and shut down all the nodes created.
ht.CloseChannel(alice, chanPointBob)
ht.CloseChannel(alice, chanPointCarol)
ht.CloseChannel(bob, chanPointBobCarol)
ht.CloseChannel(alice, chanPointDave)
// The channel between Alice and Eve should be force closed since Eve
// is offline.
ht.ForceCloseChannel(alice, chanPointEve)
}
// testScidAliasRoutingHints tests that dynamically created aliases via the RPC
@ -877,7 +853,7 @@ func testScidAliasRoutingHints(ht *lntest.HarnessTest) {
// Connect the existing Bob node with Carol via a public channel.
ht.ConnectNodes(bob, carol)
chanPointBC := ht.OpenChannel(bob, carol, lntest.OpenChannelParams{
ht.OpenChannel(bob, carol, lntest.OpenChannelParams{
Amt: chanAmt,
PushAmt: chanAmt / 2,
})
@ -940,9 +916,6 @@ func testScidAliasRoutingHints(ht *lntest.HarnessTest) {
FeeLimitSat: math.MaxInt64,
})
ht.AssertPaymentStatusFromStream(stream2, lnrpc.Payment_FAILED)
ht.CloseChannel(carol, chanPointCD)
ht.CloseChannel(bob, chanPointBC)
}
// testMultiHopOverPrivateChannels tests that private channels can be used as
@ -1042,12 +1015,6 @@ func testMultiHopOverPrivateChannels(ht *lntest.HarnessTest) {
// Alice should have sent 20k satoshis + fee for two hops to Bob.
ht.AssertAmountPaid("Alice(local) [private=>] Bob(remote)", alice,
chanPointAlice, paymentAmt+baseFee*2, 0)
// At this point, the payment was successful. We can now close all the
// channels and shutdown the nodes created throughout this test.
ht.CloseChannel(alice, chanPointAlice)
ht.CloseChannel(bob, chanPointBob)
ht.CloseChannel(carol, chanPointCarol)
}
// testQueryRoutes checks the response of queryroutes.
@ -1085,7 +1052,6 @@ func testQueryRoutes(ht *lntest.HarnessTest) {
resp := ht.OpenMultiChannelsAsync(reqs)
// Extract channel points from the response.
chanPointAlice := resp[0]
chanPointBob := resp[1]
chanPointCarol := resp[2]
@ -1196,12 +1162,6 @@ func testQueryRoutes(ht *lntest.HarnessTest) {
// control import function updates appropriately.
testMissionControlCfg(ht.T, alice)
testMissionControlImport(ht, alice, bob.PubKey[:], carol.PubKey[:])
// We clean up the test case by closing channels that were created for
// the duration of the tests.
ht.CloseChannel(alice, chanPointAlice)
ht.CloseChannel(bob, chanPointBob)
ht.CloseChannel(carol, chanPointCarol)
}
// testMissionControlCfg tests getting and setting of a node's mission control
@ -1528,13 +1488,6 @@ func testRouteFeeCutoff(ht *lntest.HarnessTest) {
},
}
testFeeCutoff(feeLimitFixed)
// Once we're done, close the channels and shut down the nodes created
// throughout this test.
ht.CloseChannel(alice, chanPointAliceBob)
ht.CloseChannel(alice, chanPointAliceCarol)
ht.CloseChannel(bob, chanPointBobDave)
ht.CloseChannel(carol, chanPointCarolDave)
}
// testFeeLimitAfterQueryRoutes tests that a payment's fee limit is consistent
@ -1547,7 +1500,7 @@ func testFeeLimitAfterQueryRoutes(ht *lntest.HarnessTest) {
cfgs, lntest.OpenChannelParams{Amt: chanAmt},
)
alice, bob, carol := nodes[0], nodes[1], nodes[2]
chanPointAliceBob, chanPointBobCarol := chanPoints[0], chanPoints[1]
chanPointAliceBob := chanPoints[0]
// We set an inbound fee discount on Bob's channel to Alice to
// effectively set the outbound fees charged to Carol to zero.
@ -1606,10 +1559,6 @@ func testFeeLimitAfterQueryRoutes(ht *lntest.HarnessTest) {
// We assert that a route compatible with the fee limit is available.
ht.SendPaymentAssertSettled(alice, sendReq)
// Once we're done, close the channels.
ht.CloseChannel(alice, chanPointAliceBob)
ht.CloseChannel(bob, chanPointBobCarol)
}
// computeFee calculates the payment fee as specified in BOLT07.

View file

@ -137,6 +137,4 @@ func testSingleHopInvoice(ht *lntest.HarnessTest) {
require.EqualValues(ht, 1, hopHint.FeeBaseMsat, "wrong FeeBaseMsat")
require.EqualValues(ht, 20, hopHint.CltvExpiryDelta,
"wrong CltvExpiryDelta")
ht.CloseChannel(alice, cp)
}

View file

@ -29,7 +29,6 @@ func testSwitchCircuitPersistence(ht *lntest.HarnessTest) {
// Setup our test scenario. We should now have four nodes running with
// three channels.
s := setupScenarioFourNodes(ht)
defer s.cleanUp()
// Restart the intermediaries and the sender.
ht.RestartNode(s.dave)
@ -99,7 +98,6 @@ func testSwitchOfflineDelivery(ht *lntest.HarnessTest) {
// Setup our test scenario. We should now have four nodes running with
// three channels.
s := setupScenarioFourNodes(ht)
defer s.cleanUp()
// First, disconnect Dave and Alice so that their link is broken.
ht.DisconnectNodes(s.dave, s.alice)
@ -175,7 +173,6 @@ func testSwitchOfflineDeliveryPersistence(ht *lntest.HarnessTest) {
// Setup our test scenario. We should now have four nodes running with
// three channels.
s := setupScenarioFourNodes(ht)
defer s.cleanUp()
// Disconnect the two intermediaries, Alice and Dave, by shutting down
// Alice.
@ -264,7 +261,6 @@ func testSwitchOfflineDeliveryOutgoingOffline(ht *lntest.HarnessTest) {
// three channels. Note that we won't call the cleanUp function here as
// we will manually stop the node Carol and her channel.
s := setupScenarioFourNodes(ht)
defer s.cleanUp()
// Disconnect the two intermediaries, Alice and Dave, so that when carol
// restarts, the response will be held by Dave.
@ -355,8 +351,6 @@ type scenarioFourNodes struct {
chanPointAliceBob *lnrpc.ChannelPoint
chanPointCarolDave *lnrpc.ChannelPoint
chanPointDaveAlice *lnrpc.ChannelPoint
cleanUp func()
}
// setupScenarioFourNodes creates a topology for switch tests. It will create
@ -433,21 +427,9 @@ func setupScenarioFourNodes(ht *lntest.HarnessTest) *scenarioFourNodes {
// above.
ht.CompletePaymentRequestsNoWait(bob, payReqs, chanPointAliceBob)
// Create a cleanUp to wipe the states.
cleanUp := func() {
if ht.Failed() {
ht.Skip("Skipped cleanup for failed test")
return
}
ht.CloseChannel(alice, chanPointAliceBob)
ht.CloseChannel(dave, chanPointDaveAlice)
ht.CloseChannel(carol, chanPointCarolDave)
}
s := &scenarioFourNodes{
alice, bob, carol, dave, chanPointAliceBob,
chanPointCarolDave, chanPointDaveAlice, cleanUp,
chanPointCarolDave, chanPointDaveAlice,
}
// Wait until all nodes in the network have 5 outstanding htlcs.

View file

@ -2,7 +2,6 @@ package itest
import (
"encoding/hex"
"time"
"github.com/btcsuite/btcd/btcutil"
"github.com/lightningnetwork/lnd/lnrpc"
@ -20,12 +19,11 @@ func testTrackPayments(ht *lntest.HarnessTest) {
cfgs := [][]string{cfgAlice, nil}
// Create a channel Alice->Bob.
chanPoints, nodes := ht.CreateSimpleNetwork(
_, nodes := ht.CreateSimpleNetwork(
cfgs, lntest.OpenChannelParams{
Amt: btcutil.Amount(300000),
},
)
channel := chanPoints[0]
alice, bob := nodes[0], nodes[1]
// Call the TrackPayments api to listen for payment updates.
@ -86,28 +84,17 @@ func testTrackPayments(ht *lntest.HarnessTest) {
require.Equal(ht, amountMsat, update3.ValueMsat)
require.Equal(ht, hex.EncodeToString(invoice.RPreimage),
update3.PaymentPreimage)
// TODO(yy): remove the sleep once the following bug is fixed.
// When the invoice is reported settled, the commitment dance is not
// yet finished, which can cause an error when closing the channel,
// saying there's active HTLCs. We need to investigate this issue and
// reverse the order to, first finish the commitment dance, then report
// the invoice as settled.
time.Sleep(2 * time.Second)
ht.CloseChannel(alice, channel)
}
// testTrackPaymentsCompatible checks that when `routerrpc.usestatusinitiated`
// is not set, the new Payment_INITIATED is replaced with Payment_IN_FLIGHT.
func testTrackPaymentsCompatible(ht *lntest.HarnessTest) {
// Open a channel between alice and bob.
chanPoints, nodes := ht.CreateSimpleNetwork(
_, nodes := ht.CreateSimpleNetwork(
[][]string{nil, nil}, lntest.OpenChannelParams{
Amt: btcutil.Amount(300000),
},
)
channel := chanPoints[0]
alice, bob := nodes[0], nodes[1]
// Call the TrackPayments api to listen for payment updates.
@ -162,14 +149,4 @@ func testTrackPaymentsCompatible(ht *lntest.HarnessTest) {
payment3, err := paymentClient.Recv()
require.NoError(ht, err, "unable to get payment update")
require.Equal(ht, lnrpc.Payment_SUCCEEDED, payment3.Status)
// TODO(yy): remove the sleep once the following bug is fixed.
// When the invoice is reported settled, the commitment dance is not
// yet finished, which can cause an error when closing the channel,
// saying there's active HTLCs. We need to investigate this issue and
// reverse the order to, first finish the commitment dance, then report
// the invoice as settled.
time.Sleep(2 * time.Second)
ht.CloseChannel(alice, channel)
}

View file

@ -45,8 +45,7 @@ func testWumboChannels(ht *lntest.HarnessTest) {
// Creating a wumbo channel between these two nodes should succeed.
ht.EnsureConnected(wumboNode, wumboNode2)
chanPoint := ht.OpenChannel(
ht.OpenChannel(
wumboNode, wumboNode2, lntest.OpenChannelParams{Amt: chanAmt},
)
ht.CloseChannel(wumboNode, chanPoint)
}

View file

@ -854,9 +854,6 @@ func testOptionScidUpgrade(ht *lntest.HarnessTest) {
daveInvoice2 := dave.RPC.AddInvoice(daveParams)
ht.CompletePaymentRequests(bob, []string{daveInvoice2.PaymentRequest})
// Close standby node's channels.
ht.CloseChannel(bob, fundingPoint2)
}
// acceptChannel is used to accept a single channel that comes across. This