Skip to content

Commit

Permalink
Merge pull request #65 from psaradev/issue#8365/staking_power_reducti…
Browse files Browse the repository at this point in the history
…on_chain_param

power reduction as on-chain param
  • Loading branch information
sunnya97 authored Feb 3, 2021
2 parents 2e9fd04 + 2a43a2d commit 2c1ef71
Show file tree
Hide file tree
Showing 87 changed files with 5,610 additions and 1,115 deletions.
6 changes: 6 additions & 0 deletions proto/cosmos/staking/v1beta1/staking.proto
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,12 @@ message Params {
uint32 historical_entries = 4 [(gogoproto.moretags) = "yaml:\"historical_entries\""];
// bond_denom defines the bondable coin denomination.
string bond_denom = 5 [(gogoproto.moretags) = "yaml:\"bond_denom\""];
// power_reduction is the amount of staking tokens required for 1 unit of consensus-engine power
string power_reduction = 6 [
(gogoproto.moretags) = "yaml:\"power_reduction\"",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.nullable) = false
];
}

// DelegationResponse is equivalent to Delegation except that it contains a
Expand Down
6 changes: 3 additions & 3 deletions simapp/simd/cmd/testnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,8 @@ func InitTestnet(
return err
}

accTokens := sdk.TokensFromConsensusPower(1000)
accStakingTokens := sdk.TokensFromConsensusPower(500)
accTokens := sdk.TokensFromConsensusPower(1000, sdk.DefaultPowerReduction)
accStakingTokens := sdk.TokensFromConsensusPower(500, sdk.DefaultPowerReduction)
coins := sdk.Coins{
sdk.NewCoin(fmt.Sprintf("%stoken", nodeDirName), accTokens),
sdk.NewCoin(sdk.DefaultBondDenom, accStakingTokens),
Expand All @@ -206,7 +206,7 @@ func InitTestnet(
genBalances = append(genBalances, banktypes.Balance{Address: addr.String(), Coins: coins.Sort()})
genAccounts = append(genAccounts, authtypes.NewBaseAccount(addr, nil, 0, 0))

valTokens := sdk.TokensFromConsensusPower(100)
valTokens := sdk.TokensFromConsensusPower(100, sdk.DefaultPowerReduction)
createValMsg, err := stakingtypes.NewMsgCreateValidator(
sdk.ValAddress(addr),
valPubKeys[i],
Expand Down
6 changes: 3 additions & 3 deletions testutil/network/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@ func DefaultConfig() Config {
NumValidators: 4,
BondDenom: sdk.DefaultBondDenom,
MinGasPrices: fmt.Sprintf("0.000006%s", sdk.DefaultBondDenom),
AccountTokens: sdk.TokensFromConsensusPower(1000),
StakingTokens: sdk.TokensFromConsensusPower(500),
BondedTokens: sdk.TokensFromConsensusPower(100),
AccountTokens: sdk.TokensFromConsensusPower(1000, sdk.DefaultPowerReduction),
StakingTokens: sdk.TokensFromConsensusPower(500, sdk.DefaultPowerReduction),
BondedTokens: sdk.TokensFromConsensusPower(100, sdk.DefaultPowerReduction),
PruningStrategy: storetypes.PruningOptionNothing,
CleanupDir: true,
SigningAlgo: string(hd.Secp256k1Type),
Expand Down
12 changes: 6 additions & 6 deletions types/staking.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ const (
ValidatorUpdateDelay int64 = 1
)

// PowerReduction is the amount of staking tokens required for 1 unit of consensus-engine power
var PowerReduction = NewIntFromBigInt(new(big.Int).Exp(big.NewInt(10), big.NewInt(6), nil))
// DefaultPowerReduction is the default amount of staking tokens required for 1 unit of consensus-engine power
var DefaultPowerReduction = NewIntFromBigInt(new(big.Int).Exp(big.NewInt(10), big.NewInt(6), nil))

// TokensToConsensusPower - convert input tokens to potential consensus-engine power
func TokensToConsensusPower(tokens Int) int64 {
return (tokens.Quo(PowerReduction)).Int64()
func TokensToConsensusPower(tokens Int, powerReduction Int) int64 {
return (tokens.Quo(powerReduction)).Int64()
}

// TokensFromConsensusPower - convert input power to tokens
func TokensFromConsensusPower(power int64) Int {
return NewInt(power).Mul(PowerReduction)
func TokensFromConsensusPower(power int64, powerReduction Int) Int {
return NewInt(power).Mul(powerReduction)
}
4 changes: 2 additions & 2 deletions types/staking_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ func (s *stakingTestSuite) SetupSuite() {
}

func (s *stakingTestSuite) TestTokensToConsensusPower() {
s.Require().Equal(int64(0), sdk.TokensToConsensusPower(sdk.NewInt(999_999)))
s.Require().Equal(int64(1), sdk.TokensToConsensusPower(sdk.NewInt(1_000_000)))
s.Require().Equal(int64(0), sdk.TokensToConsensusPower(sdk.NewInt(999_999), sdk.DefaultPowerReduction))
s.Require().Equal(int64(1), sdk.TokensToConsensusPower(sdk.NewInt(1_000_000), sdk.DefaultPowerReduction))
}
4 changes: 2 additions & 2 deletions x/auth/client/cli/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ func (s *IntegrationTestSuite) TestCLISendGenerateSignAndBroadcast() {
account, err := val1.ClientCtx.Keyring.Key("newAccount")
s.Require().NoError(err)

sendTokens := sdk.NewCoin(s.cfg.BondDenom, sdk.TokensFromConsensusPower(10))
sendTokens := sdk.NewCoin(s.cfg.BondDenom, sdk.TokensFromConsensusPower(10, sdk.DefaultPowerReduction))

normalGeneratedTx, err := bankcli.MsgSendExec(
val1.ClientCtx,
Expand Down Expand Up @@ -544,7 +544,7 @@ func (s *IntegrationTestSuite) TestCLIMultisignInsufficientCosigners() {
func (s *IntegrationTestSuite) TestCLIEncode() {
val1 := s.network.Validators[0]

sendTokens := sdk.NewCoin(s.cfg.BondDenom, sdk.TokensFromConsensusPower(10))
sendTokens := sdk.NewCoin(s.cfg.BondDenom, sdk.TokensFromConsensusPower(10, sdk.DefaultPowerReduction))

normalGeneratedTx, err := bankcli.MsgSendExec(
val1.ClientCtx,
Expand Down
6 changes: 3 additions & 3 deletions x/authz/simulation/operations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func (suite *SimTestSuite) TestWeightedOperations() {
func (suite *SimTestSuite) getTestingAccounts(r *rand.Rand, n int) []simtypes.Account {
accounts := simtypes.RandomAccounts(r, n)

initAmt := sdk.TokensFromConsensusPower(200000)
initAmt := suite.app.StakingKeeper.TokensFromConsensusPower(suite.ctx, 200000)
initCoins := sdk.NewCoins(sdk.NewCoin("foo", initAmt))

// add coins to the accounts
Expand Down Expand Up @@ -132,7 +132,7 @@ func (suite *SimTestSuite) TestSimulateRevokeAuthorization() {
AppHash: suite.app.LastCommitID().Hash,
}})

initAmt := sdk.TokensFromConsensusPower(200000)
initAmt := suite.app.StakingKeeper.TokensFromConsensusPower(suite.ctx, 200000)
initCoins := sdk.NewCoins(sdk.NewCoin("foo", initAmt))

granter := accounts[0]
Expand Down Expand Up @@ -167,7 +167,7 @@ func (suite *SimTestSuite) TestSimulateExecAuthorization() {
// begin a new block
suite.app.BeginBlock(abci.RequestBeginBlock{Header: tmproto.Header{Height: suite.app.LastBlockHeight() + 1, AppHash: suite.app.LastCommitID().Hash}})

initAmt := sdk.TokensFromConsensusPower(200000)
initAmt := suite.app.StakingKeeper.TokensFromConsensusPower(suite.ctx, 200000)
initCoins := sdk.NewCoins(sdk.NewCoin("foo", initAmt))

granter := accounts[0]
Expand Down
3 changes: 2 additions & 1 deletion x/bank/client/rest/tx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/cosmos/cosmos-sdk/simapp"
"github.com/cosmos/cosmos-sdk/testutil/network"
"github.com/cosmos/cosmos-sdk/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/types/rest"
authclient "github.com/cosmos/cosmos-sdk/x/auth/client"
Expand All @@ -28,7 +29,7 @@ func (s *IntegrationTestSuite) TestCoinSend() {

sendReq := generateSendReq(
account,
types.Coins{types.NewCoin(s.cfg.BondDenom, types.TokensFromConsensusPower(1))},
types.Coins{types.NewCoin(s.cfg.BondDenom, types.TokensFromConsensusPower(1, sdk.DefaultPowerReduction))},
)

stdTx, err := submitSendReq(val, sendReq)
Expand Down
5 changes: 3 additions & 2 deletions x/bank/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ var (
multiPermAcc = authtypes.NewEmptyModuleAccount(multiPerm, authtypes.Burner, authtypes.Minter, authtypes.Staking)
randomPermAcc = authtypes.NewEmptyModuleAccount(randomPerm, "random")

initTokens = sdk.TokensFromConsensusPower(initialPower)
// The default power validators are initialized to have within tests
initTokens = sdk.TokensFromConsensusPower(initialPower, sdk.DefaultPowerReduction)
initCoins = sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, initTokens))
)

Expand Down Expand Up @@ -86,7 +87,7 @@ func (suite *IntegrationTestSuite) TestSupply() {
app, ctx := suite.app, suite.ctx

initialPower := int64(100)
initTokens := sdk.TokensFromConsensusPower(initialPower)
initTokens := suite.app.StakingKeeper.TokensFromConsensusPower(suite.ctx, initialPower)

totalSupply := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, initTokens))
app.BankKeeper.SetSupply(ctx, types.NewSupply(totalSupply))
Expand Down
2 changes: 1 addition & 1 deletion x/bank/simulation/operations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func (suite *SimTestSuite) TestSimulateMsgMultiSend() {
func (suite *SimTestSuite) getTestingAccounts(r *rand.Rand, n int) []simtypes.Account {
accounts := simtypes.RandomAccounts(r, n)

initAmt := sdk.TokensFromConsensusPower(200)
initAmt := suite.app.StakingKeeper.TokensFromConsensusPower(suite.ctx, 200)
initCoins := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, initAmt))

// add coins to the accounts
Expand Down
14 changes: 7 additions & 7 deletions x/distribution/keeper/delegation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func TestCalculateRewardsAfterSlash(t *testing.T) {
ctx = ctx.WithBlockHeight(ctx.BlockHeight() + 3)

// allocate some rewards
initial := sdk.TokensFromConsensusPower(10)
initial := app.StakingKeeper.TokensFromConsensusPower(ctx, 10)
tokens := sdk.DecCoins{{Denom: sdk.DefaultBondDenom, Amount: initial.ToDec()}}
app.DistrKeeper.AllocateTokensToValidator(ctx, val, tokens)

Expand Down Expand Up @@ -175,7 +175,7 @@ func TestCalculateRewardsAfterManySlashes(t *testing.T) {
ctx = ctx.WithBlockHeight(ctx.BlockHeight() + 3)

// allocate some rewards
initial := sdk.TokensFromConsensusPower(10)
initial := app.StakingKeeper.TokensFromConsensusPower(ctx, 10)
tokens := sdk.DecCoins{{Denom: sdk.DefaultBondDenom, Amount: initial.ToDec()}}
app.DistrKeeper.AllocateTokensToValidator(ctx, val, tokens)

Expand Down Expand Up @@ -269,11 +269,11 @@ func TestCalculateRewardsMultiDelegator(t *testing.T) {
}

func TestWithdrawDelegationRewardsBasic(t *testing.T) {
balancePower := int64(1000)
balanceTokens := sdk.TokensFromConsensusPower(balancePower)
app := simapp.Setup(false)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})

balancePower := int64(1000)
balanceTokens := app.StakingKeeper.TokensFromConsensusPower(ctx, balancePower)
addr := simapp.AddTestAddrs(app, ctx, 1, sdk.NewInt(1000000000))
valAddrs := simapp.ConvertAddrsToValAddrs(addr)
tstaking := teststaking.NewHelper(t, ctx, app.StakingKeeper)
Expand Down Expand Up @@ -305,7 +305,7 @@ func TestWithdrawDelegationRewardsBasic(t *testing.T) {
val := app.StakingKeeper.Validator(ctx, valAddrs[0])

// allocate some rewards
initial := sdk.TokensFromConsensusPower(10)
initial := app.StakingKeeper.TokensFromConsensusPower(ctx, 10)
tokens := sdk.DecCoins{sdk.NewDecCoin(sdk.DefaultBondDenom, initial)}

app.DistrKeeper.AllocateTokensToValidator(ctx, val, tokens)
Expand Down Expand Up @@ -375,7 +375,7 @@ func TestCalculateRewardsAfterManySlashesInSameBlock(t *testing.T) {
ctx = ctx.WithBlockHeight(ctx.BlockHeight() + 3)

// allocate some rewards
initial := sdk.TokensFromConsensusPower(10).ToDec()
initial := app.StakingKeeper.TokensFromConsensusPower(ctx, 10).ToDec()
tokens := sdk.DecCoins{{Denom: sdk.DefaultBondDenom, Amount: initial}}
app.DistrKeeper.AllocateTokensToValidator(ctx, val, tokens)

Expand Down Expand Up @@ -431,7 +431,7 @@ func TestCalculateRewardsMultiDelegatorMultiSlash(t *testing.T) {
del1 := app.StakingKeeper.Delegation(ctx, sdk.AccAddress(valAddrs[0]), valAddrs[0])

// allocate some rewards
initial := sdk.TokensFromConsensusPower(30).ToDec()
initial := app.StakingKeeper.TokensFromConsensusPower(ctx, 30).ToDec()
tokens := sdk.DecCoins{{Denom: sdk.DefaultBondDenom, Amount: initial}}
app.DistrKeeper.AllocateTokensToValidator(ctx, val, tokens)

Expand Down
2 changes: 1 addition & 1 deletion x/distribution/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func TestWithdrawValidatorCommission(t *testing.T) {

// check initial balance
balance := app.BankKeeper.GetAllBalances(ctx, sdk.AccAddress(valAddrs[0]))
expTokens := sdk.TokensFromConsensusPower(1000)
expTokens := app.StakingKeeper.TokensFromConsensusPower(ctx, 1000)
expCoins := sdk.NewCoins(sdk.NewCoin("stake", expTokens))
require.Equal(t, expCoins, balance)

Expand Down
4 changes: 2 additions & 2 deletions x/distribution/simulation/operations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func (suite *SimTestSuite) TestSimulateMsgWithdrawDelegatorReward() {
validator0 := suite.getTestingValidator0(accounts)

// setup delegation
delTokens := sdk.TokensFromConsensusPower(2)
delTokens := suite.app.StakingKeeper.TokensFromConsensusPower(suite.ctx, 2)
validator0, issuedShares := validator0.AddTokensFromDel(delTokens)
delegator := accounts[1]
delegation := stakingtypes.NewDelegation(delegator.Address, validator0.GetOperator(), issuedShares)
Expand Down Expand Up @@ -223,7 +223,7 @@ func (suite *SimTestSuite) SetupTest() {
func (suite *SimTestSuite) getTestingAccounts(r *rand.Rand, n int) []simtypes.Account {
accounts := simtypes.RandomAccounts(r, n)

initAmt := sdk.TokensFromConsensusPower(200)
initAmt := suite.app.StakingKeeper.TokensFromConsensusPower(suite.ctx, 200)
initCoins := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, initAmt))

// add coins to the accounts
Expand Down
3 changes: 2 additions & 1 deletion x/evidence/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ var (
sdk.ValAddress(pubkeys[2].Address()),
}

initAmt = sdk.TokensFromConsensusPower(200)
// The default power validators are initialized to have within tests
initAmt = sdk.TokensFromConsensusPower(200, sdk.DefaultPowerReduction)
initCoins = sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, initAmt))
)

Expand Down
4 changes: 2 additions & 2 deletions x/feegrant/simulation/operations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func (suite *SimTestSuite) getTestingAccounts(r *rand.Rand, n int) []simtypes.Ac
accounts := simtypes.RandomAccounts(r, n)
require := suite.Require()

initAmt := sdk.TokensFromConsensusPower(200)
initAmt := app.StakingKeeper.TokensFromConsensusPower(ctx, 200)
initCoins := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, initAmt))

// add coins to the accounts
Expand Down Expand Up @@ -138,7 +138,7 @@ func (suite *SimTestSuite) TestSimulateMsgRevokeFeeAllowance() {
// begin a new block
app.BeginBlock(abci.RequestBeginBlock{Header: tmproto.Header{Height: suite.app.LastBlockHeight() + 1, AppHash: suite.app.LastCommitID().Hash}})

feeAmt := sdk.TokensFromConsensusPower(200000)
feeAmt := app.StakingKeeper.TokensFromConsensusPower(ctx, 200000)
feeCoins := sdk.NewCoins(sdk.NewCoin("foo", feeAmt))

granter, grantee := accounts[0], accounts[1]
Expand Down
6 changes: 3 additions & 3 deletions x/gov/abci_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ func TestTickPassedVotingPeriod(t *testing.T) {
require.False(t, activeQueue.Valid())
activeQueue.Close()

proposalCoins := sdk.Coins{sdk.NewCoin(sdk.DefaultBondDenom, sdk.TokensFromConsensusPower(5))}
proposalCoins := sdk.Coins{sdk.NewCoin(sdk.DefaultBondDenom, app.StakingKeeper.TokensFromConsensusPower(ctx, 5))}
newProposalMsg, err := types.NewMsgSubmitProposal(TestProposal, proposalCoins, addrs[0])
require.NoError(t, err)

Expand Down Expand Up @@ -295,7 +295,7 @@ func TestProposalPassedEndblocker(t *testing.T) {
proposal, err := app.GovKeeper.SubmitProposal(ctx, TestProposal)
require.NoError(t, err)

proposalCoins := sdk.Coins{sdk.NewCoin(sdk.DefaultBondDenom, sdk.TokensFromConsensusPower(10))}
proposalCoins := sdk.Coins{sdk.NewCoin(sdk.DefaultBondDenom, app.StakingKeeper.TokensFromConsensusPower(ctx, 10))}
newDepositMsg := types.NewMsgDeposit(addrs[0], proposal.ProposalId, proposalCoins)

handleAndCheck(t, handler, ctx, newDepositMsg)
Expand Down Expand Up @@ -343,7 +343,7 @@ func TestEndBlockerProposalHandlerFailed(t *testing.T) {
proposal, err := app.GovKeeper.SubmitProposal(ctx, TestProposal)
require.NoError(t, err)

proposalCoins := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.TokensFromConsensusPower(10)))
proposalCoins := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, app.StakingKeeper.TokensFromConsensusPower(ctx, 10)))
newDepositMsg := types.NewMsgDeposit(addrs[0], proposal.ProposalId, proposalCoins)

handleAndCheck(t, gov.NewHandler(app.GovKeeper), ctx, newDepositMsg)
Expand Down
4 changes: 2 additions & 2 deletions x/gov/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
)

var (
valTokens = sdk.TokensFromConsensusPower(42)
valTokens = sdk.TokensFromConsensusPower(42, sdk.DefaultPowerReduction)
TestProposal = types.NewTextProposal("Test", "description")
TestDescription = stakingtypes.NewDescription("T", "E", "S", "T", "Z")
TestCommissionRates = stakingtypes.NewCommissionRates(sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec())
Expand Down Expand Up @@ -82,7 +82,7 @@ func createValidators(t *testing.T, stakingHandler sdk.Handler, ctx sdk.Context,
require.True(t, len(addrs) <= len(pubkeys), "Not enough pubkeys specified at top of file.")

for i := 0; i < len(addrs); i++ {
valTokens := sdk.TokensFromConsensusPower(powerAmt[i])
valTokens := sdk.TokensFromConsensusPower(powerAmt[i], sdk.DefaultPowerReduction)
valCreateMsg, err := stakingtypes.NewMsgCreateValidator(
addrs[i], pubkeys[i], sdk.NewCoin(sdk.DefaultBondDenom, valTokens),
TestDescription, TestCommissionRates, sdk.OneInt(),
Expand Down
6 changes: 3 additions & 3 deletions x/gov/keeper/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ func createValidators(t *testing.T, ctx sdk.Context, app *simapp.SimApp, powers
app.StakingKeeper.SetNewValidatorByPowerIndex(ctx, val2)
app.StakingKeeper.SetNewValidatorByPowerIndex(ctx, val3)

_, _ = app.StakingKeeper.Delegate(ctx, addrs[0], sdk.TokensFromConsensusPower(powers[0]), stakingtypes.Unbonded, val1, true)
_, _ = app.StakingKeeper.Delegate(ctx, addrs[1], sdk.TokensFromConsensusPower(powers[1]), stakingtypes.Unbonded, val2, true)
_, _ = app.StakingKeeper.Delegate(ctx, addrs[2], sdk.TokensFromConsensusPower(powers[2]), stakingtypes.Unbonded, val3, true)
_, _ = app.StakingKeeper.Delegate(ctx, addrs[0], app.StakingKeeper.TokensFromConsensusPower(ctx, powers[0]), stakingtypes.Unbonded, val1, true)
_, _ = app.StakingKeeper.Delegate(ctx, addrs[1], app.StakingKeeper.TokensFromConsensusPower(ctx, powers[1]), stakingtypes.Unbonded, val2, true)
_, _ = app.StakingKeeper.Delegate(ctx, addrs[2], app.StakingKeeper.TokensFromConsensusPower(ctx, powers[2]), stakingtypes.Unbonded, val3, true)

_ = staking.EndBlocker(ctx, app.StakingKeeper)

Expand Down
4 changes: 2 additions & 2 deletions x/gov/keeper/deposit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ func TestDeposits(t *testing.T) {
require.NoError(t, err)
proposalID := proposal.ProposalId

fourStake := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.TokensFromConsensusPower(4)))
fiveStake := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.TokensFromConsensusPower(5)))
fourStake := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, app.StakingKeeper.TokensFromConsensusPower(ctx, 4)))
fiveStake := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, app.StakingKeeper.TokensFromConsensusPower(ctx, 5)))

addr0Initial := app.BankKeeper.GetAllBalances(ctx, TestAddrs[0])
addr1Initial := app.BankKeeper.GetAllBalances(ctx, TestAddrs[1])
Expand Down
8 changes: 4 additions & 4 deletions x/gov/keeper/grpc_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ func (suite *KeeperTestSuite) TestGRPCQueryProposals() {
{
"request with filter of deposit address",
func() {
depositCoins := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.TokensFromConsensusPower(20)))
depositCoins := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, app.StakingKeeper.TokensFromConsensusPower(ctx, 20)))
deposit := types.NewDeposit(testProposals[0].ProposalId, addrs[0], depositCoins)
app.GovKeeper.SetDeposit(ctx, deposit)

Expand Down Expand Up @@ -584,7 +584,7 @@ func (suite *KeeperTestSuite) TestGRPCQueryDeposit() {
{
"valid request",
func() {
depositCoins := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.TokensFromConsensusPower(20)))
depositCoins := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, app.StakingKeeper.TokensFromConsensusPower(ctx, 20)))
deposit := types.NewDeposit(proposal.ProposalId, addrs[0], depositCoins)
app.GovKeeper.SetDeposit(ctx, deposit)

Expand Down Expand Up @@ -671,11 +671,11 @@ func (suite *KeeperTestSuite) TestGRPCQueryDeposits() {
{
"get deposits with default limit",
func() {
depositAmount1 := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.TokensFromConsensusPower(20)))
depositAmount1 := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, app.StakingKeeper.TokensFromConsensusPower(ctx, 20)))
deposit1 := types.NewDeposit(proposal.ProposalId, addrs[0], depositAmount1)
app.GovKeeper.SetDeposit(ctx, deposit1)

depositAmount2 := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.TokensFromConsensusPower(30)))
depositAmount2 := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, app.StakingKeeper.TokensFromConsensusPower(ctx, 30)))
deposit2 := types.NewDeposit(proposal.ProposalId, addrs[1], depositAmount2)
app.GovKeeper.SetDeposit(ctx, deposit2)

Expand Down
2 changes: 1 addition & 1 deletion x/gov/keeper/querier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ func TestQueries(t *testing.T) {
TestAddrs := simapp.AddTestAddrsIncremental(app, ctx, 2, sdk.NewInt(20000001))

oneCoins := sdk.NewCoins(sdk.NewInt64Coin(sdk.DefaultBondDenom, 1))
consCoins := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.TokensFromConsensusPower(10)))
consCoins := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, app.StakingKeeper.TokensFromConsensusPower(ctx, 10)))

tp := TestProposal

Expand Down
Loading

0 comments on commit 2c1ef71

Please sign in to comment.