Co-authored-by: Julien Robert <julien@rbrt.fr>
This commit is contained in:
co-authored by
Julien Robert
parent
ce54aab92e
commit
d9c53bfefc
@@ -9,6 +9,7 @@ import (
|
||||
|
||||
"cosmossdk.io/core/appmodule"
|
||||
"cosmossdk.io/log"
|
||||
"cosmossdk.io/math"
|
||||
storetypes "cosmossdk.io/store/types"
|
||||
|
||||
addresscodec "github.com/cosmos/cosmos-sdk/codec/address"
|
||||
@@ -35,7 +36,7 @@ import (
|
||||
var (
|
||||
denomRegex = sdk.DefaultCoinDenomRegex()
|
||||
addr1 = sdk.MustAccAddressFromBech32("cosmos139f7kncmglres2nf3h4hc4tade85ekfr8sulz5")
|
||||
coin1 = sdk.NewCoin("denom", sdk.NewInt(10))
|
||||
coin1 = sdk.NewCoin("denom", math.NewInt(10))
|
||||
metadataAtom = banktypes.Metadata{
|
||||
Description: "The native staking token of the Cosmos Hub.",
|
||||
DenomUnits: []*banktypes.DenomUnit{
|
||||
@@ -133,7 +134,7 @@ func fundAccount(f *deterministicFixture, addr sdk.AccAddress, coin ...sdk.Coin)
|
||||
func getCoin(rt *rapid.T) sdk.Coin {
|
||||
return sdk.NewCoin(
|
||||
rapid.StringMatching(denomRegex).Draw(rt, "denom"),
|
||||
sdk.NewInt(rapid.Int64Min(1).Draw(rt, "amount")),
|
||||
math.NewInt(rapid.Int64Min(1).Draw(rt, "amount")),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -179,8 +180,8 @@ func TestGRPCQueryAllBalances(t *testing.T) {
|
||||
})
|
||||
|
||||
coins := sdk.NewCoins(
|
||||
sdk.NewCoin("stake", sdk.NewInt(10)),
|
||||
sdk.NewCoin("denom", sdk.NewInt(100)),
|
||||
sdk.NewCoin("stake", math.NewInt(10)),
|
||||
sdk.NewCoin("denom", math.NewInt(100)),
|
||||
)
|
||||
|
||||
fundAccount(f, addr1, coins...)
|
||||
@@ -202,7 +203,7 @@ func TestGRPCQuerySpendableBalances(t *testing.T) {
|
||||
for _, denom := range denoms {
|
||||
coin := sdk.NewCoin(
|
||||
denom,
|
||||
sdk.NewInt(rapid.Int64Min(1).Draw(rt, "amount")),
|
||||
math.NewInt(rapid.Int64Min(1).Draw(rt, "amount")),
|
||||
)
|
||||
|
||||
// NewCoins sorts the denoms
|
||||
@@ -217,8 +218,8 @@ func TestGRPCQuerySpendableBalances(t *testing.T) {
|
||||
})
|
||||
|
||||
coins := sdk.NewCoins(
|
||||
sdk.NewCoin("stake", sdk.NewInt(10)),
|
||||
sdk.NewCoin("denom", sdk.NewInt(100)),
|
||||
sdk.NewCoin("stake", math.NewInt(10)),
|
||||
sdk.NewCoin("denom", math.NewInt(100)),
|
||||
)
|
||||
|
||||
err := banktestutil.FundAccount(f.ctx, f.bankKeeper, addr1, coins)
|
||||
@@ -243,7 +244,7 @@ func TestGRPCQueryTotalSupply(t *testing.T) {
|
||||
for i := 0; i < numCoins; i++ {
|
||||
coin := sdk.NewCoin(
|
||||
rapid.StringMatching(denomRegex).Draw(rt, "denom"),
|
||||
sdk.NewInt(rapid.Int64Min(1).Draw(rt, "amount")),
|
||||
math.NewInt(rapid.Int64Min(1).Draw(rt, "amount")),
|
||||
)
|
||||
|
||||
coins = coins.Add(coin)
|
||||
@@ -263,8 +264,8 @@ func TestGRPCQueryTotalSupply(t *testing.T) {
|
||||
f = initDeterministicFixture(t) // reset
|
||||
|
||||
coins := sdk.NewCoins(
|
||||
sdk.NewCoin("foo", sdk.NewInt(10)),
|
||||
sdk.NewCoin("bar", sdk.NewInt(100)),
|
||||
sdk.NewCoin("foo", math.NewInt(10)),
|
||||
sdk.NewCoin("bar", math.NewInt(100)),
|
||||
)
|
||||
|
||||
assert.NilError(t, f.bankKeeper.MintCoins(f.ctx, minttypes.ModuleName, coins))
|
||||
@@ -280,7 +281,7 @@ func TestGRPCQueryTotalSupplyOf(t *testing.T) {
|
||||
rapid.Check(t, func(rt *rapid.T) {
|
||||
coin := sdk.NewCoin(
|
||||
rapid.StringMatching(denomRegex).Draw(rt, "denom"),
|
||||
sdk.NewInt(rapid.Int64Min(1).Draw(rt, "amount")),
|
||||
math.NewInt(rapid.Int64Min(1).Draw(rt, "amount")),
|
||||
)
|
||||
|
||||
assert.NilError(t, f.bankKeeper.MintCoins(f.ctx, minttypes.ModuleName, sdk.NewCoins(coin)))
|
||||
@@ -289,7 +290,7 @@ func TestGRPCQueryTotalSupplyOf(t *testing.T) {
|
||||
testdata.DeterministicIterations(f.ctx, t, req, f.queryClient.SupplyOf, 0, true)
|
||||
})
|
||||
|
||||
coin := sdk.NewCoin("bar", sdk.NewInt(100))
|
||||
coin := sdk.NewCoin("bar", math.NewInt(100))
|
||||
|
||||
assert.NilError(t, f.bankKeeper.MintCoins(f.ctx, minttypes.ModuleName, sdk.NewCoins(coin)))
|
||||
req := &banktypes.QuerySupplyOfRequest{Denom: coin.GetDenom()}
|
||||
@@ -482,7 +483,7 @@ func TestGRPCDenomOwners(t *testing.T) {
|
||||
|
||||
coin := sdk.NewCoin(
|
||||
denom,
|
||||
sdk.NewInt(rapid.Int64Min(1).Draw(rt, "amount")),
|
||||
math.NewInt(rapid.Int64Min(1).Draw(rt, "amount")),
|
||||
)
|
||||
|
||||
err := banktestutil.FundAccount(f.ctx, f.bankKeeper, addr, sdk.NewCoins(coin))
|
||||
|
||||
@@ -46,7 +46,7 @@ func TestGRPCParams(t *testing.T) {
|
||||
name: "valid request",
|
||||
malleate: func() {
|
||||
params = types.Params{
|
||||
CommunityTax: sdk.NewDecWithPrec(3, 1),
|
||||
CommunityTax: math.LegacyNewDecWithPrec(3, 1),
|
||||
BaseProposerReward: math.LegacyZeroDec(),
|
||||
BonusProposerReward: math.LegacyZeroDec(),
|
||||
WithdrawAddrEnabled: true,
|
||||
@@ -97,8 +97,8 @@ func TestGRPCValidatorOutstandingRewards(t *testing.T) {
|
||||
|
||||
initialStake := int64(10)
|
||||
tstaking := stakingtestutil.NewHelper(t, f.sdkCtx, f.stakingKeeper)
|
||||
tstaking.Commission = stakingtypes.NewCommissionRates(sdk.NewDecWithPrec(5, 1), sdk.NewDecWithPrec(5, 1), math.LegacyNewDec(0))
|
||||
tstaking.CreateValidator(f.valAddr, valConsPk0, sdk.NewInt(initialStake), true)
|
||||
tstaking.Commission = stakingtypes.NewCommissionRates(math.LegacyNewDecWithPrec(5, 1), math.LegacyNewDecWithPrec(5, 1), math.LegacyNewDec(0))
|
||||
tstaking.CreateValidator(f.valAddr, valConsPk0, math.NewInt(initialStake), true)
|
||||
|
||||
// set outstanding rewards
|
||||
err := f.distrKeeper.SetValidatorOutstandingRewards(f.sdkCtx, f.valAddr, types.ValidatorOutstandingRewards{Rewards: valCommission})
|
||||
@@ -169,8 +169,8 @@ func TestGRPCValidatorCommission(t *testing.T) {
|
||||
|
||||
initialStake := int64(10)
|
||||
tstaking := stakingtestutil.NewHelper(t, f.sdkCtx, f.stakingKeeper)
|
||||
tstaking.Commission = stakingtypes.NewCommissionRates(sdk.NewDecWithPrec(5, 1), sdk.NewDecWithPrec(5, 1), math.LegacyNewDec(0))
|
||||
tstaking.CreateValidator(f.valAddr, valConsPk0, sdk.NewInt(initialStake), true)
|
||||
tstaking.Commission = stakingtypes.NewCommissionRates(math.LegacyNewDecWithPrec(5, 1), math.LegacyNewDecWithPrec(5, 1), math.LegacyNewDec(0))
|
||||
tstaking.CreateValidator(f.valAddr, valConsPk0, math.NewInt(initialStake), true)
|
||||
|
||||
commission := sdk.DecCoins{sdk.DecCoin{Denom: "token1", Amount: math.LegacyNewDec(4)}, {Denom: "token2", Amount: math.LegacyNewDec(2)}}
|
||||
assert.NilError(t, f.distrKeeper.SetValidatorAccumulatedCommission(f.sdkCtx, f.valAddr, types.ValidatorAccumulatedCommission{Commission: commission}))
|
||||
@@ -228,10 +228,10 @@ func TestGRPCValidatorSlashes(t *testing.T) {
|
||||
valAddr2 := sdk.ValAddress(addr2)
|
||||
|
||||
slashes := []types.ValidatorSlashEvent{
|
||||
types.NewValidatorSlashEvent(3, sdk.NewDecWithPrec(5, 1)),
|
||||
types.NewValidatorSlashEvent(5, sdk.NewDecWithPrec(5, 1)),
|
||||
types.NewValidatorSlashEvent(7, sdk.NewDecWithPrec(5, 1)),
|
||||
types.NewValidatorSlashEvent(9, sdk.NewDecWithPrec(5, 1)),
|
||||
types.NewValidatorSlashEvent(3, math.LegacyNewDecWithPrec(5, 1)),
|
||||
types.NewValidatorSlashEvent(5, math.LegacyNewDecWithPrec(5, 1)),
|
||||
types.NewValidatorSlashEvent(7, math.LegacyNewDecWithPrec(5, 1)),
|
||||
types.NewValidatorSlashEvent(9, math.LegacyNewDecWithPrec(5, 1)),
|
||||
}
|
||||
|
||||
for i, slash := range slashes {
|
||||
@@ -499,8 +499,8 @@ func TestGRPCDelegationRewards(t *testing.T) {
|
||||
|
||||
initialStake := int64(10)
|
||||
tstaking := stakingtestutil.NewHelper(t, f.sdkCtx, f.stakingKeeper)
|
||||
tstaking.Commission = stakingtypes.NewCommissionRates(sdk.NewDecWithPrec(5, 1), sdk.NewDecWithPrec(5, 1), math.LegacyNewDec(0))
|
||||
tstaking.CreateValidator(f.valAddr, valConsPk0, sdk.NewInt(initialStake), true)
|
||||
tstaking.Commission = stakingtypes.NewCommissionRates(math.LegacyNewDecWithPrec(5, 1), math.LegacyNewDecWithPrec(5, 1), math.LegacyNewDec(0))
|
||||
tstaking.CreateValidator(f.valAddr, valConsPk0, math.NewInt(initialStake), true)
|
||||
|
||||
val, found := f.stakingKeeper.GetValidator(f.sdkCtx, f.valAddr)
|
||||
assert.Assert(t, found)
|
||||
|
||||
@@ -179,7 +179,7 @@ func TestMsgWithdrawDelegatorReward(t *testing.T) {
|
||||
validator, err = validator.SetInitialCommission(commission)
|
||||
assert.NilError(t, err)
|
||||
validator.DelegatorShares = math.LegacyNewDec(100)
|
||||
validator.Tokens = sdk.NewInt(1000000)
|
||||
validator.Tokens = math.NewInt(1000000)
|
||||
assert.NilError(t, f.stakingKeeper.SetValidator(f.sdkCtx, validator))
|
||||
|
||||
// set module account coins
|
||||
@@ -474,7 +474,7 @@ func TestMsgWithdrawValidatorCommission(t *testing.T) {
|
||||
// send funds to val addr
|
||||
err = f.bankKeeper.SendCoinsFromModuleToAccount(f.sdkCtx, distrtypes.ModuleName, sdk.AccAddress(f.valAddr), sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, initTokens)))
|
||||
require.NoError(t, err)
|
||||
coins := sdk.NewCoins(sdk.NewCoin("mytoken", sdk.NewInt(2)), sdk.NewCoin("stake", sdk.NewInt(2)))
|
||||
coins := sdk.NewCoins(sdk.NewCoin("mytoken", math.NewInt(2)), sdk.NewCoin("stake", math.NewInt(2)))
|
||||
err = f.bankKeeper.MintCoins(f.sdkCtx, distrtypes.ModuleName, coins)
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -545,7 +545,7 @@ func TestMsgWithdrawValidatorCommission(t *testing.T) {
|
||||
// check balance increase
|
||||
balance = f.bankKeeper.GetAllBalances(f.sdkCtx, sdk.AccAddress(f.valAddr))
|
||||
assert.DeepEqual(t, sdk.NewCoins(
|
||||
sdk.NewCoin("mytoken", sdk.NewInt(1)),
|
||||
sdk.NewCoin("mytoken", math.NewInt(1)),
|
||||
sdk.NewCoin("stake", expTokens.AddRaw(1)),
|
||||
), balance)
|
||||
|
||||
@@ -592,7 +592,7 @@ func TestMsgFundCommunityPool(t *testing.T) {
|
||||
{
|
||||
name: "no depositor address",
|
||||
msg: &distrtypes.MsgFundCommunityPool{
|
||||
Amount: sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(100))),
|
||||
Amount: sdk.NewCoins(sdk.NewCoin("stake", math.NewInt(100))),
|
||||
Depositor: emptyDelAddr.String(),
|
||||
},
|
||||
expErr: true,
|
||||
@@ -610,7 +610,7 @@ func TestMsgFundCommunityPool(t *testing.T) {
|
||||
{
|
||||
name: "depositor address with no funds",
|
||||
msg: &distrtypes.MsgFundCommunityPool{
|
||||
Amount: sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(100))),
|
||||
Amount: sdk.NewCoins(sdk.NewCoin("stake", math.NewInt(100))),
|
||||
Depositor: addr2.String(),
|
||||
},
|
||||
expErr: true,
|
||||
@@ -619,7 +619,7 @@ func TestMsgFundCommunityPool(t *testing.T) {
|
||||
{
|
||||
name: "valid message",
|
||||
msg: &distrtypes.MsgFundCommunityPool{
|
||||
Amount: sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(100))),
|
||||
Amount: sdk.NewCoins(sdk.NewCoin("stake", math.NewInt(100))),
|
||||
Depositor: addr.String(),
|
||||
},
|
||||
expErr: false,
|
||||
@@ -659,7 +659,7 @@ func TestMsgUpdateParams(t *testing.T) {
|
||||
f := initFixture(t)
|
||||
|
||||
// default params
|
||||
communityTax := sdk.NewDecWithPrec(2, 2) // 2%
|
||||
communityTax := math.LegacyNewDecWithPrec(2, 2) // 2%
|
||||
withdrawAddrEnabled := true
|
||||
|
||||
testCases := []struct {
|
||||
@@ -673,7 +673,7 @@ func TestMsgUpdateParams(t *testing.T) {
|
||||
msg: &distrtypes.MsgUpdateParams{
|
||||
Authority: "invalid",
|
||||
Params: distrtypes.Params{
|
||||
CommunityTax: sdk.NewDecWithPrec(2, 0),
|
||||
CommunityTax: math.LegacyNewDecWithPrec(2, 0),
|
||||
WithdrawAddrEnabled: withdrawAddrEnabled,
|
||||
BaseProposerReward: math.LegacyZeroDec(),
|
||||
BonusProposerReward: math.LegacyZeroDec(),
|
||||
@@ -687,7 +687,7 @@ func TestMsgUpdateParams(t *testing.T) {
|
||||
msg: &distrtypes.MsgUpdateParams{
|
||||
Authority: f.distrKeeper.GetAuthority(),
|
||||
Params: distrtypes.Params{
|
||||
CommunityTax: sdk.NewDecWithPrec(2, 0),
|
||||
CommunityTax: math.LegacyNewDecWithPrec(2, 0),
|
||||
WithdrawAddrEnabled: withdrawAddrEnabled,
|
||||
BaseProposerReward: math.LegacyZeroDec(),
|
||||
BonusProposerReward: math.LegacyZeroDec(),
|
||||
@@ -701,7 +701,7 @@ func TestMsgUpdateParams(t *testing.T) {
|
||||
msg: &distrtypes.MsgUpdateParams{
|
||||
Authority: f.distrKeeper.GetAuthority(),
|
||||
Params: distrtypes.Params{
|
||||
CommunityTax: sdk.NewDecWithPrec(-2, 1),
|
||||
CommunityTax: math.LegacyNewDecWithPrec(-2, 1),
|
||||
WithdrawAddrEnabled: withdrawAddrEnabled,
|
||||
BaseProposerReward: math.LegacyZeroDec(),
|
||||
BonusProposerReward: math.LegacyZeroDec(),
|
||||
@@ -716,7 +716,7 @@ func TestMsgUpdateParams(t *testing.T) {
|
||||
Authority: f.distrKeeper.GetAuthority(),
|
||||
Params: distrtypes.Params{
|
||||
CommunityTax: communityTax,
|
||||
BaseProposerReward: sdk.NewDecWithPrec(1, 2),
|
||||
BaseProposerReward: math.LegacyNewDecWithPrec(1, 2),
|
||||
BonusProposerReward: math.LegacyZeroDec(),
|
||||
WithdrawAddrEnabled: withdrawAddrEnabled,
|
||||
},
|
||||
@@ -731,7 +731,7 @@ func TestMsgUpdateParams(t *testing.T) {
|
||||
Params: distrtypes.Params{
|
||||
CommunityTax: communityTax,
|
||||
BaseProposerReward: math.LegacyZeroDec(),
|
||||
BonusProposerReward: sdk.NewDecWithPrec(1, 2),
|
||||
BonusProposerReward: math.LegacyNewDecWithPrec(1, 2),
|
||||
WithdrawAddrEnabled: withdrawAddrEnabled,
|
||||
},
|
||||
},
|
||||
@@ -807,7 +807,7 @@ func TestMsgCommunityPoolSpend(t *testing.T) {
|
||||
msg: &distrtypes.MsgCommunityPoolSpend{
|
||||
Authority: "invalid",
|
||||
Recipient: recipient.String(),
|
||||
Amount: sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(100))),
|
||||
Amount: sdk.NewCoins(sdk.NewCoin("stake", math.NewInt(100))),
|
||||
},
|
||||
expErr: true,
|
||||
expErrMsg: "invalid authority",
|
||||
@@ -817,7 +817,7 @@ func TestMsgCommunityPoolSpend(t *testing.T) {
|
||||
msg: &distrtypes.MsgCommunityPoolSpend{
|
||||
Authority: f.distrKeeper.GetAuthority(),
|
||||
Recipient: "invalid",
|
||||
Amount: sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(100))),
|
||||
Amount: sdk.NewCoins(sdk.NewCoin("stake", math.NewInt(100))),
|
||||
},
|
||||
expErr: true,
|
||||
expErrMsg: "decoding bech32 failed",
|
||||
@@ -827,7 +827,7 @@ func TestMsgCommunityPoolSpend(t *testing.T) {
|
||||
msg: &distrtypes.MsgCommunityPoolSpend{
|
||||
Authority: f.distrKeeper.GetAuthority(),
|
||||
Recipient: recipient.String(),
|
||||
Amount: sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(100))),
|
||||
Amount: sdk.NewCoins(sdk.NewCoin("stake", math.NewInt(100))),
|
||||
},
|
||||
expErr: false,
|
||||
},
|
||||
@@ -889,8 +889,8 @@ func TestMsgDepositValidatorRewardsPool(t *testing.T) {
|
||||
err = f.bankKeeper.SendCoinsFromModuleToAccount(f.sdkCtx, distrtypes.ModuleName, addr, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, tokens)))
|
||||
require.NoError(t, err)
|
||||
tstaking := stakingtestutil.NewHelper(t, f.sdkCtx, f.stakingKeeper)
|
||||
tstaking.Commission = stakingtypes.NewCommissionRates(sdk.NewDecWithPrec(5, 1), sdk.NewDecWithPrec(5, 1), math.LegacyNewDec(0))
|
||||
tstaking.CreateValidator(valAddr1, valConsPk0, sdk.NewInt(100), true)
|
||||
tstaking.Commission = stakingtypes.NewCommissionRates(math.LegacyNewDecWithPrec(5, 1), math.LegacyNewDecWithPrec(5, 1), math.LegacyNewDec(0))
|
||||
tstaking.CreateValidator(valAddr1, valConsPk0, math.NewInt(100), true)
|
||||
|
||||
// mint a non-staking token and send to an account
|
||||
amt := sdk.NewCoins(sdk.NewInt64Coin("foo", 500))
|
||||
@@ -911,7 +911,7 @@ func TestMsgDepositValidatorRewardsPool(t *testing.T) {
|
||||
msg: &distrtypes.MsgDepositValidatorRewardsPool{
|
||||
Depositor: addr.String(),
|
||||
ValidatorAddress: valAddr1.String(),
|
||||
Amount: sdk.NewCoins(sdk.NewCoin(bondDenom, sdk.NewInt(100))),
|
||||
Amount: sdk.NewCoins(sdk.NewCoin(bondDenom, math.NewInt(100))),
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -927,7 +927,7 @@ func TestMsgDepositValidatorRewardsPool(t *testing.T) {
|
||||
msg: &distrtypes.MsgDepositValidatorRewardsPool{
|
||||
Depositor: addr.String(),
|
||||
ValidatorAddress: sdk.ValAddress([]byte("addr1_______________")).String(),
|
||||
Amount: sdk.NewCoins(sdk.NewCoin(bondDenom, sdk.NewInt(100))),
|
||||
Amount: sdk.NewCoins(sdk.NewCoin(bondDenom, math.NewInt(100))),
|
||||
},
|
||||
expErr: true,
|
||||
expErrMsg: "validator does not exist",
|
||||
@@ -960,7 +960,7 @@ func TestMsgDepositValidatorRewardsPool(t *testing.T) {
|
||||
outstandingRewards, _ := f.distrKeeper.GetValidatorOutstandingRewards(f.sdkCtx, val)
|
||||
for _, c := range tc.msg.Amount {
|
||||
x := outstandingRewards.Rewards.AmountOf(c.Denom)
|
||||
assert.DeepEqual(t, x, sdk.NewDecFromInt(c.Amount))
|
||||
assert.DeepEqual(t, x, math.LegacyNewDecFromInt(c.Amount))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -5,6 +5,8 @@ import (
|
||||
|
||||
"gotest.tools/v3/assert"
|
||||
|
||||
"cosmossdk.io/math"
|
||||
|
||||
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||
@@ -34,7 +36,7 @@ func getTestProposal() []sdk.Msg {
|
||||
}
|
||||
|
||||
func createValidators(t *testing.T, f *fixture, powers []int64) ([]sdk.AccAddress, []sdk.ValAddress) {
|
||||
addrs := simtestutil.AddTestAddrsIncremental(f.bankKeeper, f.stakingKeeper, f.ctx, 5, sdk.NewInt(30000000))
|
||||
addrs := simtestutil.AddTestAddrsIncremental(f.bankKeeper, f.stakingKeeper, f.ctx, 5, math.NewInt(30000000))
|
||||
valAddrs := simtestutil.ConvertAddrsToValAddrs(addrs)
|
||||
pks := simtestutil.CreateTestPubKeys(5)
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@ import (
|
||||
|
||||
"cosmossdk.io/math"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
v1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
|
||||
"github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
|
||||
)
|
||||
@@ -90,7 +89,7 @@ func TestGRPCQueryTally(t *testing.T) {
|
||||
|
||||
expRes = &v1.QueryTallyResultResponse{
|
||||
Tally: &v1.TallyResult{
|
||||
YesCount: sdk.NewInt(3 * 5 * 1000000).String(),
|
||||
YesCount: math.NewInt(3 * 5 * 1000000).String(),
|
||||
NoCount: "0",
|
||||
AbstainCount: "0",
|
||||
NoWithVetoCount: "0",
|
||||
@@ -212,10 +211,10 @@ func TestLegacyGRPCQueryTally(t *testing.T) {
|
||||
|
||||
expRes = &v1beta1.QueryTallyResultResponse{
|
||||
Tally: v1beta1.TallyResult{
|
||||
Yes: sdk.NewInt(3 * 5 * 1000000),
|
||||
No: sdk.NewInt(0),
|
||||
Abstain: sdk.NewInt(0),
|
||||
NoWithVeto: sdk.NewInt(0),
|
||||
Yes: math.NewInt(3 * 5 * 1000000),
|
||||
No: math.NewInt(0),
|
||||
Abstain: math.NewInt(0),
|
||||
NoWithVeto: math.NewInt(0),
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
@@ -5,6 +5,8 @@ import (
|
||||
|
||||
"gotest.tools/v3/assert"
|
||||
|
||||
"cosmossdk.io/math"
|
||||
|
||||
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
v1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
|
||||
@@ -44,7 +46,7 @@ func TestTallyNoQuorum(t *testing.T) {
|
||||
|
||||
createValidators(t, f, []int64{2, 5, 0})
|
||||
|
||||
addrs := simtestutil.AddTestAddrsIncremental(f.bankKeeper, f.stakingKeeper, ctx, 1, sdk.NewInt(10000000))
|
||||
addrs := simtestutil.AddTestAddrsIncremental(f.bankKeeper, f.stakingKeeper, ctx, 1, math.NewInt(10000000))
|
||||
|
||||
tp := TestProposal
|
||||
proposal, err := f.govKeeper.SubmitProposal(ctx, tp, "", "test", "description", addrs[0], false)
|
||||
|
||||
@@ -58,7 +58,7 @@ func ValEq(t *testing.T, exp, got types.Validator) (*testing.T, bool, string, ty
|
||||
|
||||
// generateAddresses generates numAddrs of normal AccAddrs and ValAddrs
|
||||
func generateAddresses(f *fixture, numAddrs int) ([]sdk.AccAddress, []sdk.ValAddress) {
|
||||
addrDels := simtestutil.AddTestAddrsIncremental(f.bankKeeper, f.stakingKeeper, f.sdkCtx, numAddrs, sdk.NewInt(10000))
|
||||
addrDels := simtestutil.AddTestAddrsIncremental(f.bankKeeper, f.stakingKeeper, f.sdkCtx, numAddrs, math.NewInt(10000))
|
||||
addrVals := simtestutil.ConvertAddrsToValAddrs(addrDels)
|
||||
|
||||
return addrDels, addrVals
|
||||
|
||||
@@ -25,7 +25,7 @@ func TestUnbondingDelegationsMaxEntries(t *testing.T) {
|
||||
assert.NilError(t, f.bankKeeper.MintCoins(ctx, types.ModuleName, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, initTokens))))
|
||||
|
||||
addrDel := sdk.AccAddress([]byte("addr"))
|
||||
accAmt := sdk.NewInt(10000)
|
||||
accAmt := math.NewInt(10000)
|
||||
bondDenom, err := f.stakingKeeper.BondDenom(ctx)
|
||||
assert.NilError(t, err)
|
||||
|
||||
|
||||
@@ -194,8 +194,8 @@ func createValidator(rt *rapid.T, f *deterministicFixture, t *testing.T) staking
|
||||
ConsensusPubkey: pubkeyAny,
|
||||
Jailed: rapid.Bool().Draw(rt, "jailed"),
|
||||
Status: bondTypeGenerator().Draw(rt, "bond-status"),
|
||||
Tokens: sdk.NewInt(rapid.Int64Min(10000).Draw(rt, "tokens")),
|
||||
DelegatorShares: sdk.NewDecWithPrec(rapid.Int64Range(1, 100).Draw(rt, "commission"), 2),
|
||||
Tokens: math.NewInt(rapid.Int64Min(10000).Draw(rt, "tokens")),
|
||||
DelegatorShares: math.LegacyNewDecWithPrec(rapid.Int64Range(1, 100).Draw(rt, "commission"), 2),
|
||||
Description: stakingtypes.NewDescription(
|
||||
rapid.StringN(5, 250, 255).Draw(rt, "moniker"),
|
||||
rapid.StringN(5, 250, 255).Draw(rt, "identity"),
|
||||
@@ -206,11 +206,11 @@ func createValidator(rt *rapid.T, f *deterministicFixture, t *testing.T) staking
|
||||
UnbondingHeight: rapid.Int64Min(1).Draw(rt, "unbonding-height"),
|
||||
UnbondingTime: time.Now().Add(durationGenerator().Draw(rt, "duration")),
|
||||
Commission: stakingtypes.NewCommission(
|
||||
sdk.NewDecWithPrec(rapid.Int64Range(0, 100).Draw(rt, "rate"), 2),
|
||||
sdk.NewDecWithPrec(rapid.Int64Range(0, 100).Draw(rt, "max-rate"), 2),
|
||||
sdk.NewDecWithPrec(rapid.Int64Range(0, 100).Draw(rt, "max-change-rate"), 2),
|
||||
math.LegacyNewDecWithPrec(rapid.Int64Range(0, 100).Draw(rt, "rate"), 2),
|
||||
math.LegacyNewDecWithPrec(rapid.Int64Range(0, 100).Draw(rt, "max-rate"), 2),
|
||||
math.LegacyNewDecWithPrec(rapid.Int64Range(0, 100).Draw(rt, "max-change-rate"), 2),
|
||||
),
|
||||
MinSelfDelegation: sdk.NewInt(rapid.Int64Min(1).Draw(rt, "tokens")),
|
||||
MinSelfDelegation: math.NewInt(rapid.Int64Min(1).Draw(rt, "tokens")),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -254,8 +254,8 @@ func getStaticValidator(f *deterministicFixture, t *testing.T) stakingtypes.Vali
|
||||
ConsensusPubkey: pubkeyAny,
|
||||
Jailed: false,
|
||||
Status: stakingtypes.Bonded,
|
||||
Tokens: sdk.NewInt(100),
|
||||
DelegatorShares: sdk.NewDecWithPrec(5, 2),
|
||||
Tokens: math.NewInt(100),
|
||||
DelegatorShares: math.LegacyNewDecWithPrec(5, 2),
|
||||
Description: stakingtypes.NewDescription(
|
||||
"moniker",
|
||||
"identity",
|
||||
@@ -266,11 +266,11 @@ func getStaticValidator(f *deterministicFixture, t *testing.T) stakingtypes.Vali
|
||||
UnbondingHeight: 10,
|
||||
UnbondingTime: time.Date(2022, 10, 1, 0, 0, 0, 0, time.UTC),
|
||||
Commission: stakingtypes.NewCommission(
|
||||
sdk.NewDecWithPrec(5, 2),
|
||||
sdk.NewDecWithPrec(5, 2),
|
||||
sdk.NewDecWithPrec(5, 2),
|
||||
math.LegacyNewDecWithPrec(5, 2),
|
||||
math.LegacyNewDecWithPrec(5, 2),
|
||||
math.LegacyNewDecWithPrec(5, 2),
|
||||
),
|
||||
MinSelfDelegation: sdk.NewInt(10),
|
||||
MinSelfDelegation: math.NewInt(10),
|
||||
}
|
||||
|
||||
setValidator(f, t, validator)
|
||||
@@ -288,8 +288,8 @@ func getStaticValidator2(f *deterministicFixture, t *testing.T) stakingtypes.Val
|
||||
ConsensusPubkey: pubkeyAny,
|
||||
Jailed: true,
|
||||
Status: stakingtypes.Bonded,
|
||||
Tokens: sdk.NewInt(10012),
|
||||
DelegatorShares: sdk.NewDecWithPrec(96, 2),
|
||||
Tokens: math.NewInt(10012),
|
||||
DelegatorShares: math.LegacyNewDecWithPrec(96, 2),
|
||||
Description: stakingtypes.NewDescription(
|
||||
"moniker",
|
||||
"identity",
|
||||
@@ -300,11 +300,11 @@ func getStaticValidator2(f *deterministicFixture, t *testing.T) stakingtypes.Val
|
||||
UnbondingHeight: 100132,
|
||||
UnbondingTime: time.Date(2025, 10, 1, 0, 0, 0, 0, time.UTC),
|
||||
Commission: stakingtypes.NewCommission(
|
||||
sdk.NewDecWithPrec(15, 2),
|
||||
sdk.NewDecWithPrec(59, 2),
|
||||
sdk.NewDecWithPrec(51, 2),
|
||||
math.LegacyNewDecWithPrec(15, 2),
|
||||
math.LegacyNewDecWithPrec(59, 2),
|
||||
math.LegacyNewDecWithPrec(51, 2),
|
||||
),
|
||||
MinSelfDelegation: sdk.NewInt(1),
|
||||
MinSelfDelegation: math.NewInt(1),
|
||||
}
|
||||
setValidator(f, t, validator)
|
||||
|
||||
@@ -822,7 +822,7 @@ func TestGRPCParams(t *testing.T) {
|
||||
MaxValidators: rapid.Uint32Min(1).Draw(rt, "max-validators"),
|
||||
MaxEntries: rapid.Uint32Min(1).Draw(rt, "max-entries"),
|
||||
HistoricalEntries: rapid.Uint32Min(1).Draw(rt, "historical-entries"),
|
||||
MinCommissionRate: sdk.NewDecWithPrec(rapid.Int64Range(0, 100).Draw(rt, "commission"), 2),
|
||||
MinCommissionRate: math.LegacyNewDecWithPrec(rapid.Int64Range(0, 100).Draw(rt, "commission"), 2),
|
||||
}
|
||||
|
||||
err := f.stakingKeeper.SetParams(f.ctx, params)
|
||||
@@ -837,7 +837,7 @@ func TestGRPCParams(t *testing.T) {
|
||||
MaxValidators: 85,
|
||||
MaxEntries: 5,
|
||||
HistoricalEntries: 5,
|
||||
MinCommissionRate: sdk.NewDecWithPrec(5, 2),
|
||||
MinCommissionRate: math.LegacyNewDecWithPrec(5, 2),
|
||||
}
|
||||
|
||||
err := f.stakingKeeper.SetParams(f.ctx, params)
|
||||
|
||||
@@ -38,7 +38,7 @@ func TestInitGenesis(t *testing.T) {
|
||||
ConsensusPubkey: pk0,
|
||||
Status: types.Bonded,
|
||||
Tokens: valTokens,
|
||||
DelegatorShares: sdk.NewDecFromInt(valTokens),
|
||||
DelegatorShares: math.LegacyNewDecFromInt(valTokens),
|
||||
Description: types.NewDescription("hoop", "", "", "", ""),
|
||||
}
|
||||
assert.NilError(t, f.stakingKeeper.SetValidator(f.sdkCtx, bondedVal))
|
||||
@@ -64,7 +64,7 @@ func TestInitGenesis(t *testing.T) {
|
||||
ConsensusPubkey: pk1,
|
||||
Status: types.Bonded,
|
||||
Tokens: valTokens,
|
||||
DelegatorShares: sdk.NewDecFromInt(valTokens),
|
||||
DelegatorShares: math.LegacyNewDecFromInt(valTokens),
|
||||
Description: types.NewDescription("hoop", "", "", "", ""),
|
||||
}
|
||||
bondedVal2 := types.Validator{
|
||||
@@ -72,7 +72,7 @@ func TestInitGenesis(t *testing.T) {
|
||||
ConsensusPubkey: pk2,
|
||||
Status: types.Bonded,
|
||||
Tokens: valTokens,
|
||||
DelegatorShares: sdk.NewDecFromInt(valTokens),
|
||||
DelegatorShares: math.LegacyNewDecFromInt(valTokens),
|
||||
Description: types.NewDescription("bloop", "", "", "", ""),
|
||||
}
|
||||
|
||||
@@ -144,8 +144,8 @@ func TestInitGenesis_PoolsBalanceMismatch(t *testing.T) {
|
||||
OperatorAddress: sdk.ValAddress("12345678901234567890").String(),
|
||||
ConsensusPubkey: consPub,
|
||||
Jailed: false,
|
||||
Tokens: sdk.NewInt(10),
|
||||
DelegatorShares: sdk.NewDecFromInt(sdk.NewInt(10)),
|
||||
Tokens: math.NewInt(10),
|
||||
DelegatorShares: math.LegacyNewDecFromInt(math.NewInt(10)),
|
||||
Description: types.NewDescription("bloop", "", "", "", ""),
|
||||
}
|
||||
|
||||
@@ -208,7 +208,7 @@ func TestInitGenesisLargeValidatorSet(t *testing.T) {
|
||||
}
|
||||
|
||||
validators[i].Tokens = tokens
|
||||
validators[i].DelegatorShares = sdk.NewDecFromInt(tokens)
|
||||
validators[i].DelegatorShares = math.LegacyNewDecFromInt(tokens)
|
||||
|
||||
// add bonded coins
|
||||
bondedPoolAmt = bondedPoolAmt.Add(tokens)
|
||||
|
||||
@@ -8,6 +8,8 @@ import (
|
||||
cmtproto "github.com/cometbft/cometbft/proto/tendermint/types"
|
||||
"gotest.tools/v3/assert"
|
||||
|
||||
"cosmossdk.io/math"
|
||||
|
||||
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/query"
|
||||
@@ -517,7 +519,7 @@ func TestGRPCQueryUnbondingDelegation(t *testing.T) {
|
||||
unbondingTokens := f.stakingKeeper.TokensFromConsensusPower(ctx, 2)
|
||||
valAddr, err1 := sdk.ValAddressFromBech32(addrVal2)
|
||||
assert.NilError(t, err1)
|
||||
_, _, err := f.stakingKeeper.Undelegate(ctx, addrAcc2, valAddr, sdk.NewDecFromInt(unbondingTokens))
|
||||
_, _, err := f.stakingKeeper.Undelegate(ctx, addrAcc2, valAddr, math.LegacyNewDecFromInt(unbondingTokens))
|
||||
assert.NilError(t, err)
|
||||
|
||||
unbond, found := f.stakingKeeper.GetUnbondingDelegation(ctx, addrAcc2, valAddr)
|
||||
@@ -620,11 +622,11 @@ func TestGRPCQueryDelegatorUnbondingDelegations(t *testing.T) {
|
||||
unbondingTokens := f.stakingKeeper.TokensFromConsensusPower(ctx, 2)
|
||||
valAddr1, err1 := sdk.ValAddressFromBech32(addrVal)
|
||||
assert.NilError(t, err1)
|
||||
_, _, err := f.stakingKeeper.Undelegate(ctx, addrAcc, valAddr1, sdk.NewDecFromInt(unbondingTokens))
|
||||
_, _, err := f.stakingKeeper.Undelegate(ctx, addrAcc, valAddr1, math.LegacyNewDecFromInt(unbondingTokens))
|
||||
assert.NilError(t, err)
|
||||
valAddr2, err1 := sdk.ValAddressFromBech32(addrVal2)
|
||||
assert.NilError(t, err1)
|
||||
_, _, err = f.stakingKeeper.Undelegate(ctx, addrAcc, valAddr2, sdk.NewDecFromInt(unbondingTokens))
|
||||
_, _, err = f.stakingKeeper.Undelegate(ctx, addrAcc, valAddr2, math.LegacyNewDecFromInt(unbondingTokens))
|
||||
assert.NilError(t, err)
|
||||
|
||||
unbond, found := f.stakingKeeper.GetUnbondingDelegation(ctx, addrAcc, valAddr1)
|
||||
@@ -807,7 +809,7 @@ func TestGRPCQueryRedelegations(t *testing.T) {
|
||||
applyValidatorSetUpdates(t, ctx, f.stakingKeeper, -1)
|
||||
|
||||
rdAmount := f.stakingKeeper.TokensFromConsensusPower(ctx, 1)
|
||||
_, err = f.stakingKeeper.BeginRedelegation(ctx, addrAcc1, val1.GetOperator(), val2.GetOperator(), sdk.NewDecFromInt(rdAmount))
|
||||
_, err = f.stakingKeeper.BeginRedelegation(ctx, addrAcc1, val1.GetOperator(), val2.GetOperator(), math.LegacyNewDecFromInt(rdAmount))
|
||||
assert.NilError(t, err)
|
||||
applyValidatorSetUpdates(t, ctx, f.stakingKeeper, -1)
|
||||
|
||||
@@ -920,7 +922,7 @@ func TestGRPCQueryValidatorUnbondingDelegations(t *testing.T) {
|
||||
|
||||
// undelegate
|
||||
undelAmount := f.stakingKeeper.TokensFromConsensusPower(ctx, 2)
|
||||
_, _, err := f.stakingKeeper.Undelegate(ctx, addrAcc1, val1.GetOperator(), sdk.NewDecFromInt(undelAmount))
|
||||
_, _, err := f.stakingKeeper.Undelegate(ctx, addrAcc1, val1.GetOperator(), math.LegacyNewDecFromInt(undelAmount))
|
||||
assert.NilError(t, err)
|
||||
applyValidatorSetUpdates(t, ctx, f.stakingKeeper, -1)
|
||||
|
||||
|
||||
@@ -6,6 +6,8 @@ import (
|
||||
|
||||
"gotest.tools/v3/assert"
|
||||
|
||||
"cosmossdk.io/math"
|
||||
|
||||
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/bank/testutil"
|
||||
@@ -33,7 +35,7 @@ func TestCancelUnbondingDelegation(t *testing.T) {
|
||||
assert.DeepEqual(t, sdk.NewInt64Coin(bondDenom, startTokens.Int64()), moduleBalance)
|
||||
|
||||
// accounts
|
||||
addrs := simtestutil.AddTestAddrsIncremental(f.bankKeeper, f.stakingKeeper, ctx, 2, sdk.NewInt(10000))
|
||||
addrs := simtestutil.AddTestAddrsIncremental(f.bankKeeper, f.stakingKeeper, ctx, 2, math.NewInt(10000))
|
||||
valAddr := sdk.ValAddress(addrs[0])
|
||||
delegatorAddr := addrs[1]
|
||||
|
||||
@@ -73,7 +75,7 @@ func TestCancelUnbondingDelegation(t *testing.T) {
|
||||
req: types.MsgCancelUnbondingDelegation{
|
||||
DelegatorAddress: resUnbond.DelegatorAddress,
|
||||
ValidatorAddress: resUnbond.ValidatorAddress,
|
||||
Amount: sdk.NewCoin(bondDenom, sdk.NewInt(4)),
|
||||
Amount: sdk.NewCoin(bondDenom, math.NewInt(4)),
|
||||
CreationHeight: 11,
|
||||
},
|
||||
expErrMsg: "unbonding delegation entry is not found at block height",
|
||||
@@ -84,7 +86,7 @@ func TestCancelUnbondingDelegation(t *testing.T) {
|
||||
req: types.MsgCancelUnbondingDelegation{
|
||||
DelegatorAddress: resUnbond.DelegatorAddress,
|
||||
ValidatorAddress: resUnbond.ValidatorAddress,
|
||||
Amount: sdk.NewCoin(bondDenom, sdk.NewInt(4)),
|
||||
Amount: sdk.NewCoin(bondDenom, math.NewInt(4)),
|
||||
CreationHeight: 0,
|
||||
},
|
||||
expErrMsg: "invalid height",
|
||||
@@ -95,7 +97,7 @@ func TestCancelUnbondingDelegation(t *testing.T) {
|
||||
req: types.MsgCancelUnbondingDelegation{
|
||||
DelegatorAddress: resUnbond.DelegatorAddress,
|
||||
ValidatorAddress: resUnbond.ValidatorAddress,
|
||||
Amount: sdk.NewCoin("dump_coin", sdk.NewInt(4)),
|
||||
Amount: sdk.NewCoin("dump_coin", math.NewInt(4)),
|
||||
CreationHeight: 10,
|
||||
},
|
||||
expErrMsg: "invalid coin denomination",
|
||||
|
||||
@@ -56,26 +56,26 @@ func bootstrapSlashTest(t *testing.T, power int64) (*fixture, []sdk.AccAddress,
|
||||
func TestSlashUnbondingDelegation(t *testing.T) {
|
||||
f, addrDels, addrVals := bootstrapSlashTest(t, 10)
|
||||
|
||||
fraction := sdk.NewDecWithPrec(5, 1)
|
||||
fraction := math.LegacyNewDecWithPrec(5, 1)
|
||||
|
||||
// set an unbonding delegation with expiration timestamp (beyond which the
|
||||
// unbonding delegation shouldn't be slashed)
|
||||
ubd := types.NewUnbondingDelegation(addrDels[0], addrVals[0], 0,
|
||||
time.Unix(5, 0), sdk.NewInt(10), 0)
|
||||
time.Unix(5, 0), math.NewInt(10), 0)
|
||||
|
||||
assert.NilError(t, f.stakingKeeper.SetUnbondingDelegation(f.sdkCtx, ubd))
|
||||
|
||||
// unbonding started prior to the infraction height, stakw didn't contribute
|
||||
slashAmount, err := f.stakingKeeper.SlashUnbondingDelegation(f.sdkCtx, ubd, 1, fraction)
|
||||
assert.NilError(t, err)
|
||||
assert.Assert(t, slashAmount.Equal(sdk.NewInt(0)))
|
||||
assert.Assert(t, slashAmount.Equal(math.NewInt(0)))
|
||||
|
||||
// after the expiration time, no longer eligible for slashing
|
||||
f.sdkCtx = f.sdkCtx.WithBlockHeader(cmtproto.Header{Time: time.Unix(10, 0)})
|
||||
assert.NilError(t, f.stakingKeeper.SetUnbondingDelegation(f.sdkCtx, ubd))
|
||||
slashAmount, err = f.stakingKeeper.SlashUnbondingDelegation(f.sdkCtx, ubd, 0, fraction)
|
||||
assert.NilError(t, err)
|
||||
assert.Assert(t, slashAmount.Equal(sdk.NewInt(0)))
|
||||
assert.Assert(t, slashAmount.Equal(math.NewInt(0)))
|
||||
|
||||
// test valid slash, before expiration timestamp and to which stake contributed
|
||||
notBondedPool := f.stakingKeeper.GetNotBondedPool(f.sdkCtx)
|
||||
@@ -84,27 +84,27 @@ func TestSlashUnbondingDelegation(t *testing.T) {
|
||||
assert.NilError(t, f.stakingKeeper.SetUnbondingDelegation(f.sdkCtx, ubd))
|
||||
slashAmount, err = f.stakingKeeper.SlashUnbondingDelegation(f.sdkCtx, ubd, 0, fraction)
|
||||
assert.NilError(t, err)
|
||||
assert.Assert(t, slashAmount.Equal(sdk.NewInt(5)))
|
||||
assert.Assert(t, slashAmount.Equal(math.NewInt(5)))
|
||||
ubd, found := f.stakingKeeper.GetUnbondingDelegation(f.sdkCtx, addrDels[0], addrVals[0])
|
||||
assert.Assert(t, found)
|
||||
assert.Assert(t, len(ubd.Entries) == 1)
|
||||
|
||||
// initial balance unchanged
|
||||
assert.DeepEqual(t, sdk.NewInt(10), ubd.Entries[0].InitialBalance)
|
||||
assert.DeepEqual(t, math.NewInt(10), ubd.Entries[0].InitialBalance)
|
||||
|
||||
// balance decreased
|
||||
assert.DeepEqual(t, sdk.NewInt(5), ubd.Entries[0].Balance)
|
||||
assert.DeepEqual(t, math.NewInt(5), ubd.Entries[0].Balance)
|
||||
newUnbondedPoolBalances := f.bankKeeper.GetAllBalances(f.sdkCtx, notBondedPool.GetAddress())
|
||||
diffTokens := oldUnbondedPoolBalances.Sub(newUnbondedPoolBalances...)
|
||||
bondDenom, err := f.stakingKeeper.BondDenom(f.sdkCtx)
|
||||
assert.NilError(t, err)
|
||||
assert.Assert(t, diffTokens.AmountOf(bondDenom).Equal(sdk.NewInt(5)))
|
||||
assert.Assert(t, diffTokens.AmountOf(bondDenom).Equal(math.NewInt(5)))
|
||||
}
|
||||
|
||||
// tests slashRedelegation
|
||||
func TestSlashRedelegation(t *testing.T) {
|
||||
f, addrDels, addrVals := bootstrapSlashTest(t, 10)
|
||||
fraction := sdk.NewDecWithPrec(5, 1)
|
||||
fraction := math.LegacyNewDecWithPrec(5, 1)
|
||||
|
||||
bondDenom, err := f.stakingKeeper.BondDenom(f.sdkCtx)
|
||||
assert.NilError(t, err)
|
||||
@@ -120,7 +120,7 @@ func TestSlashRedelegation(t *testing.T) {
|
||||
// set a redelegation with an expiration timestamp beyond which the
|
||||
// redelegation shouldn't be slashed
|
||||
rd := types.NewRedelegation(addrDels[0], addrVals[0], addrVals[1], 0,
|
||||
time.Unix(5, 0), sdk.NewInt(10), math.LegacyNewDec(10), 0)
|
||||
time.Unix(5, 0), math.NewInt(10), math.LegacyNewDec(10), 0)
|
||||
|
||||
assert.NilError(t, f.stakingKeeper.SetRedelegation(f.sdkCtx, rd))
|
||||
|
||||
@@ -133,7 +133,7 @@ func TestSlashRedelegation(t *testing.T) {
|
||||
assert.Assert(t, found)
|
||||
slashAmount, err := f.stakingKeeper.SlashRedelegation(f.sdkCtx, validator, rd, 1, fraction)
|
||||
assert.NilError(t, err)
|
||||
assert.Assert(t, slashAmount.Equal(sdk.NewInt(0)))
|
||||
assert.Assert(t, slashAmount.Equal(math.NewInt(0)))
|
||||
|
||||
// after the expiration time, no longer eligible for slashing
|
||||
f.sdkCtx = f.sdkCtx.WithBlockHeader(cmtproto.Header{Time: time.Unix(10, 0)})
|
||||
@@ -142,7 +142,7 @@ func TestSlashRedelegation(t *testing.T) {
|
||||
assert.Assert(t, found)
|
||||
slashAmount, err = f.stakingKeeper.SlashRedelegation(f.sdkCtx, validator, rd, 0, fraction)
|
||||
assert.NilError(t, err)
|
||||
assert.Assert(t, slashAmount.Equal(sdk.NewInt(0)))
|
||||
assert.Assert(t, slashAmount.Equal(math.NewInt(0)))
|
||||
|
||||
balances := f.bankKeeper.GetAllBalances(f.sdkCtx, bondedPool.GetAddress())
|
||||
|
||||
@@ -153,7 +153,7 @@ func TestSlashRedelegation(t *testing.T) {
|
||||
assert.Assert(t, found)
|
||||
slashAmount, err = f.stakingKeeper.SlashRedelegation(f.sdkCtx, validator, rd, 0, fraction)
|
||||
assert.NilError(t, err)
|
||||
assert.Assert(t, slashAmount.Equal(sdk.NewInt(5)))
|
||||
assert.Assert(t, slashAmount.Equal(math.NewInt(5)))
|
||||
rd, found = f.stakingKeeper.GetRedelegation(f.sdkCtx, addrDels[0], addrVals[0], addrVals[1])
|
||||
assert.Assert(t, found)
|
||||
assert.Assert(t, len(rd.Entries) == 1)
|
||||
@@ -162,7 +162,7 @@ func TestSlashRedelegation(t *testing.T) {
|
||||
applyValidatorSetUpdates(t, f.sdkCtx, f.stakingKeeper, 1)
|
||||
|
||||
// initialbalance unchanged
|
||||
assert.DeepEqual(t, sdk.NewInt(10), rd.Entries[0].InitialBalance)
|
||||
assert.DeepEqual(t, math.NewInt(10), rd.Entries[0].InitialBalance)
|
||||
|
||||
// shares decreased
|
||||
del, found = f.stakingKeeper.GetDelegation(f.sdkCtx, addrDels[0], addrVals[1])
|
||||
@@ -179,7 +179,7 @@ func TestSlashRedelegation(t *testing.T) {
|
||||
func TestSlashAtNegativeHeight(t *testing.T) {
|
||||
f, _, _ := bootstrapSlashTest(t, 10)
|
||||
consAddr := sdk.ConsAddress(PKs[0].Address())
|
||||
fraction := sdk.NewDecWithPrec(5, 1)
|
||||
fraction := math.LegacyNewDecWithPrec(5, 1)
|
||||
|
||||
bondedPool := f.stakingKeeper.GetBondedPool(f.sdkCtx)
|
||||
oldBondedPoolBalances := f.bankKeeper.GetAllBalances(f.sdkCtx, bondedPool.GetAddress())
|
||||
@@ -214,7 +214,7 @@ func TestSlashAtNegativeHeight(t *testing.T) {
|
||||
func TestSlashValidatorAtCurrentHeight(t *testing.T) {
|
||||
f, _, _ := bootstrapSlashTest(t, 10)
|
||||
consAddr := sdk.ConsAddress(PKs[0].Address())
|
||||
fraction := sdk.NewDecWithPrec(5, 1)
|
||||
fraction := math.LegacyNewDecWithPrec(5, 1)
|
||||
|
||||
bondDenom, err := f.stakingKeeper.BondDenom(f.sdkCtx)
|
||||
assert.NilError(t, err)
|
||||
@@ -250,7 +250,7 @@ func TestSlashWithUnbondingDelegation(t *testing.T) {
|
||||
f, addrDels, addrVals := bootstrapSlashTest(t, 10)
|
||||
|
||||
consAddr := sdk.ConsAddress(PKs[0].Address())
|
||||
fraction := sdk.NewDecWithPrec(5, 1)
|
||||
fraction := math.LegacyNewDecWithPrec(5, 1)
|
||||
|
||||
bondDenom, err := f.stakingKeeper.BondDenom(f.sdkCtx)
|
||||
assert.NilError(t, err)
|
||||
@@ -307,7 +307,7 @@ func TestSlashWithUnbondingDelegation(t *testing.T) {
|
||||
assert.Assert(t, len(ubd.Entries) == 1)
|
||||
|
||||
// balance decreased again
|
||||
assert.DeepEqual(t, sdk.NewInt(0), ubd.Entries[0].Balance)
|
||||
assert.DeepEqual(t, math.NewInt(0), ubd.Entries[0].Balance)
|
||||
|
||||
// bonded tokens burned again
|
||||
newBondedPoolBalances = f.bankKeeper.GetAllBalances(f.sdkCtx, bondedPool.GetAddress())
|
||||
@@ -334,7 +334,7 @@ func TestSlashWithUnbondingDelegation(t *testing.T) {
|
||||
assert.Assert(t, len(ubd.Entries) == 1)
|
||||
|
||||
// balance unchanged
|
||||
assert.DeepEqual(t, sdk.NewInt(0), ubd.Entries[0].Balance)
|
||||
assert.DeepEqual(t, math.NewInt(0), ubd.Entries[0].Balance)
|
||||
|
||||
// bonded tokens burned again
|
||||
newBondedPoolBalances = f.bankKeeper.GetAllBalances(f.sdkCtx, bondedPool.GetAddress())
|
||||
@@ -361,7 +361,7 @@ func TestSlashWithUnbondingDelegation(t *testing.T) {
|
||||
assert.Assert(t, len(ubd.Entries) == 1)
|
||||
|
||||
// balance unchanged
|
||||
assert.DeepEqual(t, sdk.NewInt(0), ubd.Entries[0].Balance)
|
||||
assert.DeepEqual(t, math.NewInt(0), ubd.Entries[0].Balance)
|
||||
|
||||
// just 1 bonded token burned again since that's all the validator now has
|
||||
newBondedPoolBalances = f.bankKeeper.GetAllBalances(f.sdkCtx, bondedPool.GetAddress())
|
||||
@@ -382,17 +382,17 @@ func TestSlashWithUnbondingDelegation(t *testing.T) {
|
||||
func TestSlashWithRedelegation(t *testing.T) {
|
||||
f, addrDels, addrVals := bootstrapSlashTest(t, 10)
|
||||
consAddr := sdk.ConsAddress(PKs[0].Address())
|
||||
fraction := sdk.NewDecWithPrec(5, 1)
|
||||
fraction := math.LegacyNewDecWithPrec(5, 1)
|
||||
bondDenom, err := f.stakingKeeper.BondDenom(f.sdkCtx)
|
||||
assert.NilError(t, err)
|
||||
|
||||
// set a redelegation
|
||||
rdTokens := f.stakingKeeper.TokensFromConsensusPower(f.sdkCtx, 6)
|
||||
rd := types.NewRedelegation(addrDels[0], addrVals[0], addrVals[1], 11, time.Unix(0, 0), rdTokens, sdk.NewDecFromInt(rdTokens), 0)
|
||||
rd := types.NewRedelegation(addrDels[0], addrVals[0], addrVals[1], 11, time.Unix(0, 0), rdTokens, math.LegacyNewDecFromInt(rdTokens), 0)
|
||||
assert.NilError(t, f.stakingKeeper.SetRedelegation(f.sdkCtx, rd))
|
||||
|
||||
// set the associated delegation
|
||||
del := types.NewDelegation(addrDels[0], addrVals[1], sdk.NewDecFromInt(rdTokens))
|
||||
del := types.NewDelegation(addrDels[0], addrVals[1], math.LegacyNewDecFromInt(rdTokens))
|
||||
assert.NilError(t, f.stakingKeeper.SetDelegation(f.sdkCtx, del))
|
||||
|
||||
// update bonded tokens
|
||||
@@ -415,7 +415,7 @@ func TestSlashWithRedelegation(t *testing.T) {
|
||||
_, err = f.stakingKeeper.Slash(f.sdkCtx, consAddr, 10, 10, fraction)
|
||||
assert.NilError(t, err)
|
||||
|
||||
burnAmount := sdk.NewDecFromInt(f.stakingKeeper.TokensFromConsensusPower(f.sdkCtx, 10)).Mul(fraction).TruncateInt()
|
||||
burnAmount := math.LegacyNewDecFromInt(f.stakingKeeper.TokensFromConsensusPower(f.sdkCtx, 10)).Mul(fraction).TruncateInt()
|
||||
|
||||
bondedPool = f.stakingKeeper.GetBondedPool(f.sdkCtx)
|
||||
notBondedPool = f.stakingKeeper.GetNotBondedPool(f.sdkCtx)
|
||||
@@ -483,7 +483,7 @@ func TestSlashWithRedelegation(t *testing.T) {
|
||||
_, err = f.stakingKeeper.Slash(f.sdkCtx, consAddr, 10, 10, math.LegacyOneDec())
|
||||
assert.NilError(t, err)
|
||||
|
||||
burnAmount = sdk.NewDecFromInt(f.stakingKeeper.TokensFromConsensusPower(f.sdkCtx, 10)).Mul(math.LegacyOneDec()).TruncateInt()
|
||||
burnAmount = math.LegacyNewDecFromInt(f.stakingKeeper.TokensFromConsensusPower(f.sdkCtx, 10)).Mul(math.LegacyOneDec()).TruncateInt()
|
||||
burnAmount = burnAmount.Sub(math.LegacyOneDec().MulInt(rdTokens).TruncateInt())
|
||||
|
||||
// read updated pool
|
||||
@@ -539,18 +539,18 @@ func TestSlashWithRedelegation(t *testing.T) {
|
||||
// tests Slash at a previous height with both an unbonding delegation and a redelegation
|
||||
func TestSlashBoth(t *testing.T) {
|
||||
f, addrDels, addrVals := bootstrapSlashTest(t, 10)
|
||||
fraction := sdk.NewDecWithPrec(5, 1)
|
||||
fraction := math.LegacyNewDecWithPrec(5, 1)
|
||||
bondDenom, err := f.stakingKeeper.BondDenom(f.sdkCtx)
|
||||
assert.NilError(t, err)
|
||||
|
||||
// set a redelegation with expiration timestamp beyond which the
|
||||
// redelegation shouldn't be slashed
|
||||
rdATokens := f.stakingKeeper.TokensFromConsensusPower(f.sdkCtx, 6)
|
||||
rdA := types.NewRedelegation(addrDels[0], addrVals[0], addrVals[1], 11, time.Unix(0, 0), rdATokens, sdk.NewDecFromInt(rdATokens), 0)
|
||||
rdA := types.NewRedelegation(addrDels[0], addrVals[0], addrVals[1], 11, time.Unix(0, 0), rdATokens, math.LegacyNewDecFromInt(rdATokens), 0)
|
||||
assert.NilError(t, f.stakingKeeper.SetRedelegation(f.sdkCtx, rdA))
|
||||
|
||||
// set the associated delegation
|
||||
delA := types.NewDelegation(addrDels[0], addrVals[1], sdk.NewDecFromInt(rdATokens))
|
||||
delA := types.NewDelegation(addrDels[0], addrVals[1], math.LegacyNewDecFromInt(rdATokens))
|
||||
assert.NilError(t, f.stakingKeeper.SetDelegation(f.sdkCtx, delA))
|
||||
|
||||
// set an unbonding delegation with expiration timestamp (beyond which the
|
||||
@@ -584,7 +584,7 @@ func TestSlashBoth(t *testing.T) {
|
||||
assert.NilError(t, err)
|
||||
|
||||
burnedNotBondedAmount := fraction.MulInt(ubdATokens).TruncateInt()
|
||||
burnedBondAmount := sdk.NewDecFromInt(f.stakingKeeper.TokensFromConsensusPower(f.sdkCtx, 10)).Mul(fraction).TruncateInt()
|
||||
burnedBondAmount := math.LegacyNewDecFromInt(f.stakingKeeper.TokensFromConsensusPower(f.sdkCtx, 10)).Mul(fraction).TruncateInt()
|
||||
burnedBondAmount = burnedBondAmount.Sub(burnedNotBondedAmount)
|
||||
|
||||
// read updated pool
|
||||
@@ -611,7 +611,7 @@ func TestSlashBoth(t *testing.T) {
|
||||
func TestSlashAmount(t *testing.T) {
|
||||
f, _, _ := bootstrapSlashTest(t, 10)
|
||||
consAddr := sdk.ConsAddress(PKs[0].Address())
|
||||
fraction := sdk.NewDecWithPrec(5, 1)
|
||||
fraction := math.LegacyNewDecWithPrec(5, 1)
|
||||
burnedCoins, err := f.stakingKeeper.Slash(f.sdkCtx, consAddr, f.sdkCtx.BlockHeight(), 10, fraction)
|
||||
assert.NilError(t, err)
|
||||
assert.Assert(t, burnedCoins.GT(math.ZeroInt()))
|
||||
@@ -620,5 +620,5 @@ func TestSlashAmount(t *testing.T) {
|
||||
_, addrVals := generateAddresses(f, 100)
|
||||
noBurned, err := f.stakingKeeper.Slash(f.sdkCtx, sdk.ConsAddress(addrVals[0]), f.sdkCtx.BlockHeight(), 10, fraction)
|
||||
assert.NilError(t, err)
|
||||
assert.Assert(t, sdk.NewInt(0).Equal(noBurned))
|
||||
assert.Assert(t, math.NewInt(0).Equal(noBurned))
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ func BenchmarkGetValidatorDelegations(b *testing.B) {
|
||||
for i := 0; i < delegationsNum; i++ {
|
||||
delegator := sdk.AccAddress(fmt.Sprintf("address%d", i))
|
||||
banktestutil.FundAccount(f.sdkCtx, f.bankKeeper, delegator,
|
||||
sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(int64(i)))))
|
||||
sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(int64(i)))))
|
||||
NewDel := types.NewDelegation(delegator, val, math.LegacyNewDec(int64(i)))
|
||||
f.stakingKeeper.SetDelegation(f.sdkCtx, NewDel)
|
||||
}
|
||||
@@ -91,7 +91,7 @@ func BenchmarkGetValidatorDelegationsLegacy(b *testing.B) {
|
||||
for i := 0; i < delegationsNum; i++ {
|
||||
delegator := sdk.AccAddress(fmt.Sprintf("address%d", i))
|
||||
banktestutil.FundAccount(f.sdkCtx, f.bankKeeper, delegator,
|
||||
sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(int64(i)))))
|
||||
sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(int64(i)))))
|
||||
NewDel := types.NewDelegation(delegator, val, math.LegacyNewDec(int64(i)))
|
||||
f.stakingKeeper.SetDelegation(f.sdkCtx, NewDel)
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ func TestUpdateBondedValidatorsDecreaseCliff(t *testing.T) {
|
||||
// validator and next in line cliff validator
|
||||
f.stakingKeeper.DeleteValidatorByPowerIndex(f.sdkCtx, nextCliffVal)
|
||||
shares := f.stakingKeeper.TokensFromConsensusPower(f.sdkCtx, 21)
|
||||
nextCliffVal, _ = nextCliffVal.RemoveDelShares(sdk.NewDecFromInt(shares))
|
||||
nextCliffVal, _ = nextCliffVal.RemoveDelShares(math.LegacyNewDecFromInt(shares))
|
||||
_ = keeper.TestingUpdateValidator(f.stakingKeeper, f.sdkCtx, nextCliffVal, true)
|
||||
|
||||
expectedValStatus := map[int]types.BondStatus{
|
||||
@@ -172,7 +172,7 @@ func TestGetValidatorSortingUnmixed(t *testing.T) {
|
||||
validators[i] = testutil.NewValidator(t, sdk.ValAddress(addrs[i]), PKs[i])
|
||||
validators[i].Status = types.Bonded
|
||||
validators[i].Tokens = amt
|
||||
validators[i].DelegatorShares = sdk.NewDecFromInt(amt)
|
||||
validators[i].DelegatorShares = math.LegacyNewDecFromInt(amt)
|
||||
keeper.TestingUpdateValidator(f.stakingKeeper, f.sdkCtx, validators[i], true)
|
||||
}
|
||||
|
||||
@@ -180,11 +180,11 @@ func TestGetValidatorSortingUnmixed(t *testing.T) {
|
||||
resValidators, err := f.stakingKeeper.GetBondedValidatorsByPower(f.sdkCtx)
|
||||
assert.NilError(t, err)
|
||||
assert.Equal(t, n, len(resValidators))
|
||||
assert.DeepEqual(t, sdk.NewInt(400).Mul(f.stakingKeeper.PowerReduction(f.sdkCtx)), resValidators[0].BondedTokens())
|
||||
assert.DeepEqual(t, sdk.NewInt(200).Mul(f.stakingKeeper.PowerReduction(f.sdkCtx)), resValidators[1].BondedTokens())
|
||||
assert.DeepEqual(t, sdk.NewInt(100).Mul(f.stakingKeeper.PowerReduction(f.sdkCtx)), resValidators[2].BondedTokens())
|
||||
assert.DeepEqual(t, sdk.NewInt(1).Mul(f.stakingKeeper.PowerReduction(f.sdkCtx)), resValidators[3].BondedTokens())
|
||||
assert.DeepEqual(t, sdk.NewInt(0), resValidators[4].BondedTokens())
|
||||
assert.DeepEqual(t, math.NewInt(400).Mul(f.stakingKeeper.PowerReduction(f.sdkCtx)), resValidators[0].BondedTokens())
|
||||
assert.DeepEqual(t, math.NewInt(200).Mul(f.stakingKeeper.PowerReduction(f.sdkCtx)), resValidators[1].BondedTokens())
|
||||
assert.DeepEqual(t, math.NewInt(100).Mul(f.stakingKeeper.PowerReduction(f.sdkCtx)), resValidators[2].BondedTokens())
|
||||
assert.DeepEqual(t, math.NewInt(1).Mul(f.stakingKeeper.PowerReduction(f.sdkCtx)), resValidators[3].BondedTokens())
|
||||
assert.DeepEqual(t, math.NewInt(0), resValidators[4].BondedTokens())
|
||||
assert.Equal(t, validators[3].OperatorAddress, resValidators[0].OperatorAddress, "%v", resValidators)
|
||||
assert.Equal(t, validators[4].OperatorAddress, resValidators[1].OperatorAddress, "%v", resValidators)
|
||||
assert.Equal(t, validators[1].OperatorAddress, resValidators[2].OperatorAddress, "%v", resValidators)
|
||||
@@ -192,7 +192,7 @@ func TestGetValidatorSortingUnmixed(t *testing.T) {
|
||||
assert.Equal(t, validators[0].OperatorAddress, resValidators[4].OperatorAddress, "%v", resValidators)
|
||||
|
||||
// test a basic increase in voting power
|
||||
validators[3].Tokens = sdk.NewInt(500).Mul(f.stakingKeeper.PowerReduction(f.sdkCtx))
|
||||
validators[3].Tokens = math.NewInt(500).Mul(f.stakingKeeper.PowerReduction(f.sdkCtx))
|
||||
keeper.TestingUpdateValidator(f.stakingKeeper, f.sdkCtx, validators[3], true)
|
||||
resValidators, err = f.stakingKeeper.GetBondedValidatorsByPower(f.sdkCtx)
|
||||
assert.NilError(t, err)
|
||||
@@ -200,7 +200,7 @@ func TestGetValidatorSortingUnmixed(t *testing.T) {
|
||||
assert.Assert(ValEq(t, validators[3], resValidators[0]))
|
||||
|
||||
// test a decrease in voting power
|
||||
validators[3].Tokens = sdk.NewInt(300).Mul(f.stakingKeeper.PowerReduction(f.sdkCtx))
|
||||
validators[3].Tokens = math.NewInt(300).Mul(f.stakingKeeper.PowerReduction(f.sdkCtx))
|
||||
keeper.TestingUpdateValidator(f.stakingKeeper, f.sdkCtx, validators[3], true)
|
||||
resValidators, err = f.stakingKeeper.GetBondedValidatorsByPower(f.sdkCtx)
|
||||
assert.NilError(t, err)
|
||||
@@ -209,7 +209,7 @@ func TestGetValidatorSortingUnmixed(t *testing.T) {
|
||||
assert.Assert(ValEq(t, validators[4], resValidators[1]))
|
||||
|
||||
// test equal voting power, different age
|
||||
validators[3].Tokens = sdk.NewInt(200).Mul(f.stakingKeeper.PowerReduction(f.sdkCtx))
|
||||
validators[3].Tokens = math.NewInt(200).Mul(f.stakingKeeper.PowerReduction(f.sdkCtx))
|
||||
f.sdkCtx = f.sdkCtx.WithBlockHeight(10)
|
||||
keeper.TestingUpdateValidator(f.stakingKeeper, f.sdkCtx, validators[3], true)
|
||||
resValidators, err = f.stakingKeeper.GetBondedValidatorsByPower(f.sdkCtx)
|
||||
@@ -228,8 +228,8 @@ func TestGetValidatorSortingUnmixed(t *testing.T) {
|
||||
assert.Assert(ValEq(t, validators[4], resValidators[1]))
|
||||
|
||||
// change in voting power of both validators, both still in v-set, no age change
|
||||
validators[3].Tokens = sdk.NewInt(300).Mul(f.stakingKeeper.PowerReduction(f.sdkCtx))
|
||||
validators[4].Tokens = sdk.NewInt(300).Mul(f.stakingKeeper.PowerReduction(f.sdkCtx))
|
||||
validators[3].Tokens = math.NewInt(300).Mul(f.stakingKeeper.PowerReduction(f.sdkCtx))
|
||||
validators[4].Tokens = math.NewInt(300).Mul(f.stakingKeeper.PowerReduction(f.sdkCtx))
|
||||
keeper.TestingUpdateValidator(f.stakingKeeper, f.sdkCtx, validators[3], true)
|
||||
resValidators, err = f.stakingKeeper.GetBondedValidatorsByPower(f.sdkCtx)
|
||||
assert.NilError(t, err)
|
||||
@@ -275,7 +275,7 @@ func TestGetValidatorSortingMixed(t *testing.T) {
|
||||
var validators [5]types.Validator
|
||||
for i, amt := range amts {
|
||||
validators[i] = testutil.NewValidator(t, sdk.ValAddress(addrs[i]), PKs[i])
|
||||
validators[i].DelegatorShares = sdk.NewDecFromInt(amt)
|
||||
validators[i].DelegatorShares = math.LegacyNewDecFromInt(amt)
|
||||
validators[i].Status = types.Bonded
|
||||
validators[i].Tokens = amt
|
||||
keeper.TestingUpdateValidator(f.stakingKeeper, f.sdkCtx, validators[i], true)
|
||||
@@ -302,8 +302,8 @@ func TestGetValidatorSortingMixed(t *testing.T) {
|
||||
assert.NilError(t, err)
|
||||
// The validators returned should match the max validators
|
||||
assert.Equal(t, 2, len(resValidators))
|
||||
assert.DeepEqual(t, sdk.NewInt(400).Mul(f.stakingKeeper.PowerReduction(f.sdkCtx)), resValidators[0].BondedTokens())
|
||||
assert.DeepEqual(t, sdk.NewInt(200).Mul(f.stakingKeeper.PowerReduction(f.sdkCtx)), resValidators[1].BondedTokens())
|
||||
assert.DeepEqual(t, math.NewInt(400).Mul(f.stakingKeeper.PowerReduction(f.sdkCtx)), resValidators[0].BondedTokens())
|
||||
assert.DeepEqual(t, math.NewInt(200).Mul(f.stakingKeeper.PowerReduction(f.sdkCtx)), resValidators[1].BondedTokens())
|
||||
assert.Equal(t, validators[3].OperatorAddress, resValidators[0].OperatorAddress, "%v", resValidators)
|
||||
assert.Equal(t, validators[4].OperatorAddress, resValidators[1].OperatorAddress, "%v", resValidators)
|
||||
}
|
||||
@@ -410,10 +410,10 @@ func TestGetValidatorsEdgeCases(t *testing.T) {
|
||||
|
||||
// validator 3 does not get spot back
|
||||
f.stakingKeeper.DeleteValidatorByPowerIndex(f.sdkCtx, validators[3])
|
||||
validators[3], _ = validators[3].AddTokensFromDel(sdk.NewInt(200))
|
||||
validators[3], _ = validators[3].AddTokensFromDel(math.NewInt(200))
|
||||
|
||||
notBondedPool = f.stakingKeeper.GetNotBondedPool(f.sdkCtx)
|
||||
assert.NilError(t, banktestutil.FundModuleAccount(f.sdkCtx, f.bankKeeper, notBondedPool.GetName(), sdk.NewCoins(sdk.NewCoin(params.BondDenom, sdk.NewInt(200)))))
|
||||
assert.NilError(t, banktestutil.FundModuleAccount(f.sdkCtx, f.bankKeeper, notBondedPool.GetName(), sdk.NewCoins(sdk.NewCoin(params.BondDenom, math.NewInt(200)))))
|
||||
f.accountKeeper.SetModuleAccount(f.sdkCtx, notBondedPool)
|
||||
|
||||
validators[3] = keeper.TestingUpdateValidator(f.stakingKeeper, f.sdkCtx, validators[3], true)
|
||||
@@ -738,14 +738,14 @@ func TestApplyAndReturnValidatorSetUpdatesNewValidator(t *testing.T) {
|
||||
// zero power
|
||||
valPubKey := PKs[len(validators)+1]
|
||||
valAddr := sdk.ValAddress(valPubKey.Address().Bytes())
|
||||
amt := sdk.NewInt(100)
|
||||
amt := math.NewInt(100)
|
||||
|
||||
validator := testutil.NewValidator(t, valAddr, valPubKey)
|
||||
validator, _ = validator.AddTokensFromDel(amt)
|
||||
|
||||
f.stakingKeeper.SetValidator(f.sdkCtx, validator)
|
||||
|
||||
validator, _ = validator.RemoveDelShares(sdk.NewDecFromInt(amt))
|
||||
validator, _ = validator.RemoveDelShares(math.LegacyNewDecFromInt(amt))
|
||||
f.stakingKeeper.SetValidator(f.sdkCtx, validator)
|
||||
f.stakingKeeper.SetValidatorByPowerIndex(f.sdkCtx, validator)
|
||||
|
||||
|
||||
@@ -217,7 +217,7 @@ func TestAminoJSON_LegacyParity(t *testing.T) {
|
||||
pubkeyAny, _ := codectypes.NewAnyWithValue(&secp256k1types.PubKey{Key: []byte("foo")})
|
||||
pubkeyAnyPulsar := newAny(t, &secp256k1.PubKey{Key: []byte("foo")})
|
||||
dec10bz, _ := math.LegacyNewDec(10).Marshal()
|
||||
int123bz, _ := types.NewInt(123).Marshal()
|
||||
int123bz, _ := math.NewInt(123).Marshal()
|
||||
|
||||
cases := map[string]struct {
|
||||
gogo gogoproto.Message
|
||||
@@ -396,7 +396,7 @@ func TestAminoJSON_LegacyParity(t *testing.T) {
|
||||
pulsar: &vestingapi.BaseVestingAccount{BaseAccount: &authapi.BaseAccount{PubKey: pubkeyAnyPulsar}},
|
||||
},
|
||||
"math/int_as_string": {
|
||||
gogo: &gogo_testpb.IntAsString{IntAsString: types.NewInt(123)},
|
||||
gogo: &gogo_testpb.IntAsString{IntAsString: math.NewInt(123)},
|
||||
pulsar: &pulsar_testpb.IntAsString{IntAsString: "123"},
|
||||
},
|
||||
"math/int_as_string/empty": {
|
||||
@@ -404,7 +404,7 @@ func TestAminoJSON_LegacyParity(t *testing.T) {
|
||||
pulsar: &pulsar_testpb.IntAsString{},
|
||||
},
|
||||
"math/int_as_bytes": {
|
||||
gogo: &gogo_testpb.IntAsBytes{IntAsBytes: types.NewInt(123)},
|
||||
gogo: &gogo_testpb.IntAsBytes{IntAsBytes: math.NewInt(123)},
|
||||
pulsar: &pulsar_testpb.IntAsBytes{IntAsBytes: int123bz},
|
||||
},
|
||||
"math/int_as_bytes/empty": {
|
||||
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
"pgregory.net/rapid"
|
||||
|
||||
msgv1 "cosmossdk.io/api/cosmos/msg/v1"
|
||||
"cosmossdk.io/math"
|
||||
"cosmossdk.io/x/evidence"
|
||||
feegrantmodule "cosmossdk.io/x/feegrant/module"
|
||||
"cosmossdk.io/x/tx/decode"
|
||||
@@ -48,7 +49,7 @@ func TestDecode(t *testing.T) {
|
||||
slashing.AppModuleBasic{}, staking.AppModuleBasic{}, upgrade.AppModuleBasic{}, vesting.AppModuleBasic{})
|
||||
legacytx.RegressionTestingAminoCodec = encCfg.Amino
|
||||
|
||||
fee := sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(100)))
|
||||
fee := sdk.NewCoins(sdk.NewCoin("stake", math.NewInt(100)))
|
||||
gas := uint64(200)
|
||||
memo := "memo"
|
||||
accSeq := uint64(2)
|
||||
|
||||
@@ -5,7 +5,15 @@ deps:
|
||||
owner: cosmos
|
||||
repository: cosmos-proto
|
||||
commit: 1935555c206d4afb9e94615dfd0fad31
|
||||
- remote: buf.build
|
||||
owner: cosmos
|
||||
repository: cosmos-sdk
|
||||
commit: 4067d92aa6344f549e84824ab7f22d4f
|
||||
- remote: buf.build
|
||||
owner: cosmos
|
||||
repository: gogo-proto
|
||||
commit: 34d970b699f84aa382f3c29773a60836
|
||||
commit: 5e5b9fdd01804356895f8f79a6f1ddc1
|
||||
- remote: buf.build
|
||||
owner: googleapis
|
||||
repository: googleapis
|
||||
commit: cc916c31859748a68fd229a3c8d7a2e8
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
version: v1
|
||||
deps:
|
||||
- buf.build/cosmos/cosmos-sdk
|
||||
- buf.build/cosmos/cosmos-proto
|
||||
- buf.build/cosmos/gogo-proto
|
||||
lint:
|
||||
|
||||
@@ -5,9 +5,9 @@ package testpb
|
||||
|
||||
import (
|
||||
context "context"
|
||||
cosmossdk_io_math "cosmossdk.io/math"
|
||||
fmt "fmt"
|
||||
_ "github.com/cosmos/cosmos-proto"
|
||||
github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types"
|
||||
_ "github.com/cosmos/cosmos-sdk/types/msgservice"
|
||||
_ "github.com/cosmos/cosmos-sdk/types/tx/amino"
|
||||
_ "github.com/cosmos/gogoproto/gogoproto"
|
||||
@@ -222,7 +222,7 @@ func (m *TestNullableFields) GetNonNullableDontOmitempty() Streng {
|
||||
}
|
||||
|
||||
type IntAsString struct {
|
||||
IntAsString github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=int_as_string,json=intAsString,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"int_as_string"`
|
||||
IntAsString cosmossdk_io_math.Int `protobuf:"bytes,1,opt,name=int_as_string,json=intAsString,proto3,customtype=cosmossdk.io/math.Int" json:"int_as_string"`
|
||||
}
|
||||
|
||||
func (m *IntAsString) Reset() { *m = IntAsString{} }
|
||||
@@ -259,7 +259,7 @@ func (m *IntAsString) XXX_DiscardUnknown() {
|
||||
var xxx_messageInfo_IntAsString proto.InternalMessageInfo
|
||||
|
||||
type IntAsBytes struct {
|
||||
IntAsBytes github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=int_as_bytes,json=intAsBytes,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"int_as_bytes"`
|
||||
IntAsBytes cosmossdk_io_math.Int `protobuf:"bytes,1,opt,name=int_as_bytes,json=intAsBytes,proto3,customtype=cosmossdk.io/math.Int" json:"int_as_bytes"`
|
||||
}
|
||||
|
||||
func (m *IntAsBytes) Reset() { *m = IntAsBytes{} }
|
||||
@@ -306,37 +306,37 @@ func init() {
|
||||
func init() { proto.RegisterFile("testpb/test.proto", fileDescriptor_41c67e33ca9d1f26) }
|
||||
|
||||
var fileDescriptor_41c67e33ca9d1f26 = []byte{
|
||||
// 473 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x54, 0x4f, 0x6b, 0x13, 0x41,
|
||||
0x14, 0xdf, 0x69, 0x9b, 0x40, 0x5f, 0xaa, 0x90, 0x21, 0xda, 0xb8, 0xc2, 0xb6, 0xe4, 0x20, 0x45,
|
||||
0xe8, 0x2e, 0xd6, 0xb3, 0x87, 0x06, 0x29, 0x44, 0xa8, 0xc2, 0xda, 0x83, 0xb7, 0x65, 0x37, 0x19,
|
||||
0xd6, 0xc1, 0xdd, 0x37, 0x6b, 0xe6, 0xa5, 0x98, 0x9b, 0x1f, 0xc1, 0x8f, 0xe1, 0xd1, 0x83, 0x1f,
|
||||
0x22, 0xc7, 0xe2, 0x49, 0x3c, 0x14, 0x49, 0x0e, 0x7e, 0x0d, 0x99, 0x9d, 0xdd, 0xb4, 0xb5, 0x41,
|
||||
0x41, 0x72, 0xd9, 0x79, 0xff, 0xe6, 0xf7, 0xfb, 0xf1, 0xe3, 0xcd, 0x42, 0x9b, 0x84, 0xa6, 0x22,
|
||||
0x09, 0xcc, 0xe1, 0x17, 0x63, 0x45, 0x8a, 0x37, 0x6d, 0xc9, 0xdd, 0x1d, 0x2a, 0x9d, 0x2b, 0x1d,
|
||||
0xe4, 0x3a, 0x0d, 0xce, 0x9f, 0x98, 0xc3, 0x0e, 0xb8, 0x9d, 0x54, 0xa5, 0xaa, 0x0c, 0x03, 0x13,
|
||||
0x55, 0xd5, 0x76, 0x9c, 0x4b, 0x54, 0x41, 0xf9, 0xad, 0x4a, 0x0f, 0x2c, 0x42, 0x64, 0x67, 0x6d,
|
||||
0x62, 0x5b, 0x3d, 0x0f, 0x9a, 0x9a, 0xc6, 0x02, 0x53, 0xde, 0x81, 0xc6, 0x79, 0x9c, 0x4d, 0x44,
|
||||
0x97, 0xed, 0xb3, 0x83, 0xed, 0xd0, 0x26, 0xbd, 0xd9, 0x06, 0xf0, 0x33, 0xa1, 0x29, 0x14, 0x85,
|
||||
0x88, 0x49, 0x8c, 0x4e, 0xa4, 0xc8, 0x46, 0x9a, 0x3f, 0x03, 0x8e, 0x93, 0x2c, 0x8b, 0x93, 0x4c,
|
||||
0x44, 0x2a, 0x97, 0x24, 0xf2, 0x82, 0xa6, 0x5d, 0xb6, 0xbf, 0x79, 0xd0, 0x3a, 0xba, 0xeb, 0x5b,
|
||||
0xe1, 0xbe, 0x05, 0x0e, 0xdb, 0xf5, 0xe4, 0xab, 0x7a, 0x90, 0x9f, 0xc2, 0xee, 0xf2, 0xfa, 0x48,
|
||||
0x21, 0x5d, 0xc3, 0xd8, 0x58, 0x85, 0xd1, 0x6f, 0x7c, 0xfe, 0xf5, 0xe5, 0x31, 0x0b, 0xef, 0xd5,
|
||||
0xb7, 0x9e, 0x2b, 0xa4, 0x2b, 0xb8, 0x17, 0x70, 0x1f, 0x15, 0x46, 0x2b, 0x14, 0x6d, 0xae, 0x44,
|
||||
0xdb, 0x9a, 0x5d, 0xee, 0x39, 0x61, 0x07, 0x15, 0xbe, 0xbc, 0x25, 0xed, 0x0d, 0x3c, 0xbc, 0x81,
|
||||
0xf5, 0x87, 0xbc, 0xad, 0x95, 0x80, 0xdb, 0x06, 0xd0, 0x4a, 0xec, 0x5e, 0x43, 0xbd, 0xa1, 0x72,
|
||||
0x69, 0x65, 0xdd, 0xfd, 0x87, 0x95, 0x6c, 0x0d, 0x56, 0xb2, 0xb5, 0x5a, 0xc9, 0xd6, 0x6d, 0x25,
|
||||
0xfb, 0x5f, 0x2b, 0x09, 0x5a, 0x03, 0xa4, 0x63, 0xfd, 0x9a, 0xc6, 0x12, 0x53, 0x2e, 0xe0, 0x8e,
|
||||
0x44, 0x8a, 0x62, 0x1d, 0xe9, 0xb2, 0x60, 0x57, 0xb8, 0x7f, 0x6c, 0xa0, 0x7e, 0x5c, 0xee, 0x3d,
|
||||
0x4a, 0x25, 0xbd, 0x9d, 0x24, 0xfe, 0x50, 0xe5, 0xd5, 0xf2, 0x57, 0xc7, 0xa1, 0x1e, 0xbd, 0x0b,
|
||||
0x68, 0x5a, 0x08, 0xed, 0x0f, 0x90, 0xbe, 0x7d, 0x3d, 0x84, 0xea, 0x6d, 0x0c, 0x90, 0xac, 0x84,
|
||||
0x96, 0xbc, 0xa2, 0xe9, 0xbd, 0x07, 0x28, 0x59, 0xfb, 0x53, 0x12, 0x9a, 0x0f, 0x61, 0xa7, 0x22,
|
||||
0x4d, 0x4c, 0x5e, 0x72, 0xee, 0xac, 0x83, 0x13, 0xe4, 0x92, 0xe4, 0x48, 0x40, 0x67, 0x80, 0x24,
|
||||
0xd2, 0x71, 0x4c, 0x52, 0xe1, 0xd9, 0x07, 0xb3, 0x3f, 0xa7, 0x3a, 0xe5, 0x27, 0x00, 0x26, 0xac,
|
||||
0x56, 0xc8, 0xad, 0x3d, 0xbc, 0xfd, 0x52, 0xdd, 0xbf, 0xf4, 0x7a, 0x8e, 0xdb, 0xf8, 0x68, 0x28,
|
||||
0xfb, 0xdd, 0xd9, 0xdc, 0x63, 0x17, 0x73, 0x8f, 0xfd, 0x9c, 0x7b, 0xec, 0xd3, 0xc2, 0x73, 0x2e,
|
||||
0x16, 0x9e, 0xf3, 0x7d, 0xe1, 0x39, 0x49, 0xb3, 0xfc, 0x4d, 0x3c, 0xfd, 0x1d, 0x00, 0x00, 0xff,
|
||||
0xff, 0xde, 0xf7, 0xd7, 0x03, 0xa0, 0x04, 0x00, 0x00,
|
||||
// 466 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x94, 0x41, 0x6b, 0xd4, 0x40,
|
||||
0x14, 0xc7, 0x33, 0x6d, 0x77, 0xa1, 0x6f, 0xab, 0xb0, 0xc3, 0xd6, 0xae, 0x11, 0xd2, 0xb2, 0xa7,
|
||||
0x22, 0x98, 0x68, 0x3d, 0x7b, 0x70, 0x91, 0xc2, 0x0a, 0x55, 0x88, 0x7b, 0xf0, 0x16, 0xb3, 0xdd,
|
||||
0x21, 0x0e, 0x26, 0x6f, 0x42, 0xe6, 0xb5, 0xd8, 0x9b, 0x1f, 0xc1, 0x8f, 0xe1, 0xd1, 0x83, 0x1f,
|
||||
0x62, 0x8f, 0xc5, 0x93, 0x78, 0x28, 0xb2, 0x7b, 0xf0, 0x6b, 0xc8, 0x64, 0x92, 0x6d, 0x6b, 0x83,
|
||||
0x42, 0xd9, 0x4b, 0x66, 0xe6, 0xbd, 0x37, 0xbf, 0xf7, 0xe7, 0xcf, 0x9b, 0x40, 0x97, 0x84, 0xa6,
|
||||
0x7c, 0x12, 0x98, 0xc5, 0xcf, 0x0b, 0x45, 0x8a, 0xb7, 0x6d, 0xc8, 0xdd, 0x39, 0x56, 0x3a, 0x53,
|
||||
0x3a, 0xc8, 0x74, 0x12, 0x9c, 0x3e, 0x31, 0x8b, 0x2d, 0x70, 0x7b, 0x89, 0x4a, 0x54, 0xb9, 0x0d,
|
||||
0xcc, 0xae, 0x8a, 0x76, 0xe3, 0x4c, 0xa2, 0x0a, 0xca, 0x6f, 0x15, 0xba, 0x6f, 0x09, 0x91, 0xad,
|
||||
0xb5, 0x07, 0x9b, 0x1a, 0x78, 0xd0, 0xd6, 0x54, 0x08, 0x4c, 0x78, 0x0f, 0x5a, 0xa7, 0x71, 0x7a,
|
||||
0x22, 0xfa, 0x6c, 0x8f, 0xed, 0x6f, 0x86, 0xf6, 0x30, 0x98, 0xad, 0x01, 0x1f, 0x0b, 0x4d, 0xa1,
|
||||
0xc8, 0x45, 0x4c, 0x62, 0x7a, 0x28, 0x45, 0x3a, 0xd5, 0xfc, 0x19, 0x70, 0x3c, 0x49, 0xd3, 0x78,
|
||||
0x92, 0x8a, 0x48, 0x65, 0x92, 0x44, 0x96, 0xd3, 0x59, 0x9f, 0xed, 0xad, 0xef, 0x77, 0x0e, 0xee,
|
||||
0xfa, 0x56, 0xb8, 0x6f, 0xc1, 0x61, 0xb7, 0xae, 0x7c, 0x5d, 0x17, 0xf2, 0x23, 0xd8, 0x59, 0x5e,
|
||||
0x9f, 0x2a, 0xa4, 0x2b, 0x8c, 0xb5, 0x26, 0xc6, 0xb0, 0xf5, 0xe5, 0xf7, 0xd7, 0x87, 0x2c, 0xdc,
|
||||
0xae, 0x6f, 0xbd, 0x50, 0x48, 0x97, 0xb8, 0x97, 0x70, 0x0f, 0x15, 0x46, 0x0d, 0x8a, 0xd6, 0x1b,
|
||||
0x69, 0x1b, 0xb3, 0x8b, 0x5d, 0x27, 0xec, 0xa1, 0xc2, 0x57, 0x37, 0xa4, 0xbd, 0x85, 0x07, 0xd7,
|
||||
0x58, 0x7f, 0xc9, 0xdb, 0x68, 0x04, 0x6e, 0x1a, 0xa0, 0x95, 0xd8, 0xbf, 0x42, 0xbd, 0xa6, 0x72,
|
||||
0x69, 0x65, 0x9d, 0xfd, 0x8f, 0x95, 0x6c, 0x05, 0x56, 0xb2, 0x95, 0x5a, 0xc9, 0x56, 0x6d, 0x25,
|
||||
0xbb, 0xad, 0x95, 0xc7, 0xd0, 0x19, 0x21, 0x3d, 0xd7, 0x6f, 0xa8, 0x90, 0x98, 0xf0, 0x31, 0xdc,
|
||||
0x91, 0x48, 0x51, 0xac, 0x23, 0x5d, 0x06, 0xec, 0x08, 0x0f, 0x1f, 0x1b, 0xd4, 0xcf, 0x8b, 0xdd,
|
||||
0x6d, 0x3b, 0xf1, 0x7a, 0xfa, 0xc1, 0x97, 0x2a, 0xc8, 0x62, 0x7a, 0xef, 0x8f, 0x90, 0xbe, 0x7f,
|
||||
0x7b, 0x04, 0xd5, 0x53, 0x18, 0x21, 0xd9, 0x8e, 0x1d, 0x79, 0x49, 0x1d, 0xbc, 0x03, 0x28, 0x9b,
|
||||
0x0c, 0xcf, 0x48, 0x68, 0x1e, 0xc2, 0x56, 0xd5, 0x63, 0x62, 0xce, 0x65, 0x8b, 0xad, 0x5b, 0xb4,
|
||||
0x00, 0xb9, 0x64, 0x1e, 0x08, 0xe8, 0x8d, 0x90, 0x44, 0x52, 0xc4, 0x24, 0x15, 0x8e, 0x3f, 0x9a,
|
||||
0xe9, 0x38, 0xd2, 0x09, 0x3f, 0x04, 0x30, 0xdb, 0x6a, 0x40, 0xdc, 0xda, 0xa1, 0x9b, 0xef, 0xd0,
|
||||
0xfd, 0x47, 0x6e, 0xe0, 0xb8, 0xad, 0x4f, 0xa6, 0xe5, 0xb0, 0x3f, 0x9b, 0x7b, 0xec, 0x7c, 0xee,
|
||||
0xb1, 0x5f, 0x73, 0x8f, 0x7d, 0x5e, 0x78, 0xce, 0xf9, 0xc2, 0x73, 0x7e, 0x2c, 0x3c, 0x67, 0xd2,
|
||||
0x2e, 0x7f, 0x02, 0x4f, 0xff, 0x04, 0x00, 0x00, 0xff, 0xff, 0x5e, 0x48, 0xa0, 0x81, 0x7e, 0x04,
|
||||
0x00, 0x00,
|
||||
}
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
|
||||
@@ -3156,39 +3156,37 @@ var file_testpb_test_proto_rawDesc = []byte{
|
||||
0x70, 0x74, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x74, 0x65, 0x73, 0x74,
|
||||
0x70, 0x62, 0x2e, 0x73, 0x74, 0x72, 0x65, 0x6e, 0x67, 0x42, 0x09, 0xc8, 0xde, 0x1f, 0x00, 0xa8,
|
||||
0xe7, 0xb0, 0x2a, 0x01, 0x52, 0x18, 0x6e, 0x6f, 0x6e, 0x4e, 0x75, 0x6c, 0x6c, 0x61, 0x62, 0x6c,
|
||||
0x65, 0x44, 0x6f, 0x6e, 0x74, 0x4f, 0x6d, 0x69, 0x74, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x74,
|
||||
0x0a, 0x0b, 0x49, 0x6e, 0x74, 0x41, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x12, 0x65, 0x0a,
|
||||
0x65, 0x44, 0x6f, 0x6e, 0x74, 0x4f, 0x6d, 0x69, 0x74, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x63,
|
||||
0x0a, 0x0b, 0x49, 0x6e, 0x74, 0x41, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x12, 0x54, 0x0a,
|
||||
0x0d, 0x69, 0x6e, 0x74, 0x5f, 0x61, 0x73, 0x5f, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x18, 0x01,
|
||||
0x20, 0x01, 0x28, 0x09, 0x42, 0x41, 0xc8, 0xde, 0x1f, 0x00, 0xda, 0xde, 0x1f, 0x26, 0x67, 0x69,
|
||||
0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f,
|
||||
0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73,
|
||||
0x2e, 0x49, 0x6e, 0x74, 0xd2, 0xb4, 0x2d, 0x0a, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x49,
|
||||
0x6e, 0x74, 0xa8, 0xe7, 0xb0, 0x2a, 0x01, 0x52, 0x0b, 0x69, 0x6e, 0x74, 0x41, 0x73, 0x53, 0x74,
|
||||
0x72, 0x69, 0x6e, 0x67, 0x22, 0x71, 0x0a, 0x0a, 0x49, 0x6e, 0x74, 0x41, 0x73, 0x42, 0x79, 0x74,
|
||||
0x65, 0x73, 0x12, 0x63, 0x0a, 0x0c, 0x69, 0x6e, 0x74, 0x5f, 0x61, 0x73, 0x5f, 0x62, 0x79, 0x74,
|
||||
0x65, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x41, 0xc8, 0xde, 0x1f, 0x00, 0xda, 0xde,
|
||||
0x1f, 0x26, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73,
|
||||
0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x74,
|
||||
0x79, 0x70, 0x65, 0x73, 0x2e, 0x49, 0x6e, 0x74, 0xd2, 0xb4, 0x2d, 0x0a, 0x63, 0x6f, 0x73, 0x6d,
|
||||
0x6f, 0x73, 0x2e, 0x49, 0x6e, 0x74, 0xa8, 0xe7, 0xb0, 0x2a, 0x01, 0x52, 0x0a, 0x69, 0x6e, 0x74,
|
||||
0x41, 0x73, 0x42, 0x79, 0x74, 0x65, 0x73, 0x32, 0x65, 0x0a, 0x14, 0x49, 0x6e, 0x74, 0x65, 0x67,
|
||||
0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x54, 0x78, 0x54, 0x65, 0x73, 0x74, 0x4d, 0x73, 0x67, 0x12,
|
||||
0x46, 0x0a, 0x0a, 0x54, 0x65, 0x73, 0x74, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x73, 0x12, 0x1a, 0x2e,
|
||||
0x74, 0x65, 0x73, 0x74, 0x70, 0x62, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x52, 0x65, 0x70, 0x65, 0x61,
|
||||
0x74, 0x65, 0x64, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x73, 0x1a, 0x1a, 0x2e, 0x74, 0x65, 0x73, 0x74,
|
||||
0x70, 0x62, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x52, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x46,
|
||||
0x69, 0x65, 0x6c, 0x64, 0x73, 0x22, 0x00, 0x1a, 0x05, 0x80, 0xe7, 0xb0, 0x2a, 0x01, 0x42, 0xa7,
|
||||
0x01, 0x0a, 0x0a, 0x63, 0x6f, 0x6d, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x70, 0x62, 0x42, 0x09, 0x54,
|
||||
0x65, 0x73, 0x74, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x56, 0x67, 0x69, 0x74, 0x68,
|
||||
0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f,
|
||||
0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x73, 0x2f, 0x69,
|
||||
0x6e, 0x74, 0x65, 0x67, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x61, 0x6d, 0x69, 0x6e, 0x6f,
|
||||
0x6a, 0x73, 0x6f, 0x6e, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x74, 0x65,
|
||||
0x73, 0x74, 0x70, 0x62, 0x2f, 0x70, 0x75, 0x6c, 0x73, 0x61, 0x72, 0x2f, 0x74, 0x65, 0x73, 0x74,
|
||||
0x70, 0x62, 0xa2, 0x02, 0x03, 0x54, 0x58, 0x58, 0xaa, 0x02, 0x06, 0x54, 0x65, 0x73, 0x74, 0x70,
|
||||
0x62, 0xca, 0x02, 0x06, 0x54, 0x65, 0x73, 0x74, 0x70, 0x62, 0xe2, 0x02, 0x12, 0x54, 0x65, 0x73,
|
||||
0x74, 0x70, 0x62, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea,
|
||||
0x02, 0x06, 0x54, 0x65, 0x73, 0x74, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
0x20, 0x01, 0x28, 0x09, 0x42, 0x30, 0xc8, 0xde, 0x1f, 0x00, 0xda, 0xde, 0x1f, 0x15, 0x63, 0x6f,
|
||||
0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x6d, 0x61, 0x74, 0x68, 0x2e,
|
||||
0x49, 0x6e, 0x74, 0xd2, 0xb4, 0x2d, 0x0a, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x49, 0x6e,
|
||||
0x74, 0xa8, 0xe7, 0xb0, 0x2a, 0x01, 0x52, 0x0b, 0x69, 0x6e, 0x74, 0x41, 0x73, 0x53, 0x74, 0x72,
|
||||
0x69, 0x6e, 0x67, 0x22, 0x60, 0x0a, 0x0a, 0x49, 0x6e, 0x74, 0x41, 0x73, 0x42, 0x79, 0x74, 0x65,
|
||||
0x73, 0x12, 0x52, 0x0a, 0x0c, 0x69, 0x6e, 0x74, 0x5f, 0x61, 0x73, 0x5f, 0x62, 0x79, 0x74, 0x65,
|
||||
0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x30, 0xc8, 0xde, 0x1f, 0x00, 0xda, 0xde, 0x1f,
|
||||
0x15, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x6d, 0x61,
|
||||
0x74, 0x68, 0x2e, 0x49, 0x6e, 0x74, 0xd2, 0xb4, 0x2d, 0x0a, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73,
|
||||
0x2e, 0x49, 0x6e, 0x74, 0xa8, 0xe7, 0xb0, 0x2a, 0x01, 0x52, 0x0a, 0x69, 0x6e, 0x74, 0x41, 0x73,
|
||||
0x42, 0x79, 0x74, 0x65, 0x73, 0x32, 0x65, 0x0a, 0x14, 0x49, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x61,
|
||||
0x74, 0x69, 0x6f, 0x6e, 0x54, 0x78, 0x54, 0x65, 0x73, 0x74, 0x4d, 0x73, 0x67, 0x12, 0x46, 0x0a,
|
||||
0x0a, 0x54, 0x65, 0x73, 0x74, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x73, 0x12, 0x1a, 0x2e, 0x74, 0x65,
|
||||
0x73, 0x74, 0x70, 0x62, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x52, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65,
|
||||
0x64, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x73, 0x1a, 0x1a, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x70, 0x62,
|
||||
0x2e, 0x54, 0x65, 0x73, 0x74, 0x52, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x46, 0x69, 0x65,
|
||||
0x6c, 0x64, 0x73, 0x22, 0x00, 0x1a, 0x05, 0x80, 0xe7, 0xb0, 0x2a, 0x01, 0x42, 0xa7, 0x01, 0x0a,
|
||||
0x0a, 0x63, 0x6f, 0x6d, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x70, 0x62, 0x42, 0x09, 0x54, 0x65, 0x73,
|
||||
0x74, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x56, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62,
|
||||
0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d,
|
||||
0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x73, 0x2f, 0x69, 0x6e, 0x74,
|
||||
0x65, 0x67, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x61, 0x6d, 0x69, 0x6e, 0x6f, 0x6a, 0x73,
|
||||
0x6f, 0x6e, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x74, 0x65, 0x73, 0x74,
|
||||
0x70, 0x62, 0x2f, 0x70, 0x75, 0x6c, 0x73, 0x61, 0x72, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x70, 0x62,
|
||||
0xa2, 0x02, 0x03, 0x54, 0x58, 0x58, 0xaa, 0x02, 0x06, 0x54, 0x65, 0x73, 0x74, 0x70, 0x62, 0xca,
|
||||
0x02, 0x06, 0x54, 0x65, 0x73, 0x74, 0x70, 0x62, 0xe2, 0x02, 0x12, 0x54, 0x65, 0x73, 0x74, 0x70,
|
||||
0x62, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x06,
|
||||
0x54, 0x65, 0x73, 0x74, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
|
||||
@@ -43,7 +43,7 @@ message TestNullableFields {
|
||||
message IntAsString {
|
||||
string int_as_string = 1 [
|
||||
(cosmos_proto.scalar) = "cosmos.Int",
|
||||
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
|
||||
(gogoproto.customtype) = "cosmossdk.io/math.Int",
|
||||
(amino.dont_omitempty) = true,
|
||||
(gogoproto.nullable) = false
|
||||
];
|
||||
@@ -52,7 +52,7 @@ message IntAsString {
|
||||
message IntAsBytes {
|
||||
bytes int_as_bytes = 1 [
|
||||
(cosmos_proto.scalar) = "cosmos.Int",
|
||||
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
|
||||
(gogoproto.customtype) = "cosmossdk.io/math.Int",
|
||||
(amino.dont_omitempty) = true,
|
||||
(gogoproto.nullable) = false
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user