only import types pkgs within types

This commit is contained in:
rhuairahrighairigh 2020-04-28 01:28:00 +01:00
parent 307ecd54e2
commit d1c0dd18b1
5 changed files with 43 additions and 43 deletions

View File

@ -4,15 +4,15 @@ import (
"testing"
"time"
"github.com/cosmos/cosmos-sdk/x/gov"
"github.com/cosmos/cosmos-sdk/x/params"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
paramstypes "github.com/cosmos/cosmos-sdk/x/params/types"
"github.com/stretchr/testify/suite"
)
var _ PubProposal = UnregisteredPubProposal{}
type UnregisteredPubProposal struct {
gov.TextProposal
govtypes.TextProposal
}
func (UnregisteredPubProposal) ProposalRoute() string { return "unregistered" }
@ -39,10 +39,10 @@ func (suite *TypesTestSuite) TestCommittee_HasPermissionsFor() {
Key: "DebtThreshold",
},
}}},
pubProposal: params.NewParameterChangeProposal(
pubProposal: paramstypes.NewParameterChangeProposal(
"A Title",
"A description of this proposal.",
[]params.ParamChange{
[]paramstypes.ParamChange{
{
Subspace: "cdp",
Key: "DebtThreshold",
@ -65,7 +65,7 @@ func (suite *TypesTestSuite) TestCommittee_HasPermissionsFor() {
}},
TextPermission{},
},
pubProposal: gov.NewTextProposal("A Proposal Title", "A description of this proposal"),
pubProposal: govtypes.NewTextProposal("A Proposal Title", "A description of this proposal"),
expectHasPermissions: true,
},
{
@ -80,10 +80,10 @@ func (suite *TypesTestSuite) TestCommittee_HasPermissionsFor() {
}},
GodPermission{},
},
pubProposal: params.NewParameterChangeProposal(
pubProposal: paramstypes.NewParameterChangeProposal(
"A Title",
"A description of this proposal.",
[]params.ParamChange{
[]paramstypes.ParamChange{
{
Subspace: "cdp",
Key: "CollateralParams",
@ -97,10 +97,10 @@ func (suite *TypesTestSuite) TestCommittee_HasPermissionsFor() {
{
name: "no permissions",
permissions: nil,
pubProposal: params.NewParameterChangeProposal(
pubProposal: paramstypes.NewParameterChangeProposal(
"A Title",
"A description of this proposal.",
[]params.ParamChange{
[]paramstypes.ParamChange{
{
Subspace: "cdp",
Key: "CollateralParams",
@ -130,10 +130,10 @@ func (suite *TypesTestSuite) TestCommittee_HasPermissionsFor() {
},
}},
},
pubProposal: params.NewParameterChangeProposal(
pubProposal: paramstypes.NewParameterChangeProposal(
"A Title",
"A description of this proposal.",
[]params.ParamChange{
[]paramstypes.ParamChange{
{
Subspace: "cdp",
Key: "DebtThreshold",
@ -161,7 +161,7 @@ func (suite *TypesTestSuite) TestCommittee_HasPermissionsFor() {
},
}},
},
pubProposal: UnregisteredPubProposal{gov.TextProposal{"A Title", "A description."}},
pubProposal: UnregisteredPubProposal{govtypes.TextProposal{"A Title", "A description."}},
expectHasPermissions: false,
},
}

View File

@ -4,7 +4,6 @@ import (
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
)
// TODO nums ok?
var (
ErrUnknownCommittee = sdkerrors.Register(ModuleName, 2, "committee not found")
ErrInvalidCommittee = sdkerrors.Register(ModuleName, 3, "invalid committee")

View File

@ -7,7 +7,7 @@ import (
"github.com/stretchr/testify/require"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/gov"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
"github.com/tendermint/tendermint/crypto"
)
@ -42,7 +42,7 @@ func TestGenesisState_Validate(t *testing.T) {
},
},
Proposals: []Proposal{
{ID: 1, CommitteeID: 1, PubProposal: gov.NewTextProposal("A Title", "A description of this proposal."), Deadline: testTime.Add(7 * 24 * time.Hour)},
{ID: 1, CommitteeID: 1, PubProposal: govtypes.NewTextProposal("A Title", "A description of this proposal."), Deadline: testTime.Add(7 * 24 * time.Hour)},
},
Votes: []Vote{
{ProposalID: 1, Voter: addresses[0]},
@ -114,7 +114,7 @@ func TestGenesisState_Validate(t *testing.T) {
testGenesis.Proposals,
Proposal{
ID: testGenesis.NextProposalID,
PubProposal: gov.NewTextProposal("A Title", "A description of this proposal."),
PubProposal: govtypes.NewTextProposal("A Title", "A description of this proposal."),
CommitteeID: 247, // doesn't exist
}),
Votes: testGenesis.Votes,

View File

@ -6,7 +6,7 @@ import (
"github.com/stretchr/testify/require"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/gov"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
)
func TestMsgSubmitProposal_ValidateBasic(t *testing.T) {
@ -18,17 +18,17 @@ func TestMsgSubmitProposal_ValidateBasic(t *testing.T) {
}{
{
name: "normal",
msg: MsgSubmitProposal{gov.NewTextProposal("A Title", "A proposal description."), addr, 3},
msg: MsgSubmitProposal{govtypes.NewTextProposal("A Title", "A proposal description."), addr, 3},
expectPass: true,
},
{
name: "empty address",
msg: MsgSubmitProposal{gov.NewTextProposal("A Title", "A proposal description."), nil, 3},
msg: MsgSubmitProposal{govtypes.NewTextProposal("A Title", "A proposal description."), nil, 3},
expectPass: false,
},
{
name: "invalid proposal",
msg: MsgSubmitProposal{gov.TextProposal{}, addr, 3},
msg: MsgSubmitProposal{govtypes.TextProposal{}, addr, 3},
expectPass: false,
},
}

View File

@ -3,8 +3,8 @@ package types
import (
"testing"
"github.com/cosmos/cosmos-sdk/x/gov"
"github.com/cosmos/cosmos-sdk/x/params"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
paramstypes "github.com/cosmos/cosmos-sdk/x/params/types"
"github.com/stretchr/testify/suite"
)
@ -45,10 +45,10 @@ func (suite *PermissionsTestSuite) TestParamChangePermission_Allows() {
{
name: "normal (single param)",
allowedParams: suite.exampleAllowedParams,
pubProposal: params.NewParameterChangeProposal(
pubProposal: paramstypes.NewParameterChangeProposal(
"A Title",
"A description for this proposal.",
[]params.ParamChange{
[]paramstypes.ParamChange{
{
Subspace: "cdp",
Key: "DebtThreshold",
@ -62,10 +62,10 @@ func (suite *PermissionsTestSuite) TestParamChangePermission_Allows() {
{
name: "normal (multiple params)",
allowedParams: suite.exampleAllowedParams,
pubProposal: params.NewParameterChangeProposal(
pubProposal: paramstypes.NewParameterChangeProposal(
"A Title",
"A description for this proposal.",
[]params.ParamChange{
[]paramstypes.ParamChange{
{
Subspace: "cdp",
Key: "DebtThreshold",
@ -85,10 +85,10 @@ func (suite *PermissionsTestSuite) TestParamChangePermission_Allows() {
{
name: "not allowed (not in list)",
allowedParams: suite.exampleAllowedParams,
pubProposal: params.NewParameterChangeProposal(
pubProposal: paramstypes.NewParameterChangeProposal(
"A Title",
"A description for this proposal.",
[]params.ParamChange{
[]paramstypes.ParamChange{
{
Subspace: "cdp",
Key: "GlobalDebtLimit",
@ -102,10 +102,10 @@ func (suite *PermissionsTestSuite) TestParamChangePermission_Allows() {
{
name: "not allowed (nil allowed params)",
allowedParams: nil,
pubProposal: params.NewParameterChangeProposal(
pubProposal: paramstypes.NewParameterChangeProposal(
"A Title",
"A description for this proposal.",
[]params.ParamChange{
[]paramstypes.ParamChange{
{
Subspace: "cdp",
Key: "DebtThreshold",
@ -119,7 +119,7 @@ func (suite *PermissionsTestSuite) TestParamChangePermission_Allows() {
{
name: "not allowed (mismatched pubproposal type)",
allowedParams: suite.exampleAllowedParams,
pubProposal: gov.NewTextProposal("A Title", "A description of this proposal."),
pubProposal: govtypes.NewTextProposal("A Title", "A description of this proposal."),
expectAllowed: false,
},
{
@ -147,13 +147,13 @@ func (suite *PermissionsTestSuite) TestAllowedParams_Contains() {
testcases := []struct {
name string
allowedParams AllowedParams
testParam params.ParamChange
testParam paramstypes.ParamChange
expectContained bool
}{
{
name: "normal",
allowedParams: suite.exampleAllowedParams,
testParam: params.ParamChange{
testParam: paramstypes.ParamChange{
Subspace: "cdp",
Key: "DebtThreshold",
@ -164,7 +164,7 @@ func (suite *PermissionsTestSuite) TestAllowedParams_Contains() {
{
name: "missing subspace",
allowedParams: suite.exampleAllowedParams,
testParam: params.ParamChange{
testParam: paramstypes.ParamChange{
Subspace: "",
Key: "DebtThreshold",
@ -175,7 +175,7 @@ func (suite *PermissionsTestSuite) TestAllowedParams_Contains() {
{
name: "missing key",
allowedParams: suite.exampleAllowedParams,
testParam: params.ParamChange{
testParam: paramstypes.ParamChange{
Subspace: "cdp",
Key: "",
@ -186,7 +186,7 @@ func (suite *PermissionsTestSuite) TestAllowedParams_Contains() {
{
name: "empty list",
allowedParams: AllowedParams{},
testParam: params.ParamChange{
testParam: paramstypes.ParamChange{
Subspace: "cdp",
Key: "DebtThreshold",
@ -197,7 +197,7 @@ func (suite *PermissionsTestSuite) TestAllowedParams_Contains() {
{
name: "nil list",
allowedParams: nil,
testParam: params.ParamChange{
testParam: paramstypes.ParamChange{
Subspace: "cdp",
Key: "DebtThreshold",
@ -208,13 +208,13 @@ func (suite *PermissionsTestSuite) TestAllowedParams_Contains() {
{
name: "no param change",
allowedParams: suite.exampleAllowedParams,
testParam: params.ParamChange{},
testParam: paramstypes.ParamChange{},
expectContained: false,
},
{
name: "empty list and no param change",
allowedParams: AllowedParams{},
testParam: params.ParamChange{},
testParam: paramstypes.ParamChange{},
expectContained: false,
},
}
@ -237,7 +237,7 @@ func (suite *PermissionsTestSuite) TestTextPermission_Allows() {
}{
{
name: "normal",
pubProposal: gov.NewTextProposal(
pubProposal: govtypes.NewTextProposal(
"A Title",
"A description for this proposal.",
),
@ -245,10 +245,10 @@ func (suite *PermissionsTestSuite) TestTextPermission_Allows() {
},
{
name: "not allowed (wrong pubproposal type)",
pubProposal: params.NewParameterChangeProposal(
pubProposal: paramstypes.NewParameterChangeProposal(
"A Title",
"A description for this proposal.",
[]params.ParamChange{
[]paramstypes.ParamChange{
{
Subspace: "cdp",
Key: "DebtThreshold",
@ -280,6 +280,7 @@ func (suite *PermissionsTestSuite) TestTextPermission_Allows() {
})
}
}
func TestPermissionsTestSuite(t *testing.T) {
suite.Run(t, new(PermissionsTestSuite))
}