From aafe4c38fcf12dd810af5263e278cff074b49ece Mon Sep 17 00:00:00 2001 From: yyforyongyu Date: Mon, 14 Nov 2022 03:41:45 +0800 Subject: [PATCH] lntest: fix flake in channel backup related tests This commit fixes the channel backup tests by decreasing the recovery window used from 1000 to 100 to speed up the startup of node Dave. --- lntemp/harness_node_manager.go | 2 +- lntest/itest/lnd_channel_backup_test.go | 22 ++++++++++++++++------ 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/lntemp/harness_node_manager.go b/lntemp/harness_node_manager.go index 1292741c7..2b5f87e08 100644 --- a/lntemp/harness_node_manager.go +++ b/lntemp/harness_node_manager.go @@ -156,7 +156,7 @@ func (nm *nodeManager) restartNode(ctxt context.Context, node *node.HarnessNode, } if len(chanBackups) != 0 { unlockReq.ChannelBackups = chanBackups[0] - unlockReq.RecoveryWindow = 1000 + unlockReq.RecoveryWindow = 100 } err = wait.NoError(func() error { diff --git a/lntest/itest/lnd_channel_backup_test.go b/lntest/itest/lnd_channel_backup_test.go index b9b1d3500..f99b37af1 100644 --- a/lntest/itest/lnd_channel_backup_test.go +++ b/lntest/itest/lnd_channel_backup_test.go @@ -39,6 +39,10 @@ type ( password []byte, mnemonic []string) nodeRestorer ) +// revocationWindow is used when we specify the revocation window used when +// restoring node. +const revocationWindow = 100 + // chanRestoreScenario represents a test case used by testing the channel // restore methods. type chanRestoreScenario struct { @@ -309,7 +313,8 @@ func testChannelBackupRestoreBasic(ht *lntemp.HarnessTest) { return func() *node.HarnessNode { return st.RestoreNodeWithSeed( "dave", nil, password, mnemonic, - "", 1000, backupSnapshot, + "", revocationWindow, + backupSnapshot, copyPorts(oldNode), ) } @@ -341,7 +346,7 @@ func testChannelBackupRestoreBasic(ht *lntemp.HarnessTest) { return func() *node.HarnessNode { newNode := st.RestoreNodeWithSeed( "dave", nil, password, mnemonic, - "", 1000, nil, + "", revocationWindow, nil, copyPorts(oldNode), ) @@ -377,7 +382,7 @@ func testChannelBackupRestoreBasic(ht *lntemp.HarnessTest) { return func() *node.HarnessNode { newNode := st.RestoreNodeWithSeed( "dave", nil, password, mnemonic, - "", 1000, nil, + "", revocationWindow, nil, copyPorts(oldNode), ) @@ -665,11 +670,16 @@ func testChannelBackupRestoreLegacy(ht *lntemp.HarnessTest) { func testChannelBackupRestoreForceClose(ht *lntemp.HarnessTest) { // Restore a channel that was force closed by dave just before going // offline. - ht.Run("from backup file anchors", func(t *testing.T) { + success := ht.Run("from backup file anchors", func(t *testing.T) { st := ht.Subtest(t) runChanRestoreScenarioForceClose(st, false) }) + // Only run the second test if the first passed. + if !success { + return + } + // Restore a zero-conf anchors channel that was force closed by dave // just before going offline. ht.Run("from backup file anchors w/ zero-conf", func(t *testing.T) { @@ -1344,8 +1354,8 @@ func chanRestoreViaRPC(ht *lntemp.HarnessTest, password []byte, return func() *node.HarnessNode { newNode := ht.RestoreNodeWithSeed( - "dave", nil, password, mnemonic, "", 1000, nil, - copyPorts(oldNode), + "dave", nil, password, mnemonic, "", revocationWindow, + nil, copyPorts(oldNode), ) req := &lnrpc.RestoreChanBackupRequest{Backup: backup} newNode.RPC.RestoreChanBackups(req)