github.com/cosmos/cosmos-sdk@v0.50.10/x/mint/keeper/msg_server_test.go (about)

     1  package keeper_test
     2  
     3  import (
     4  	sdkmath "cosmossdk.io/math"
     5  
     6  	sdk "github.com/cosmos/cosmos-sdk/types"
     7  	"github.com/cosmos/cosmos-sdk/x/mint/types"
     8  )
     9  
    10  func (s *IntegrationTestSuite) TestUpdateParams() {
    11  	testCases := []struct {
    12  		name      string
    13  		request   *types.MsgUpdateParams
    14  		expectErr bool
    15  	}{
    16  		{
    17  			name: "set invalid authority (not an address)",
    18  			request: &types.MsgUpdateParams{
    19  				Authority: "foo",
    20  			},
    21  			expectErr: true,
    22  		},
    23  		{
    24  			name: "set invalid authority (not defined authority)",
    25  			request: &types.MsgUpdateParams{
    26  				Authority: "cosmos139f7kncmglres2nf3h4hc4tade85ekfr8sulz5",
    27  			},
    28  			expectErr: true,
    29  		},
    30  		{
    31  			name: "set invalid params",
    32  			request: &types.MsgUpdateParams{
    33  				Authority: s.mintKeeper.GetAuthority(),
    34  				Params: types.Params{
    35  					MintDenom:           sdk.DefaultBondDenom,
    36  					InflationRateChange: sdkmath.LegacyNewDecWithPrec(-13, 2),
    37  					InflationMax:        sdkmath.LegacyNewDecWithPrec(20, 2),
    38  					InflationMin:        sdkmath.LegacyNewDecWithPrec(7, 2),
    39  					GoalBonded:          sdkmath.LegacyNewDecWithPrec(67, 2),
    40  					BlocksPerYear:       uint64(60 * 60 * 8766 / 5),
    41  				},
    42  			},
    43  			expectErr: true,
    44  		},
    45  		{
    46  			name: "set full valid params",
    47  			request: &types.MsgUpdateParams{
    48  				Authority: s.mintKeeper.GetAuthority(),
    49  				Params: types.Params{
    50  					MintDenom:           sdk.DefaultBondDenom,
    51  					InflationRateChange: sdkmath.LegacyNewDecWithPrec(8, 2),
    52  					InflationMax:        sdkmath.LegacyNewDecWithPrec(20, 2),
    53  					InflationMin:        sdkmath.LegacyNewDecWithPrec(2, 2),
    54  					GoalBonded:          sdkmath.LegacyNewDecWithPrec(37, 2),
    55  					BlocksPerYear:       uint64(60 * 60 * 8766 / 5),
    56  				},
    57  			},
    58  			expectErr: false,
    59  		},
    60  	}
    61  
    62  	for _, tc := range testCases {
    63  		tc := tc
    64  		s.Run(tc.name, func() {
    65  			_, err := s.msgServer.UpdateParams(s.ctx, tc.request)
    66  			if tc.expectErr {
    67  				s.Require().Error(err)
    68  			} else {
    69  				s.Require().NoError(err)
    70  			}
    71  		})
    72  	}
    73  }