Skip to content

Commit

Permalink
itest: improve backup check during wt test
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
matheusd committed Jul 13, 2020
1 parent 9153888 commit af660d0
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions lntest/itest/lnd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit af660d0

Please sign in to comment.