Skip to content

Commit fb3fc1f

Browse files
fix: test: no snap deals in immutable deadlines (#12071)
1 parent 730c96e commit fb3fc1f

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

itests/kit/node_unmanaged.go

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,7 @@ func (tm *TestUnmanagedMiner) SnapDealWithRealProofs(ctx context.Context, proofT
422422
snapProof, err := ffi.SectorUpdate.GenerateUpdateProofWithVanilla(updateProofType, tm.sealedCids[sectorNumber],
423423
newSealed, newUnsealed, vp)
424424
require.NoError(tm.t, err)
425+
tm.waitForMutableDeadline(ctx, sectorNumber)
425426

426427
// submit proof
427428
var manifest []miner14.PieceActivationManifest
@@ -453,12 +454,41 @@ func (tm *TestUnmanagedMiner) SnapDealWithRealProofs(ctx context.Context, proofT
453454
RequireActivationSuccess: true,
454455
RequireNotificationSuccess: false,
455456
}
456-
457457
r, err := tm.submitMessage(ctx, params, 1, builtin.MethodsMiner.ProveReplicaUpdates3)
458458
require.NoError(tm.t, err)
459459
require.True(tm.t, r.Receipt.ExitCode.IsSuccess())
460460
}
461461

462+
func (tm *TestUnmanagedMiner) waitForMutableDeadline(ctx context.Context, sectorNum abi.SectorNumber) {
463+
ts, err := tm.FullNode.ChainHead(ctx)
464+
require.NoError(tm.t, err)
465+
466+
sl, err := tm.FullNode.StateSectorPartition(ctx, tm.ActorAddr, sectorNum, ts.Key())
467+
require.NoError(tm.t, err)
468+
469+
dlinfo, err := tm.FullNode.StateMinerProvingDeadline(ctx, tm.ActorAddr, ts.Key())
470+
require.NoError(tm.t, err)
471+
472+
sectorDeadlineOpen := sl.Deadline == dlinfo.Index
473+
sectorDeadlineNext := (dlinfo.Index+1)%dlinfo.WPoStPeriodDeadlines == sl.Deadline
474+
immutable := sectorDeadlineOpen || sectorDeadlineNext
475+
476+
// Sleep for immutable epochs
477+
if immutable {
478+
dlineEpochsRemaining := dlinfo.NextOpen() - ts.Height()
479+
var targetEpoch abi.ChainEpoch
480+
if sectorDeadlineOpen {
481+
// sleep for remainder of deadline
482+
targetEpoch = ts.Height() + dlineEpochsRemaining
483+
} else {
484+
// sleep for remainder of deadline and next one
485+
targetEpoch = ts.Height() + dlineEpochsRemaining + dlinfo.WPoStChallengeWindow
486+
}
487+
_, err := tm.FullNode.WaitTillChainOrError(ctx, HeightAtLeast(targetEpoch+5))
488+
require.NoError(tm.t, err)
489+
}
490+
}
491+
462492
func (tm *TestUnmanagedMiner) OnboardCCSectorWithMockProofs(ctx context.Context, proofType abi.RegisteredSealProof) (abi.SectorNumber, chan WindowPostResp,
463493
context.CancelFunc) {
464494
req := require.New(tm.t)

0 commit comments

Comments
 (0)