From 06022eeb7a2801a72e6a2caf80056697bed07fba Mon Sep 17 00:00:00 2001 From: Rod Vagg Date: Fri, 5 Jul 2024 14:27:21 +1000 Subject: [PATCH] fix: itest: current deadline calculation should account for future period start --- itests/kit/node_unmanaged.go | 7 +++++-- itests/niporep_manual_test.go | 2 ++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/itests/kit/node_unmanaged.go b/itests/kit/node_unmanaged.go index 15275a880ff..72d7350fc59 100644 --- a/itests/kit/node_unmanaged.go +++ b/itests/kit/node_unmanaged.go @@ -6,7 +6,6 @@ import ( "crypto/rand" "fmt" "io" - "math" "os" "path/filepath" "sync" @@ -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 diff --git a/itests/niporep_manual_test.go b/itests/niporep_manual_test.go index f27cf1b7d8b..71ebf6beeaf 100644 --- a/itests/niporep_manual_test.go +++ b/itests/niporep_manual_test.go @@ -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(¶ms, fmt.Sprintf("proving deadline %d must not be the current or next deadline", currentDeadlineIdx), 18)