Skip to content

Commit

Permalink
Merge pull request #4033 from filecoin-project/asr/add-supported-proof
Browse files Browse the repository at this point in the history
Fix AddSupportedProofTypes
  • Loading branch information
Jakub Sztandera authored Sep 25, 2020
2 parents 6db6a90 + a5f13a5 commit eaf3424
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 4 deletions.
6 changes: 2 additions & 4 deletions chain/actors/policy/policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,10 @@ func SetSupportedProofTypes(types ...abi.RegisteredSealProof) {
// AddSupportedProofTypes sets supported proof types, across all actor versions.
// This should only be used for testing.
func AddSupportedProofTypes(types ...abi.RegisteredSealProof) {
newTypes := make(map[abi.RegisteredSealProof]struct{}, len(types))
for _, t := range types {
newTypes[t] = struct{}{}
// Set for all miner versions.
miner0.SupportedProofTypes[t] = struct{}{}
}
// Set for all miner versions.
miner0.SupportedProofTypes = newTypes
}

// SetPreCommitChallengeDelay sets the pre-commit challenge delay across all
Expand Down
36 changes: 36 additions & 0 deletions chain/actors/policy/policy_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package policy

import (
"testing"

"github.com/stretchr/testify/require"

"github.com/filecoin-project/go-state-types/abi"
miner0 "github.com/filecoin-project/specs-actors/actors/builtin/miner"
)

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: {},
},
)
}

0 comments on commit eaf3424

Please sign in to comment.