Skip to content

Commit

Permalink
review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
aleem1314 committed Jul 19, 2021
1 parent c08db7e commit 77a2b1a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion x/slashing/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func TestUnJailNotBonded(t *testing.T) {
amt := app.StakingKeeper.TokensFromConsensusPower(ctx, 50)
msg := tstaking.CreateValidatorMsg(addr, val, amt)
msg.MinSelfDelegation = amt
res, err := tstaking.MsgSrvr.CreateValidator(sdk.WrapSDKContext(ctx), msg)
res, err := tstaking.CreateValidatorWithMsg(sdk.WrapSDKContext(ctx), msg)
require.NoError(t, err)
require.NotNil(t, res)

Expand Down
16 changes: 11 additions & 5 deletions x/staking/teststaking/helper.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package teststaking

import (
"context"
"testing"
"time"

Expand All @@ -17,7 +18,7 @@ import (
// and provides methods useful in tests
type Helper struct {
t *testing.T
MsgSrvr stakingtypes.MsgServer
msgSrvr stakingtypes.MsgServer
k keeper.Keeper

Ctx sdk.Context
Expand Down Expand Up @@ -54,10 +55,15 @@ func (sh *Helper) CreateValidatorMsg(addr sdk.ValAddress, pk cryptotypes.PubKey,
return msg
}

// CreateValidatorWithMsg calls staking module `MsgServer/CreateValidator`
func (sh *Helper) CreateValidatorWithMsg(ctx context.Context, msg *stakingtypes.MsgCreateValidator) (*stakingtypes.MsgCreateValidatorResponse, error) {
return sh.msgSrvr.CreateValidator(ctx, msg)
}

func (sh *Helper) createValidator(addr sdk.ValAddress, pk cryptotypes.PubKey, coin sdk.Coin, ok bool) {
msg, err := stakingtypes.NewMsgCreateValidator(addr, pk, coin, stakingtypes.Description{}, sh.Commission, sdk.OneInt())
require.NoError(sh.t, err)
res, err := sh.MsgSrvr.CreateValidator(sdk.WrapSDKContext(sh.Ctx), msg)
res, err := sh.msgSrvr.CreateValidator(sdk.WrapSDKContext(sh.Ctx), msg)
if ok {
require.NoError(sh.t, err)
require.NotNil(sh.t, res)
Expand All @@ -71,7 +77,7 @@ func (sh *Helper) createValidator(addr sdk.ValAddress, pk cryptotypes.PubKey, co
func (sh *Helper) Delegate(delegator sdk.AccAddress, val sdk.ValAddress, amount sdk.Int) {
coin := sdk.NewCoin(sh.Denom, amount)
msg := stakingtypes.NewMsgDelegate(delegator, val, coin)
res, err := sh.MsgSrvr.Delegate(sdk.WrapSDKContext(sh.Ctx), msg)
res, err := sh.msgSrvr.Delegate(sdk.WrapSDKContext(sh.Ctx), msg)
require.NoError(sh.t, err)
require.NotNil(sh.t, res)
}
Expand All @@ -80,7 +86,7 @@ func (sh *Helper) Delegate(delegator sdk.AccAddress, val sdk.ValAddress, amount
func (sh *Helper) DelegateWithPower(delegator sdk.AccAddress, val sdk.ValAddress, power int64) {
coin := sdk.NewCoin(sh.Denom, sh.k.TokensFromConsensusPower(sh.Ctx, power))
msg := stakingtypes.NewMsgDelegate(delegator, val, coin)
res, err := sh.MsgSrvr.Delegate(sdk.WrapSDKContext(sh.Ctx), msg)
res, err := sh.msgSrvr.Delegate(sdk.WrapSDKContext(sh.Ctx), msg)
require.NoError(sh.t, err)
require.NotNil(sh.t, res)
}
Expand All @@ -89,7 +95,7 @@ func (sh *Helper) DelegateWithPower(delegator sdk.AccAddress, val sdk.ValAddress
func (sh *Helper) Undelegate(delegator sdk.AccAddress, val sdk.ValAddress, amount sdk.Int, ok bool) {
unbondAmt := sdk.NewCoin(sh.Denom, amount)
msg := stakingtypes.NewMsgUndelegate(delegator, val, unbondAmt)
res, err := sh.MsgSrvr.Undelegate(sdk.WrapSDKContext(sh.Ctx), msg)
res, err := sh.msgSrvr.Undelegate(sdk.WrapSDKContext(sh.Ctx), msg)
if ok {
require.NoError(sh.t, err)
require.NotNil(sh.t, res)
Expand Down

0 comments on commit 77a2b1a

Please sign in to comment.