itest: flatten and fix testWatchtower

This commit is contained in:
yyforyongyu committed 2024-12-20 17:54:12 +08:00
1 parent b7feeba008
commit 9c0c373b7e
2 files changed
+25 -30

No files matched your search

+1 -4
View File
@@ -550,10 +550,6 @@ var allTestCases = []*lntest.TestCase{
Name: "lookup htlc resolution", Name: "lookup htlc resolution",
TestFunc: testLookupHtlcResolution, TestFunc: testLookupHtlcResolution,
}, },
{
Name: "watchtower",
TestFunc: testWatchtower,
},
{ {
Name: "channel fundmax", Name: "channel fundmax",
TestFunc: testChannelFundMax, TestFunc: testChannelFundMax,
@@ -695,4 +691,5 @@ var allTestCases = []*lntest.TestCase{
func init() { func init() {
// Register subtests. // Register subtests.
allTestCases = append(allTestCases, multiHopForceCloseTestCases...) allTestCases = append(allTestCases, multiHopForceCloseTestCases...)
allTestCases = append(allTestCases, watchtowerTestCases...)
} }
+24 -26
View File
@@ -19,22 +19,21 @@ import (
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )
// testWatchtower tests the behaviour of the watchtower client and server. // watchtowerTestCases defines a set of tests to check the behaviour of the
func testWatchtower(ht *lntest.HarnessTest) { // watchtower client and server.
ht.Run("revocation", func(t *testing.T) { var watchtowerTestCases = []*lntest.TestCase{
tt := ht.Subtest(t) {
testRevokedCloseRetributionAltruistWatchtower(tt) Name: "watchtower revoked close retribution altruist",
}) TestFunc: testRevokedCloseRetributionAltruistWatchtower,
},
ht.Run("session deletion", func(t *testing.T) { {
tt := ht.Subtest(t) Name: "watchtower client session deletion",
testTowerClientSessionDeletion(tt) TestFunc: testTowerClientSessionDeletion,
}) },
{
ht.Run("tower and session activation", func(t *testing.T) { Name: "watchtower client tower and session management",
tt := ht.Subtest(t) TestFunc: testTowerClientTowerAndSessionManagement,
testTowerClientTowerAndSessionManagement(tt) },
})
} }
// testTowerClientTowerAndSessionManagement tests the various control commands // testTowerClientTowerAndSessionManagement tests the various control commands
@@ -565,6 +564,15 @@ func testRevokedCloseRetributionAltruistWatchtowerCase(ht *lntest.HarnessTest,
// then been swept to his wallet by Willy. // then been swept to his wallet by Willy.
require.NoError(ht, restart(), "unable to restart dave") require.NoError(ht, restart(), "unable to restart dave")
// For neutrino backend, we may need to mine one more block to trigger
// the chain watcher to act.
//
// TODO(yy): remove it once the blockbeat remembers the last block
// processed.
if ht.IsNeutrinoBackend() {
ht.MineEmptyBlocks(1)
}
err = wait.NoError(func() error { err = wait.NoError(func() error {
daveBalResp := dave.RPC.ChannelBalance() daveBalResp := dave.RPC.ChannelBalance()
if daveBalResp.LocalBalance.Sat != 0 { if daveBalResp.LocalBalance.Sat != 0 {
@@ -579,16 +587,6 @@ func testRevokedCloseRetributionAltruistWatchtowerCase(ht *lntest.HarnessTest,
ht.AssertNumPendingForceClose(dave, 0) ht.AssertNumPendingForceClose(dave, 0)
// If this is an anchor channel, Dave would offer his sweeper the
// anchor. However, due to no time-sensitive outputs involved, the
// anchor sweeping won't happen as it's uneconomical.
if lntest.CommitTypeHasAnchors(commitType) {
ht.AssertNumPendingSweeps(dave, 1)
// Mine a block to trigger the sweep.
ht.MineEmptyBlocks(1)
}
// Check that Dave's wallet balance is increased. // Check that Dave's wallet balance is increased.
err = wait.NoError(func() error { err = wait.NoError(func() error {
daveBalResp := dave.RPC.WalletBalance() daveBalResp := dave.RPC.WalletBalance()