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.
This commit is contained in:
yyforyongyu 2022-11-14 03:41:45 +08:00
parent 3d7aae42b3
commit aafe4c38fc
No known key found for this signature in database
GPG key ID: 9BCD95C4FF296868
2 changed files with 17 additions and 7 deletions

View file

@ -156,7 +156,7 @@ func (nm *nodeManager) restartNode(ctxt context.Context, node *node.HarnessNode,
} }
if len(chanBackups) != 0 { if len(chanBackups) != 0 {
unlockReq.ChannelBackups = chanBackups[0] unlockReq.ChannelBackups = chanBackups[0]
unlockReq.RecoveryWindow = 1000 unlockReq.RecoveryWindow = 100
} }
err = wait.NoError(func() error { err = wait.NoError(func() error {

View file

@ -39,6 +39,10 @@ type (
password []byte, mnemonic []string) nodeRestorer 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 // chanRestoreScenario represents a test case used by testing the channel
// restore methods. // restore methods.
type chanRestoreScenario struct { type chanRestoreScenario struct {
@ -309,7 +313,8 @@ func testChannelBackupRestoreBasic(ht *lntemp.HarnessTest) {
return func() *node.HarnessNode { return func() *node.HarnessNode {
return st.RestoreNodeWithSeed( return st.RestoreNodeWithSeed(
"dave", nil, password, mnemonic, "dave", nil, password, mnemonic,
"", 1000, backupSnapshot, "", revocationWindow,
backupSnapshot,
copyPorts(oldNode), copyPorts(oldNode),
) )
} }
@ -341,7 +346,7 @@ func testChannelBackupRestoreBasic(ht *lntemp.HarnessTest) {
return func() *node.HarnessNode { return func() *node.HarnessNode {
newNode := st.RestoreNodeWithSeed( newNode := st.RestoreNodeWithSeed(
"dave", nil, password, mnemonic, "dave", nil, password, mnemonic,
"", 1000, nil, "", revocationWindow, nil,
copyPorts(oldNode), copyPorts(oldNode),
) )
@ -377,7 +382,7 @@ func testChannelBackupRestoreBasic(ht *lntemp.HarnessTest) {
return func() *node.HarnessNode { return func() *node.HarnessNode {
newNode := st.RestoreNodeWithSeed( newNode := st.RestoreNodeWithSeed(
"dave", nil, password, mnemonic, "dave", nil, password, mnemonic,
"", 1000, nil, "", revocationWindow, nil,
copyPorts(oldNode), copyPorts(oldNode),
) )
@ -665,11 +670,16 @@ func testChannelBackupRestoreLegacy(ht *lntemp.HarnessTest) {
func testChannelBackupRestoreForceClose(ht *lntemp.HarnessTest) { func testChannelBackupRestoreForceClose(ht *lntemp.HarnessTest) {
// Restore a channel that was force closed by dave just before going // Restore a channel that was force closed by dave just before going
// offline. // 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) st := ht.Subtest(t)
runChanRestoreScenarioForceClose(st, false) 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 // Restore a zero-conf anchors channel that was force closed by dave
// just before going offline. // just before going offline.
ht.Run("from backup file anchors w/ zero-conf", func(t *testing.T) { 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 { return func() *node.HarnessNode {
newNode := ht.RestoreNodeWithSeed( newNode := ht.RestoreNodeWithSeed(
"dave", nil, password, mnemonic, "", 1000, nil, "dave", nil, password, mnemonic, "", revocationWindow,
copyPorts(oldNode), nil, copyPorts(oldNode),
) )
req := &lnrpc.RestoreChanBackupRequest{Backup: backup} req := &lnrpc.RestoreChanBackupRequest{Backup: backup}
newNode.RPC.RestoreChanBackups(req) newNode.RPC.RestoreChanBackups(req)