Skip to content

Commit

Permalink
fix: itest: current deadline calculation should account for future pe…
Browse files Browse the repository at this point in the history
…riod start
  • Loading branch information
rvagg committed Jul 5, 2024
1 parent 51445e2 commit 06022ee
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 5 additions & 2 deletions itests/kit/node_unmanaged.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"crypto/rand"
"fmt"
"io"
"math"
"os"
"path/filepath"
"sync"
Expand Down Expand Up @@ -1562,7 +1561,11 @@ func (tm *TestUnmanagedMiner) IsImmutableDeadline(deadlineIndex uint64) bool {
// situations where the miner hasn't been enrolled in cron and the deadline index isn't ticking
// so dline.Info.Index may not be accurate.
func CurrentDeadlineIndex(di *dline.Info) uint64 {
return uint64(math.Abs(float64((di.CurrentEpoch - di.PeriodStart) / di.WPoStChallengeWindow)))
didx := int64((di.CurrentEpoch - di.PeriodStart) / di.WPoStChallengeWindow)
if didx < 0 { // before the first deadline
return uint64(int64(di.WPoStPeriodDeadlines) + didx)
}
return uint64(didx)
}

// TODO: remove when https://github.com/filecoin-project/go-state-types/pull/286 is available
Expand Down
2 changes: 2 additions & 0 deletions itests/niporep_manual_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,8 @@ func verifyProveCommitSectorsNIErrorConditions(ctx context.Context, t *testing.T
req.NoError(err)
currentDeadlineIdx = kit.CurrentDeadlineIndex(di)

t.Logf("Validating submission failure for current and next deadline. Current Deadline Info: %+v, calculated current deadline: %d.", di, currentDeadlineIdx)

params = mkParams()
params.ProvingDeadline = currentDeadlineIdx
submitAndFail(&params, fmt.Sprintf("proving deadline %d must not be the current or next deadline", currentDeadlineIdx), 18)
Expand Down

0 comments on commit 06022ee

Please sign in to comment.