forked from cosmos/cosmos-sdk
-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
min commission rate check on create validator (#11)
add MustUpdateValidatorCommission
- Loading branch information
1 parent
2228736
commit 07832f2
Showing
4 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package keeper_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
tmproto "github.com/tendermint/tendermint/proto/tendermint/types" | ||
|
||
"github.com/cosmos/cosmos-sdk/simapp" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/cosmos/cosmos-sdk/x/staking" | ||
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" | ||
) | ||
|
||
func TestCreateValidatorWithLessThanMinCommission(t *testing.T) { | ||
PKS := simapp.CreateTestPubKeys(1) | ||
valConsPk1 := PKS[0] | ||
|
||
app := simapp.Setup(false) | ||
ctx := app.BaseApp.NewContext(false, tmproto.Header{}) | ||
|
||
addrs := simapp.AddTestAddrs(app, ctx, 3, sdk.NewInt(1234)) | ||
|
||
// set min commission rate to non-zero | ||
params := app.StakingKeeper.GetParams(ctx) | ||
params.MinCommissionRate = sdk.NewDecWithPrec(1, 2) | ||
app.StakingKeeper.SetParams(ctx, params) | ||
|
||
// create validator with 0% commission | ||
msg, err := stakingtypes.NewMsgCreateValidator( | ||
sdk.ValAddress(addrs[0]), | ||
valConsPk1, | ||
sdk.NewInt64Coin(sdk.DefaultBondDenom, 100), | ||
stakingtypes.Description{}, | ||
stakingtypes.NewCommissionRates(sdk.NewDec(0), sdk.NewDecWithPrec(5, 1), sdk.NewDec(0)), | ||
sdk.OneInt()) | ||
require.NoError(t, err) | ||
|
||
sh := staking.NewHandler(app.StakingKeeper) | ||
_, err = sh(ctx, msg) | ||
require.Error(t, err) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters