itest: flatten and fix testWatchtower

This commit is contained in:
yyforyongyu 2024-10-25 14:05:18 +08:00
parent b7feeba008
commit 9c0c373b7e
No known key found for this signature in database
GPG key ID: 9BCD95C4FF296868
2 changed files with 25 additions and 30 deletions

View file

@ -550,10 +550,6 @@ var allTestCases = []*lntest.TestCase{
Name: "lookup htlc resolution",
TestFunc: testLookupHtlcResolution,
},
{
Name: "watchtower",
TestFunc: testWatchtower,
},
{
Name: "channel fundmax",
TestFunc: testChannelFundMax,
@ -695,4 +691,5 @@ var allTestCases = []*lntest.TestCase{
func init() {
// Register subtests.
allTestCases = append(allTestCases, multiHopForceCloseTestCases...)
allTestCases = append(allTestCases, watchtowerTestCases...)
}

View file

@ -19,22 +19,21 @@ import (
"github.com/stretchr/testify/require"
)
// testWatchtower tests the behaviour of the watchtower client and server.
func testWatchtower(ht *lntest.HarnessTest) {
ht.Run("revocation", func(t *testing.T) {
tt := ht.Subtest(t)
testRevokedCloseRetributionAltruistWatchtower(tt)
})
ht.Run("session deletion", func(t *testing.T) {
tt := ht.Subtest(t)
testTowerClientSessionDeletion(tt)
})
ht.Run("tower and session activation", func(t *testing.T) {
tt := ht.Subtest(t)
testTowerClientTowerAndSessionManagement(tt)
})
// watchtowerTestCases defines a set of tests to check the behaviour of the
// watchtower client and server.
var watchtowerTestCases = []*lntest.TestCase{
{
Name: "watchtower revoked close retribution altruist",
TestFunc: testRevokedCloseRetributionAltruistWatchtower,
},
{
Name: "watchtower client session deletion",
TestFunc: testTowerClientSessionDeletion,
},
{
Name: "watchtower client tower and session management",
TestFunc: testTowerClientTowerAndSessionManagement,
},
}
// testTowerClientTowerAndSessionManagement tests the various control commands
@ -565,6 +564,15 @@ func testRevokedCloseRetributionAltruistWatchtowerCase(ht *lntest.HarnessTest,
// then been swept to his wallet by Willy.
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 {
daveBalResp := dave.RPC.ChannelBalance()
if daveBalResp.LocalBalance.Sat != 0 {
@ -579,16 +587,6 @@ func testRevokedCloseRetributionAltruistWatchtowerCase(ht *lntest.HarnessTest,
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.
err = wait.NoError(func() error {
daveBalResp := dave.RPC.WalletBalance()