Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v047 disable tests #5

Draft
wants to merge 13 commits into
base: consumer_sdk_upgrade_v047
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
174 changes: 87 additions & 87 deletions app/consumer-democracy/ante/forbidden_proposals_ante_test.go
Original file line number Diff line number Diff line change
@@ -1,97 +1,97 @@
package ante_test

import (
"testing"
// import (
// "testing"

sdk "github.com/cosmos/cosmos-sdk/types"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
govtypesv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
"github.com/cosmos/cosmos-sdk/x/params/types/proposal"
app "github.com/cosmos/interchain-security/app/consumer-democracy"
"github.com/cosmos/interchain-security/app/consumer-democracy/ante"
"github.com/stretchr/testify/require"
"github.com/tendermint/spm/cosmoscmd"
)
// sdk "github.com/cosmos/cosmos-sdk/types"
// authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
// banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
// govtypesv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
// "github.com/cosmos/cosmos-sdk/x/params/types/proposal"
// app "github.com/cosmos/interchain-security/app/consumer-democracy"
// "github.com/cosmos/interchain-security/app/consumer-democracy/ante"
// "github.com/stretchr/testify/require"
// "github.com/tendermint/spm/cosmoscmd"
// )

func TestForbiddenProposalsDecorator(t *testing.T) {
txCfg := cosmoscmd.MakeEncodingConfig(app.ModuleBasics).TxConfig
// func TestForbiddenProposalsDecorator(t *testing.T) {
// txCfg := cosmoscmd.MakeEncodingConfig(app.ModuleBasics).TxConfig

testCases := []struct {
name string
ctx sdk.Context
msgs []sdk.Msg
expectErr bool
}{
{
name: "Allowed param change",
ctx: sdk.Context{},
msgs: []sdk.Msg{
newParamChangeProposalMsg([]proposal.ParamChange{
//only subspace and key are relevant for testing
{Subspace: banktypes.ModuleName, Key: "SendEnabled", Value: ""},
}),
},
expectErr: false,
},
{
name: "Forbidden param change",
ctx: sdk.Context{},
msgs: []sdk.Msg{
newParamChangeProposalMsg([]proposal.ParamChange{
{Subspace: authtypes.ModuleName, Key: "MaxMemoCharacters", Value: ""},
}),
},
expectErr: true,
},
{
name: "Allowed and forbidden param changes in the same msg",
ctx: sdk.Context{},
msgs: []sdk.Msg{
newParamChangeProposalMsg([]proposal.ParamChange{
{Subspace: banktypes.ModuleName, Key: "SendEnabled", Value: ""},
{Subspace: authtypes.ModuleName, Key: "MaxMemoCharacters", Value: ""},
}),
},
expectErr: true,
},
{
name: "Allowed and forbidden param changes in different msg",
ctx: sdk.Context{},
msgs: []sdk.Msg{
newParamChangeProposalMsg([]proposal.ParamChange{
{Subspace: banktypes.ModuleName, Key: "SendEnabled", Value: ""},
}),
newParamChangeProposalMsg([]proposal.ParamChange{
{Subspace: authtypes.ModuleName, Key: "MaxMemoCharacters", Value: ""},
}),
},
expectErr: true,
},
}
// testCases := []struct {
// name string
// ctx sdk.Context
// msgs []sdk.Msg
// expectErr bool
// }{
// {
// name: "Allowed param change",
// ctx: sdk.Context{},
// msgs: []sdk.Msg{
// newParamChangeProposalMsg([]proposal.ParamChange{
// //only subspace and key are relevant for testing
// {Subspace: banktypes.ModuleName, Key: "SendEnabled", Value: ""},
// }),
// },
// expectErr: false,
// },
// {
// name: "Forbidden param change",
// ctx: sdk.Context{},
// msgs: []sdk.Msg{
// newParamChangeProposalMsg([]proposal.ParamChange{
// {Subspace: authtypes.ModuleName, Key: "MaxMemoCharacters", Value: ""},
// }),
// },
// expectErr: true,
// },
// {
// name: "Allowed and forbidden param changes in the same msg",
// ctx: sdk.Context{},
// msgs: []sdk.Msg{
// newParamChangeProposalMsg([]proposal.ParamChange{
// {Subspace: banktypes.ModuleName, Key: "SendEnabled", Value: ""},
// {Subspace: authtypes.ModuleName, Key: "MaxMemoCharacters", Value: ""},
// }),
// },
// expectErr: true,
// },
// {
// name: "Allowed and forbidden param changes in different msg",
// ctx: sdk.Context{},
// msgs: []sdk.Msg{
// newParamChangeProposalMsg([]proposal.ParamChange{
// {Subspace: banktypes.ModuleName, Key: "SendEnabled", Value: ""},
// }),
// newParamChangeProposalMsg([]proposal.ParamChange{
// {Subspace: authtypes.ModuleName, Key: "MaxMemoCharacters", Value: ""},
// }),
// },
// expectErr: true,
// },
// }

for _, tc := range testCases {
tc := tc
// for _, tc := range testCases {
// tc := tc

t.Run(tc.name, func(t *testing.T) {
handler := ante.NewForbiddenProposalsDecorator(app.IsProposalWhitelisted)
// t.Run(tc.name, func(t *testing.T) {
// handler := ante.NewForbiddenProposalsDecorator(app.IsProposalWhitelisted)

txBuilder := txCfg.NewTxBuilder()
require.NoError(t, txBuilder.SetMsgs(tc.msgs...))
// txBuilder := txCfg.NewTxBuilder()
// require.NoError(t, txBuilder.SetMsgs(tc.msgs...))

_, err := handler.AnteHandle(tc.ctx, txBuilder.GetTx(), false,
func(ctx sdk.Context, _ sdk.Tx, _ bool) (sdk.Context, error) { return ctx, nil })
if tc.expectErr {
require.Error(t, err)
} else {
require.NoError(t, err)
}
})
}
}
// _, err := handler.AnteHandle(tc.ctx, txBuilder.GetTx(), false,
// func(ctx sdk.Context, _ sdk.Tx, _ bool) (sdk.Context, error) { return ctx, nil })
// if tc.expectErr {
// require.Error(t, err)
// } else {
// require.NoError(t, err)
// }
// })
// }
// }

func newParamChangeProposalMsg(changes []proposal.ParamChange) *govtypesv1beta1.MsgSubmitProposal {
paramChange := proposal.ParameterChangeProposal{Changes: changes}
msg, _ := govtypesv1beta1.NewMsgSubmitProposal(&paramChange, sdk.NewCoins(), sdk.AccAddress{})
return msg
}
// func newParamChangeProposalMsg(changes []proposal.ParamChange) *govtypesv1beta1.MsgSubmitProposal {
// paramChange := proposal.ParameterChangeProposal{Changes: changes}
// msg, _ := govtypesv1beta1.NewMsgSubmitProposal(&paramChange, sdk.NewCoins(), sdk.AccAddress{})
// return msg
// }
Loading