lotus/storage/wdpost/wdpost_nextdl_test.go
Łukasz Magiera 08b22edd89 fix make gen
2022-08-29 16:25:30 +02:00

41 lines
1.4 KiB
Go

// stm: #unit
package wdpost
import (
"testing"
"github.com/stretchr/testify/require"
"github.com/filecoin-project/go-state-types/abi"
minertypes "github.com/filecoin-project/go-state-types/builtin/v8/miner"
)
func TestNextDeadline(t *testing.T) {
periodStart := abi.ChainEpoch(0)
deadlineIdx := 0
currentEpoch := abi.ChainEpoch(10)
di := NewDeadlineInfo(periodStart, uint64(deadlineIdx), currentEpoch)
require.EqualValues(t, 0, di.Index)
require.EqualValues(t, 0, di.PeriodStart)
require.EqualValues(t, -20, di.Challenge)
require.EqualValues(t, 0, di.Open)
require.EqualValues(t, 60, di.Close)
for i := 1; i < 1+int(minertypes.WPoStPeriodDeadlines)*2; i++ {
//stm: @WDPOST_NEXT_DEADLINE_001
di = nextDeadline(di)
deadlineIdx = i % int(minertypes.WPoStPeriodDeadlines)
expPeriodStart := int(minertypes.WPoStProvingPeriod) * (i / int(minertypes.WPoStPeriodDeadlines))
expOpen := expPeriodStart + deadlineIdx*int(minertypes.WPoStChallengeWindow)
expClose := expOpen + int(minertypes.WPoStChallengeWindow)
expChallenge := expOpen - int(minertypes.WPoStChallengeLookback)
//fmt.Printf("%d: %d@%d %d-%d (%d)\n", i, expPeriodStart, deadlineIdx, expOpen, expClose, expChallenge)
require.EqualValues(t, deadlineIdx, di.Index)
require.EqualValues(t, expPeriodStart, di.PeriodStart)
require.EqualValues(t, expOpen, di.Open)
require.EqualValues(t, expClose, di.Close)
require.EqualValues(t, expChallenge, di.Challenge)
}
}