Skip to content

Commit

Permalink
feat: add mint amount when create validator
Browse files Browse the repository at this point in the history
  • Loading branch information
hoanguyenkh committed Sep 7, 2022
1 parent ff416ee commit 8c1a1fc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
8 changes: 5 additions & 3 deletions x/staking/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func TestDuplicatesMsgCreateValidator(t *testing.T) {
pk1, pk2 := PKs[0], PKs[1]
tstaking := teststaking.NewHelper(t, ctx, app.StakingKeeper)

valTokens := tstaking.CreateValidatorWithValPower(addr1, pk1, 10, true)
valTokens := tstaking.CreateValidatorWithValPower(addr1, pk1, initPower, true)
app.StakingKeeper.ApplyAndReturnValidatorSetUpdates(ctx)

validator := tstaking.CheckValidator(addr1, types.Bonded, false)
Expand Down Expand Up @@ -183,7 +183,8 @@ func TestInvalidPubKeyTypeMsgCreateValidator(t *testing.T) {
}

func TestBothPubKeyTypesMsgCreateValidator(t *testing.T) {
app, ctx, _, valAddrs := bootstrapHandlerGenesisTest(t, 1000, 2, sdk.NewInt(1000))
val, _ := sdk.NewIntFromString("10000000000000000000000000")
app, ctx, _, valAddrs := bootstrapHandlerGenesisTest(t, 1000, 2, val)
ctx = ctx.WithConsensusParams(&abci.ConsensusParams{
Validator: &tmproto.ValidatorParams{PubKeyTypes: []string{tmtypes.ABCIPubKeyTypeEd25519, tmtypes.ABCIPubKeyTypeSecp256k1}},
})
Expand All @@ -208,7 +209,8 @@ func TestBothPubKeyTypesMsgCreateValidator(t *testing.T) {
}
for _, tc := range testCases {
t.Run(tc.name, func(*testing.T) {
tstaking.CreateValidator(tc.addr, tc.pk, sdk.NewInt(10), true)

tstaking.CreateValidator(tc.addr, tc.pk, val, true)
})
}
}
Expand Down
6 changes: 6 additions & 0 deletions x/staking/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ func (k msgServer) CreateValidator(goCtx context.Context, msg *types.MsgCreateVa
return nil, err
}

minValueCreateValidator, _ := sdk.NewIntFromString("1000000000000000000000000")

if msg.Value.Amount.LT(minValueCreateValidator) {
return nil, sdkerrors.Wrapf(sdkerrors.ErrInsufficientFunds, "create validator value must > 1000000000000000000000000")
}

// check to see if the pubkey or sender has been registered before
if _, found := k.GetValidator(ctx, valAddr); found {
return nil, types.ErrValidatorOwnerExists
Expand Down

0 comments on commit 8c1a1fc

Please sign in to comment.