Skip to content

Commit

Permalink
refactor: move legacy gov to v1beta1 (cosmos#10748)
Browse files Browse the repository at this point in the history
Ref: cosmos#9810

Moves all legacy gov code to `v1beta1`. This preserves all existing behavior (i.e. everything still uses v1beta1). It's merely moving things around to get everything in the right place logistically (hence the large diff still)

---

### Author Checklist

*All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.*

I have...

- [ ] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] added `!` to the type prefix if API or client breaking change
- [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting))
- [ ] provided a link to the relevant issue or specification
- [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules)
- [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing)
- [ ] added a changelog entry to `CHANGELOG.md`
- [ ] included comments for [documenting Go code](https://blog.golang.org/godoc)
- [ ] updated the relevant documentation or specification
- [ ] reviewed "Files changed" and left comments if necessary
- [ ] confirmed all CI checks have passed

### Reviewers Checklist

*All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.*

I have...

- [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] confirmed `!` in the type prefix if API or client breaking change
- [ ] confirmed all author checklist items have been addressed 
- [ ] reviewed state machine logic
- [ ] reviewed API design and naming
- [ ] reviewed documentation is accurate
- [ ] reviewed tests and test coverage
- [ ] manually tested (if applicable)
  • Loading branch information
cmwaters authored Dec 13, 2021
1 parent 4c31b3a commit c7e2305
Show file tree
Hide file tree
Showing 96 changed files with 13,012 additions and 1,727 deletions.
14 changes: 6 additions & 8 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,6 @@ Ref: https://keepachangelog.com/en/1.0.0/
* [\#10507](https://github.com/cosmos/cosmos-sdk/pull/10507) Add middleware for tx priority.
* [\#10311](https://github.com/cosmos/cosmos-sdk/pull/10311) Adds cli to use tips transactions. It adds an `--aux` flag to all CLI tx commands to generate the aux signer data (with optional tip), and a new `tx aux-to-fee` subcommand to let the fee payer gather aux signer data and broadcast the tx

### Improvements

* (deps) [\#10210](https://github.com/cosmos/cosmos-sdk/pull/10210) Bump Tendermint to [v0.35.0](https://github.com/tendermint/tendermint/releases/tag/v0.35.0).
* [\#10486](https://github.com/cosmos/cosmos-sdk/pull/10486) store/cachekv's `Store.Write` conservatively looks up keys, but also uses the [map clearing idiom](https://bencher.orijtech.com/perfclinic/mapclearing/) to reduce the RAM usage, CPU time usage, and garbage collection pressure from clearing maps, instead of allocating new maps.
* (types) [\#10630](https://github.com/cosmos/cosmos-sdk/pull/10630) Add an `Events` field to the `TxResponse` type that captures _all_ events emitted by a transaction, unlike `Logs` which only contains events emitted during message execution.
* (deps) [\#10706](https://github.com/cosmos/cosmos-sdk/issues/10706) Bump rosetta-sdk-go to v0.7.2 and rosetta-cli to v0.7.3
* (module) [\#10711](https://github.com/cosmos/cosmos-sdk/pull/10711) Panic at startup if the app developer forgot to add modules in the `SetOrder{BeginBlocker, EndBlocker, InitGenesis, ExportGenesis}` functions. This means that all modules, even those who have empty implementations for those methods, need to be added to `SetOrder*`.

### API Breaking Changes

* (x/mint) [\#10441](https://github.com/cosmos/cosmos-sdk/pull/10441) The `NewAppModule` function now accepts an inflation calculation function as an argument.
Expand Down Expand Up @@ -119,6 +111,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* [\#10208](https://github.com/cosmos/cosmos-sdk/pull/10208) The `x/auth/signing.Tx` interface now also includes a new `GetTip() *tx.Tip` method for verifying tipped transactions. The `x/auth/types` expected BankKeeper interface now expects the `SendCoins` method too.
* [\#10612](https://github.com/cosmos/cosmos-sdk/pull/10612) `baseapp.NewBaseApp` constructor function doesn't take the `sdk.TxDecoder` anymore. This logic has been moved into the TxDecoderMiddleware.
* [\#10692](https://github.com/cosmos/cosmos-sdk/pull/10612) `SignerData` takes 2 new fields, `Address` and `PubKey`, which need to get populated when using SIGN_MODE_DIRECT_AUX.
* [\#10748](https://github.com/cosmos/cosmos-sdk/pull/10748) Move legacy `x/gov` api to `v1beta1` directory.

### Client Breaking Changes

Expand Down Expand Up @@ -151,6 +144,11 @@ Ref: https://keepachangelog.com/en/1.0.0/
* (cli) [\#10683](https://github.com/cosmos/cosmos-sdk/pull/10683) In CLI, allow 1 SIGN_MODE_DIRECT signer in transactions with multiple signers.
* (x/gov) [\#10740](https://github.com/cosmos/cosmos-sdk/pull/10740) Increase maximum proposal description size from 5k characters to 10k characters.
* (store) [\#10741](https://github.com/cosmos/cosmos-sdk/pull/10741) Significantly speedup iterator creation after delete heavy workloads. Significantly improves IBC migration times.
* (deps) [\#10210](https://github.com/cosmos/cosmos-sdk/pull/10210) Bump Tendermint to [v0.35.0](https://github.com/tendermint/tendermint/releases/tag/v0.35.0).
* [\#10486](https://github.com/cosmos/cosmos-sdk/pull/10486) store/cachekv's `Store.Write` conservatively looks up keys, but also uses the [map clearing idiom](https://bencher.orijtech.com/perfclinic/mapclearing/) to reduce the RAM usage, CPU time usage, and garbage collection pressure from clearing maps, instead of allocating new maps.
* (types) [\#10630](https://github.com/cosmos/cosmos-sdk/pull/10630) Add an `Events` field to the `TxResponse` type that captures _all_ events emitted by a transaction, unlike `Logs` which only contains events emitted during message execution.
* (deps) [\#10706](https://github.com/cosmos/cosmos-sdk/issues/10706) Bump rosetta-sdk-go to v0.7.2 and rosetta-cli to v0.7.3
* (module) [\#10711](https://github.com/cosmos/cosmos-sdk/pull/10711) Panic at startup if the app developer forgot to add modules in the `SetOrder{BeginBlocker, EndBlocker, InitGenesis, ExportGenesis}` functions. This means that all modules, even those who have empty implementations for those methods, need to be added to `SetOrder*`.

### Bug Fixes

Expand Down
2 changes: 1 addition & 1 deletion proto/cosmos/gov/v1beta1/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ package cosmos.gov.v1beta1;
import "gogoproto/gogo.proto";
import "cosmos/gov/v1beta1/gov.proto";

option go_package = "github.com/cosmos/cosmos-sdk/x/gov/types";
option go_package = "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1";

// GenesisState defines the gov module's genesis state.
message GenesisState {
Expand Down
2 changes: 1 addition & 1 deletion proto/cosmos/gov/v1beta1/gov.proto
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import "google/protobuf/any.proto";
import "google/protobuf/duration.proto";
import "cosmos_proto/cosmos.proto";

option go_package = "github.com/cosmos/cosmos-sdk/x/gov/types";
option go_package = "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1";

option (gogoproto.goproto_stringer_all) = false;
option (gogoproto.stringer_all) = false;
Expand Down
2 changes: 1 addition & 1 deletion proto/cosmos/gov/v1beta1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import "google/api/annotations.proto";
import "cosmos/gov/v1beta1/gov.proto";
import "cosmos_proto/cosmos.proto";

option go_package = "github.com/cosmos/cosmos-sdk/x/gov/types";
option go_package = "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1";

// Query defines the gRPC querier service for gov module
service Query {
Expand Down
2 changes: 1 addition & 1 deletion proto/cosmos/gov/v1beta1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import "cosmos_proto/cosmos.proto";
import "gogoproto/gogo.proto";
import "google/protobuf/any.proto";

option go_package = "github.com/cosmos/cosmos-sdk/x/gov/types";
option go_package = "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1";

// Msg defines the bank Msg service.
service Msg {
Expand Down
7 changes: 4 additions & 3 deletions simapp/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ import (
"github.com/cosmos/cosmos-sdk/x/gov"
govkeeper "github.com/cosmos/cosmos-sdk/x/gov/keeper"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
oldgovtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
"github.com/cosmos/cosmos-sdk/x/group"
groupkeeper "github.com/cosmos/cosmos-sdk/x/group/keeper"
groupmodule "github.com/cosmos/cosmos-sdk/x/group/module"
Expand Down Expand Up @@ -295,8 +296,8 @@ func NewSimApp(
app.GroupKeeper = groupkeeper.NewKeeper(keys[group.StoreKey], appCodec, app.msgSvcRouter, app.AccountKeeper)

// register the proposal types
govRouter := govtypes.NewRouter()
govRouter.AddRoute(govtypes.RouterKey, govtypes.ProposalHandler).
govRouter := oldgovtypes.NewRouter()
govRouter.AddRoute(govtypes.RouterKey, oldgovtypes.ProposalHandler).
AddRoute(paramproposal.RouterKey, params.NewParamChangeProposalHandler(app.ParamsKeeper)).
AddRoute(distrtypes.RouterKey, distr.NewCommunityPoolSpendProposalHandler(app.DistrKeeper)).
AddRoute(upgradetypes.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(app.UpgradeKeeper))
Expand Down Expand Up @@ -615,7 +616,7 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
paramsKeeper.Subspace(minttypes.ModuleName)
paramsKeeper.Subspace(distrtypes.ModuleName)
paramsKeeper.Subspace(slashingtypes.ModuleName)
paramsKeeper.Subspace(govtypes.ModuleName).WithKeyTable(govtypes.ParamKeyTable())
paramsKeeper.Subspace(govtypes.ModuleName).WithKeyTable(oldgovtypes.ParamKeyTable())
paramsKeeper.Subspace(crisistypes.ModuleName)

return paramsKeeper
Expand Down
2 changes: 1 addition & 1 deletion x/auth/client/testutil/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import (
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
"github.com/cosmos/cosmos-sdk/x/genutil/client/cli"
govtestutil "github.com/cosmos/cosmos-sdk/x/gov/client/testutil"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
)

type IntegrationTestSuite struct {
Expand Down
2 changes: 1 addition & 1 deletion x/auth/middleware/tips_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/cosmos/cosmos-sdk/types/tx"
"github.com/cosmos/cosmos-sdk/types/tx/signing"
authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
)

Expand Down
2 changes: 1 addition & 1 deletion x/authz/client/testutil/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
bank "github.com/cosmos/cosmos-sdk/x/bank/types"
govcli "github.com/cosmos/cosmos-sdk/x/gov/client/cli"
govtestutil "github.com/cosmos/cosmos-sdk/x/gov/client/testutil"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
stakingcli "github.com/cosmos/cosmos-sdk/x/staking/client/cli"
)

Expand Down
2 changes: 1 addition & 1 deletion x/distribution/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/version"
"github.com/cosmos/cosmos-sdk/x/distribution/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
)

// Transaction flags for the x/distribution module
Expand Down
2 changes: 1 addition & 1 deletion x/distribution/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/x/distribution/keeper"
"github.com/cosmos/cosmos-sdk/x/distribution/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
)

func NewCommunityPoolSpendProposalHandler(k keeper.Keeper) govtypes.Handler {
Expand Down
2 changes: 1 addition & 1 deletion x/distribution/types/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/msgservice"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
)

// RegisterLegacyAminoCodec registers the necessary x/distribution interfaces and concrete types
Expand Down
2 changes: 1 addition & 1 deletion x/distribution/types/proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"strings"

sdk "github.com/cosmos/cosmos-sdk/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion x/feegrant/client/testutil/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"github.com/cosmos/cosmos-sdk/x/feegrant"
"github.com/cosmos/cosmos-sdk/x/feegrant/client/cli"
govtestutil "github.com/cosmos/cosmos-sdk/x/gov/client/testutil"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
)

const (
Expand Down
13 changes: 7 additions & 6 deletions x/gov/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,17 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/gov/keeper"
"github.com/cosmos/cosmos-sdk/x/gov/types"
"github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
)

// EndBlocker called every block, process inflation, update validator set.
func EndBlocker(ctx sdk.Context, keeper keeper.Keeper) {
defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), telemetry.MetricKeyEndBlocker)
defer telemetry.ModuleMeasureSince(v1beta1.ModuleName, time.Now(), telemetry.MetricKeyEndBlocker)

logger := keeper.Logger(ctx)

// delete dead proposals from store and burn theirs deposits. A proposal is dead when it's inactive and didn't get enough deposit on time to get into voting phase.
keeper.IterateInactiveProposalsQueue(ctx, ctx.BlockHeader().Time, func(proposal types.Proposal) bool {
keeper.IterateInactiveProposalsQueue(ctx, ctx.BlockHeader().Time, func(proposal v1beta1.Proposal) bool {
keeper.DeleteProposal(ctx, proposal.ProposalId)
keeper.DeleteAndBurnDeposits(ctx, proposal.ProposalId)

Expand All @@ -44,7 +45,7 @@ func EndBlocker(ctx sdk.Context, keeper keeper.Keeper) {
})

// fetch active proposals whose voting periods have ended (are passed the block time)
keeper.IterateActiveProposalsQueue(ctx, ctx.BlockHeader().Time, func(proposal types.Proposal) bool {
keeper.IterateActiveProposalsQueue(ctx, ctx.BlockHeader().Time, func(proposal v1beta1.Proposal) bool {
var tagValue, logMsg string

passes, burnDeposits, tallyResults := keeper.Tally(ctx, proposal)
Expand All @@ -64,7 +65,7 @@ func EndBlocker(ctx sdk.Context, keeper keeper.Keeper) {
// is written and the error message is logged.
err := handler(cacheCtx, proposal.GetContent())
if err == nil {
proposal.Status = types.StatusPassed
proposal.Status = v1beta1.StatusPassed
tagValue = types.AttributeValueProposalPassed
logMsg = "passed"

Expand All @@ -77,12 +78,12 @@ func EndBlocker(ctx sdk.Context, keeper keeper.Keeper) {
// write state to the underlying multi-store
writeCache()
} else {
proposal.Status = types.StatusFailed
proposal.Status = v1beta1.StatusFailed
tagValue = types.AttributeValueProposalFailed
logMsg = fmt.Sprintf("passed, but failed on execution: %s", err)
}
} else {
proposal.Status = types.StatusRejected
proposal.Status = v1beta1.StatusRejected
tagValue = types.AttributeValueProposalRejected
logMsg = "rejected"
}
Expand Down
33 changes: 17 additions & 16 deletions x/gov/abci_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/cosmos/cosmos-sdk/x/gov"
"github.com/cosmos/cosmos-sdk/x/gov/keeper"
"github.com/cosmos/cosmos-sdk/x/gov/types"
"github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
"github.com/cosmos/cosmos-sdk/x/staking"
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
Expand All @@ -32,8 +33,8 @@ func TestTickExpiredDepositPeriod(t *testing.T) {
require.False(t, inactiveQueue.Valid())
inactiveQueue.Close()

newProposalMsg, err := types.NewMsgSubmitProposal(
types.ContentFromProposalType("test", "test", types.ProposalTypeText),
newProposalMsg, err := v1beta1.NewMsgSubmitProposal(
v1beta1.ContentFromProposalType("test", "test", v1beta1.ProposalTypeText),
sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 5)},
addrs[0],
)
Expand Down Expand Up @@ -84,8 +85,8 @@ func TestTickMultipleExpiredDepositPeriod(t *testing.T) {
require.False(t, inactiveQueue.Valid())
inactiveQueue.Close()

newProposalMsg, err := types.NewMsgSubmitProposal(
types.ContentFromProposalType("test", "test", types.ProposalTypeText),
newProposalMsg, err := v1beta1.NewMsgSubmitProposal(
v1beta1.ContentFromProposalType("test", "test", v1beta1.ProposalTypeText),
sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 5)},
addrs[0],
)
Expand All @@ -107,8 +108,8 @@ func TestTickMultipleExpiredDepositPeriod(t *testing.T) {
require.False(t, inactiveQueue.Valid())
inactiveQueue.Close()

newProposalMsg2, err := types.NewMsgSubmitProposal(
types.ContentFromProposalType("test2", "test2", types.ProposalTypeText),
newProposalMsg2, err := v1beta1.NewMsgSubmitProposal(
v1beta1.ContentFromProposalType("test2", "test2", v1beta1.ProposalTypeText),
sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 5)},
addrs[0],
)
Expand Down Expand Up @@ -164,8 +165,8 @@ func TestTickPassedDepositPeriod(t *testing.T) {
require.False(t, activeQueue.Valid())
activeQueue.Close()

newProposalMsg, err := types.NewMsgSubmitProposal(
types.ContentFromProposalType("test2", "test2", types.ProposalTypeText),
newProposalMsg, err := v1beta1.NewMsgSubmitProposal(
v1beta1.ContentFromProposalType("test2", "test2", v1beta1.ProposalTypeText),
sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 5)},
addrs[0],
)
Expand All @@ -189,7 +190,7 @@ func TestTickPassedDepositPeriod(t *testing.T) {
require.False(t, inactiveQueue.Valid())
inactiveQueue.Close()

newDepositMsg := types.NewMsgDeposit(addrs[1], proposalID, sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 5)})
newDepositMsg := v1beta1.NewMsgDeposit(addrs[1], proposalID, sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 5)})

res1, err := govMsgSvr.Deposit(sdk.WrapSDKContext(ctx), newDepositMsg)
require.NoError(t, err)
Expand Down Expand Up @@ -220,7 +221,7 @@ func TestTickPassedVotingPeriod(t *testing.T) {
activeQueue.Close()

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

wrapCtx := sdk.WrapSDKContext(ctx)
Expand All @@ -235,7 +236,7 @@ func TestTickPassedVotingPeriod(t *testing.T) {
newHeader.Time = ctx.BlockHeader().Time.Add(time.Duration(1) * time.Second)
ctx = ctx.WithBlockHeader(newHeader)

newDepositMsg := types.NewMsgDeposit(addrs[1], proposalID, proposalCoins)
newDepositMsg := v1beta1.NewMsgDeposit(addrs[1], proposalID, proposalCoins)

res1, err := govMsgSvr.Deposit(wrapCtx, newDepositMsg)
require.NoError(t, err)
Expand All @@ -255,7 +256,7 @@ func TestTickPassedVotingPeriod(t *testing.T) {
activeProposalID := types.GetProposalIDFromBytes(activeQueue.Value())
proposal, ok := app.GovKeeper.GetProposal(ctx, activeProposalID)
require.True(t, ok)
require.Equal(t, types.StatusVotingPeriod, proposal.Status)
require.Equal(t, v1beta1.StatusVotingPeriod, proposal.Status)

activeQueue.Close()

Expand Down Expand Up @@ -292,7 +293,7 @@ func TestProposalPassedEndblocker(t *testing.T) {
require.NoError(t, err)

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

res, err := govMsgSvr.Deposit(sdk.WrapSDKContext(ctx), newDepositMsg)
require.NoError(t, err)
Expand All @@ -305,7 +306,7 @@ func TestProposalPassedEndblocker(t *testing.T) {
deposits := initialModuleAccCoins.Add(proposal.TotalDeposit...).Add(proposalCoins...)
require.True(t, moduleAccCoins.IsEqual(deposits))

err = app.GovKeeper.AddVote(ctx, proposal.ProposalId, addrs[0], types.NewNonSplitVoteOption(types.OptionYes))
err = app.GovKeeper.AddVote(ctx, proposal.ProposalId, addrs[0], v1beta1.NewNonSplitVoteOption(v1beta1.OptionYes))
require.NoError(t, err)

newHeader := ctx.BlockHeader()
Expand Down Expand Up @@ -342,14 +343,14 @@ func TestEndBlockerProposalHandlerFailed(t *testing.T) {
require.NoError(t, err)

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

govMsgSvr := keeper.NewMsgServerImpl(app.GovKeeper)
res, err := govMsgSvr.Deposit(sdk.WrapSDKContext(ctx), newDepositMsg)
require.NoError(t, err)
require.NotNil(t, res)

err = app.GovKeeper.AddVote(ctx, proposal.ProposalId, addrs[0], types.NewNonSplitVoteOption(types.OptionYes))
err = app.GovKeeper.AddVote(ctx, proposal.ProposalId, addrs[0], v1beta1.NewNonSplitVoteOption(v1beta1.OptionYes))
require.NoError(t, err)

newHeader := ctx.BlockHeader()
Expand Down
Loading

0 comments on commit c7e2305

Please sign in to comment.