2020-09-25 21:36:36 +00:00
|
|
|
package policy
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
|
|
|
|
"github.com/filecoin-project/go-state-types/abi"
|
2020-10-08 01:09:33 +00:00
|
|
|
builtin0 "github.com/filecoin-project/specs-actors/actors/builtin"
|
2020-09-25 21:36:36 +00:00
|
|
|
miner0 "github.com/filecoin-project/specs-actors/actors/builtin/miner"
|
2020-10-08 01:09:33 +00:00
|
|
|
paych0 "github.com/filecoin-project/specs-actors/actors/builtin/paych"
|
2020-09-29 00:28:16 +00:00
|
|
|
verifreg0 "github.com/filecoin-project/specs-actors/actors/builtin/verifreg"
|
2020-10-08 01:09:33 +00:00
|
|
|
builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin"
|
2020-09-29 00:28:16 +00:00
|
|
|
miner2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/miner"
|
2020-10-08 01:09:33 +00:00
|
|
|
paych2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/paych"
|
2020-09-29 00:28:16 +00:00
|
|
|
verifreg2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/verifreg"
|
2020-09-25 21:36:36 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestSupportedProofTypes(t *testing.T) {
|
|
|
|
var oldTypes []abi.RegisteredSealProof
|
|
|
|
for t := range miner0.SupportedProofTypes {
|
|
|
|
oldTypes = append(oldTypes, t)
|
|
|
|
}
|
|
|
|
t.Cleanup(func() {
|
|
|
|
SetSupportedProofTypes(oldTypes...)
|
|
|
|
})
|
|
|
|
|
|
|
|
SetSupportedProofTypes(abi.RegisteredSealProof_StackedDrg2KiBV1)
|
|
|
|
require.EqualValues(t,
|
|
|
|
miner0.SupportedProofTypes,
|
|
|
|
map[abi.RegisteredSealProof]struct{}{
|
|
|
|
abi.RegisteredSealProof_StackedDrg2KiBV1: {},
|
|
|
|
},
|
|
|
|
)
|
|
|
|
AddSupportedProofTypes(abi.RegisteredSealProof_StackedDrg8MiBV1)
|
|
|
|
require.EqualValues(t,
|
|
|
|
miner0.SupportedProofTypes,
|
|
|
|
map[abi.RegisteredSealProof]struct{}{
|
|
|
|
abi.RegisteredSealProof_StackedDrg2KiBV1: {},
|
|
|
|
abi.RegisteredSealProof_StackedDrg8MiBV1: {},
|
|
|
|
},
|
|
|
|
)
|
|
|
|
}
|
2020-09-29 00:28:16 +00:00
|
|
|
|
|
|
|
// Tests assumptions about policies being the same between actor versions.
|
|
|
|
func TestAssumptions(t *testing.T) {
|
|
|
|
require.EqualValues(t, miner0.SupportedProofTypes, miner2.SupportedProofTypes)
|
|
|
|
require.Equal(t, miner0.PreCommitChallengeDelay, miner2.PreCommitChallengeDelay)
|
2020-10-08 01:09:33 +00:00
|
|
|
require.Equal(t, miner0.MaxSectorExpirationExtension, miner2.MaxSectorExpirationExtension)
|
2020-09-29 00:28:16 +00:00
|
|
|
require.Equal(t, miner0.ChainFinality, miner2.ChainFinality)
|
2020-10-05 21:28:47 +00:00
|
|
|
require.Equal(t, miner0.WPoStChallengeWindow, miner2.WPoStChallengeWindow)
|
|
|
|
require.Equal(t, miner0.WPoStProvingPeriod, miner2.WPoStProvingPeriod)
|
|
|
|
require.Equal(t, miner0.WPoStPeriodDeadlines, miner2.WPoStPeriodDeadlines)
|
2020-10-08 01:09:33 +00:00
|
|
|
require.Equal(t, miner0.AddressedSectorsMax, miner2.AddressedSectorsMax)
|
|
|
|
require.Equal(t, paych0.SettleDelay, paych2.SettleDelay)
|
2020-09-29 00:44:34 +00:00
|
|
|
require.True(t, verifreg0.MinVerifiedDealSize.Equals(verifreg2.MinVerifiedDealSize))
|
2020-09-29 00:28:16 +00:00
|
|
|
}
|
2020-10-08 01:09:33 +00:00
|
|
|
|
|
|
|
func TestPartitionSizes(t *testing.T) {
|
|
|
|
for p := range abi.PoStSealProofTypes {
|
|
|
|
sizeNew, err := builtin2.PoStProofWindowPoStPartitionSectors(p)
|
|
|
|
require.NoError(t, err)
|
|
|
|
sizeOld, err := builtin0.PoStProofWindowPoStPartitionSectors(p)
|
|
|
|
if err != nil {
|
|
|
|
// new proof type.
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
require.Equal(t, sizeOld, sizeNew)
|
|
|
|
}
|
|
|
|
}
|