mirror of
https://github.com/lightningnetwork/lnd.git
synced 2024-11-19 18:10:34 +01:00
itest: improve backup check during wt test
This replaces an outstanding sleep for a check for a specific state during the test for watchtower use: specifically, that the backup has been sent to the watchtower prior to shutting down Dave. This reduces flakiness in the test that could occur if the Dave shutdown without the backup being comitted to the watchtower, causing the rest of the test to fail.
This commit is contained in:
parent
91538884da
commit
af660d0152
@ -9050,6 +9050,29 @@ func testRevokedCloseRetributionAltruistWatchtower(net *lntest.NetworkHarness,
|
||||
|
||||
davePreSweepBalance := daveBalResp.ConfirmedBalance
|
||||
|
||||
// Wait until the backup has been accepted by the watchtower before
|
||||
// shutting down Dave.
|
||||
err = wait.NoError(func() error {
|
||||
ctxt, cancel := context.WithTimeout(ctxb, defaultTimeout)
|
||||
defer cancel()
|
||||
bkpStats, err := dave.WatchtowerClient.Stats(ctxt, &wtclientrpc.StatsRequest{})
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
}
|
||||
if bkpStats == nil {
|
||||
return errors.New("no active backup sessions")
|
||||
}
|
||||
if bkpStats.NumBackups == 0 {
|
||||
return errors.New("no backups accepted")
|
||||
}
|
||||
|
||||
return nil
|
||||
}, defaultTimeout)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to verify backup task completed: %v", err)
|
||||
}
|
||||
|
||||
// Shutdown Dave to simulate going offline for an extended period of
|
||||
// time. Once he's not watching, Carol will try to breach the channel.
|
||||
restart, err := net.SuspendNode(dave)
|
||||
@ -9078,9 +9101,6 @@ func testRevokedCloseRetributionAltruistWatchtower(net *lntest.NetworkHarness,
|
||||
t.Fatalf("db copy failed: %v", carolChan.NumUpdates)
|
||||
}
|
||||
|
||||
// TODO(conner): add hook for backup completion
|
||||
time.Sleep(3 * time.Second)
|
||||
|
||||
// Now force Carol to execute a *force* channel closure by unilaterally
|
||||
// broadcasting his current channel state. This is actually the
|
||||
// commitment transaction of a prior *revoked* state, so he'll soon
|
||||
|
Loading…
Reference in New Issue
Block a user