cosmos-sdk/x/consensus/keeper/msg_server_test.go
Marko 6ec25b6261
feat: consensus module (#13164)
* add module

* pulsar

* fix++

* adddress comments

* comments on genesis methods

* register migration

* Update x/consensus/exported/exported.go

Co-authored-by: Amaury <1293565+amaurym@users.noreply.github.com>

* address

* remove annotations

* remove migrations

* fix lint

Co-authored-by: Amaury <1293565+amaurym@users.noreply.github.com>
2022-09-08 03:28:44 +00:00

66 lines
1.7 KiB
Go

package keeper_test
import (
"github.com/cosmos/cosmos-sdk/x/consensus/types"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
tmtypes "github.com/tendermint/tendermint/types"
)
func (s *KeeperTestSuite) TestUpdateParams() {
defaultConsensusParams := tmtypes.DefaultConsensusParams().ToProto()
testCases := []struct {
name string
input *types.MsgUpdateParams
expErr bool
expErrMsg string
}{
{
name: "valid params",
input: &types.MsgUpdateParams{
Authority: s.consensusParamsKeeper.GetAuthority(),
Block: defaultConsensusParams.Block,
Validator: defaultConsensusParams.Validator,
Evidence: defaultConsensusParams.Evidence,
},
expErr: false,
expErrMsg: "",
},
{
name: "invalid params",
input: &types.MsgUpdateParams{
Authority: s.consensusParamsKeeper.GetAuthority(),
Block: &tmproto.BlockParams{MaxGas: -10, MaxBytes: -10},
Validator: defaultConsensusParams.Validator,
Evidence: defaultConsensusParams.Evidence,
},
expErr: true,
expErrMsg: "block.MaxBytes must be greater than 0. Got -10",
},
{
name: "invalid authority",
input: &types.MsgUpdateParams{
Authority: "invalid",
Block: defaultConsensusParams.Block,
Validator: defaultConsensusParams.Validator,
Evidence: defaultConsensusParams.Evidence,
},
expErr: true,
expErrMsg: "invalid authority",
},
}
for _, tc := range testCases {
tc := tc
s.Run(tc.name, func() {
s.SetupTest()
_, err := s.msgServer.UpdateParams(s.ctx, tc.input)
if tc.expErr {
s.Require().Error(err)
s.Require().Contains(err.Error(), tc.expErrMsg)
} else {
s.Require().NoError(err)
}
})
}
}