Skip to content

Commit

Permalink
refactor(gov): simplify state management (#19349)
Browse files Browse the repository at this point in the history
  • Loading branch information
julienrbrt authored Feb 9, 2024
1 parent e15a0de commit e4fabeb
Show file tree
Hide file tree
Showing 20 changed files with 90 additions and 133 deletions.
4 changes: 2 additions & 2 deletions tests/integration/gov/abci_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func TestUnregisteredProposal_InactiveProposalFails(t *testing.T) {
}, 1, startTime, startTime, "", "Unsupported proposal", "Unsupported proposal", addrs[0], v1.ProposalType_PROPOSAL_TYPE_STANDARD)
require.NoError(t, err)

err = suite.GovKeeper.SetProposal(ctx, proposal)
err = suite.GovKeeper.Proposals.Set(ctx, proposal.Id, proposal)
require.NoError(t, err)

// manually set proposal in inactive proposal queue
Expand Down Expand Up @@ -62,7 +62,7 @@ func TestUnregisteredProposal_ActiveProposalFails(t *testing.T) {
proposal.Status = v1.StatusVotingPeriod
proposal.VotingEndTime = &endTime

err = suite.GovKeeper.SetProposal(ctx, proposal)
err = suite.GovKeeper.Proposals.Set(ctx, proposal.Id, proposal)
require.NoError(t, err)

// manually set proposal in active proposal queue
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/gov/keeper/grpc_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func TestLegacyGRPCQueryTally(t *testing.T) {
proposal, err := f.govKeeper.SubmitProposal(ctx, TestProposal, "", "test", "description", addrs[0], v1.ProposalType_PROPOSAL_TYPE_STANDARD)
assert.NilError(t, err)
proposal.Status = v1.StatusVotingPeriod
err = f.govKeeper.SetProposal(ctx, proposal)
err = f.govKeeper.Proposals.Set(ctx, proposal.Id, proposal)
assert.NilError(t, err)
assert.NilError(t, f.govKeeper.AddVote(ctx, proposal.Id, addrs[0], v1.NewNonSplitVoteOption(v1.OptionYes), ""))
assert.NilError(t, f.govKeeper.AddVote(ctx, proposal.Id, addrs[1], v1.NewNonSplitVoteOption(v1.OptionYes), ""))
Expand Down
30 changes: 15 additions & 15 deletions tests/integration/gov/keeper/tally_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func TestTallyNoOneVotes(t *testing.T) {
assert.NilError(t, err)
proposalID := proposal.Id
proposal.Status = v1.StatusVotingPeriod
err = f.govKeeper.SetProposal(ctx, proposal)
err = f.govKeeper.Proposals.Set(ctx, proposal.Id, proposal)
assert.NilError(t, err)
proposal, ok := f.govKeeper.Proposals.Get(ctx, proposalID)
assert.Assert(t, ok)
Expand All @@ -53,7 +53,7 @@ func TestTallyNoQuorum(t *testing.T) {
assert.NilError(t, err)
proposalID := proposal.Id
proposal.Status = v1.StatusVotingPeriod
err = f.govKeeper.SetProposal(ctx, proposal)
err = f.govKeeper.Proposals.Set(ctx, proposal.Id, proposal)
assert.NilError(t, err)
err = f.govKeeper.AddVote(ctx, proposalID, addrs[0], v1.NewNonSplitVoteOption(v1.OptionYes), "")
assert.NilError(t, err)
Expand All @@ -79,7 +79,7 @@ func TestTallyOnlyValidatorsAllYes(t *testing.T) {
assert.NilError(t, err)
proposalID := proposal.Id
proposal.Status = v1.StatusVotingPeriod
err = f.govKeeper.SetProposal(ctx, proposal)
err = f.govKeeper.Proposals.Set(ctx, proposal.Id, proposal)
assert.NilError(t, err)
assert.NilError(t, f.govKeeper.AddVote(ctx, proposalID, addrs[0], v1.NewNonSplitVoteOption(v1.OptionYes), ""))
assert.NilError(t, f.govKeeper.AddVote(ctx, proposalID, addrs[1], v1.NewNonSplitVoteOption(v1.OptionYes), ""))
Expand Down Expand Up @@ -108,7 +108,7 @@ func TestTallyOnlyValidators51No(t *testing.T) {
assert.NilError(t, err)
proposalID := proposal.Id
proposal.Status = v1.StatusVotingPeriod
err = f.govKeeper.SetProposal(ctx, proposal)
err = f.govKeeper.Proposals.Set(ctx, proposal.Id, proposal)
assert.NilError(t, err)
assert.NilError(t, f.govKeeper.AddVote(ctx, proposalID, valAccAddrs[0], v1.NewNonSplitVoteOption(v1.OptionYes), ""))
assert.NilError(t, f.govKeeper.AddVote(ctx, proposalID, valAccAddrs[1], v1.NewNonSplitVoteOption(v1.OptionNo), ""))
Expand All @@ -135,7 +135,7 @@ func TestTallyOnlyValidators51Yes(t *testing.T) {
assert.NilError(t, err)
proposalID := proposal.Id
proposal.Status = v1.StatusVotingPeriod
err = f.govKeeper.SetProposal(ctx, proposal)
err = f.govKeeper.Proposals.Set(ctx, proposal.Id, proposal)
assert.NilError(t, err)
assert.NilError(t, f.govKeeper.AddVote(ctx, proposalID, valAccAddrs[0], v1.NewNonSplitVoteOption(v1.OptionNo), ""))
assert.NilError(t, f.govKeeper.AddVote(ctx, proposalID, valAccAddrs[1], v1.NewNonSplitVoteOption(v1.OptionYes), ""))
Expand Down Expand Up @@ -163,7 +163,7 @@ func TestTallyOnlyValidatorsVetoed(t *testing.T) {
assert.NilError(t, err)
proposalID := proposal.Id
proposal.Status = v1.StatusVotingPeriod
err = f.govKeeper.SetProposal(ctx, proposal)
err = f.govKeeper.Proposals.Set(ctx, proposal.Id, proposal)
assert.NilError(t, err)
assert.NilError(t, f.govKeeper.AddVote(ctx, proposalID, valAccAddrs[0], v1.NewNonSplitVoteOption(v1.OptionYes), ""))
assert.NilError(t, f.govKeeper.AddVote(ctx, proposalID, valAccAddrs[1], v1.NewNonSplitVoteOption(v1.OptionYes), ""))
Expand Down Expand Up @@ -192,7 +192,7 @@ func TestTallyOnlyValidatorsAbstainPasses(t *testing.T) {
assert.NilError(t, err)
proposalID := proposal.Id
proposal.Status = v1.StatusVotingPeriod
err = f.govKeeper.SetProposal(ctx, proposal)
err = f.govKeeper.Proposals.Set(ctx, proposal.Id, proposal)
assert.NilError(t, err)
assert.NilError(t, f.govKeeper.AddVote(ctx, proposalID, valAccAddrs[0], v1.NewNonSplitVoteOption(v1.OptionAbstain), ""))
assert.NilError(t, f.govKeeper.AddVote(ctx, proposalID, valAccAddrs[1], v1.NewNonSplitVoteOption(v1.OptionNo), ""))
Expand Down Expand Up @@ -221,7 +221,7 @@ func TestTallyOnlyValidatorsAbstainFails(t *testing.T) {
assert.NilError(t, err)
proposalID := proposal.Id
proposal.Status = v1.StatusVotingPeriod
err = f.govKeeper.SetProposal(ctx, proposal)
err = f.govKeeper.Proposals.Set(ctx, proposal.Id, proposal)
assert.NilError(t, err)
assert.NilError(t, f.govKeeper.AddVote(ctx, proposalID, valAccAddrs[0], v1.NewNonSplitVoteOption(v1.OptionAbstain), ""))
assert.NilError(t, f.govKeeper.AddVote(ctx, proposalID, valAccAddrs[1], v1.NewNonSplitVoteOption(v1.OptionYes), ""))
Expand Down Expand Up @@ -251,7 +251,7 @@ func TestTallyOnlyValidatorsNonVoter(t *testing.T) {
assert.NilError(t, err)
proposalID := proposal.Id
proposal.Status = v1.StatusVotingPeriod
err = f.govKeeper.SetProposal(ctx, proposal)
err = f.govKeeper.Proposals.Set(ctx, proposal.Id, proposal)
assert.NilError(t, err)
assert.NilError(t, f.govKeeper.AddVote(ctx, proposalID, valAccAddr1, v1.NewNonSplitVoteOption(v1.OptionYes), ""))
assert.NilError(t, f.govKeeper.AddVote(ctx, proposalID, valAccAddr2, v1.NewNonSplitVoteOption(v1.OptionNo), ""))
Expand Down Expand Up @@ -288,7 +288,7 @@ func TestTallyDelgatorOverride(t *testing.T) {
assert.NilError(t, err)
proposalID := proposal.Id
proposal.Status = v1.StatusVotingPeriod
err = f.govKeeper.SetProposal(ctx, proposal)
err = f.govKeeper.Proposals.Set(ctx, proposal.Id, proposal)
assert.NilError(t, err)
assert.NilError(t, f.govKeeper.AddVote(ctx, proposalID, addrs[1], v1.NewNonSplitVoteOption(v1.OptionYes), ""))
assert.NilError(t, f.govKeeper.AddVote(ctx, proposalID, addrs[2], v1.NewNonSplitVoteOption(v1.OptionYes), ""))
Expand Down Expand Up @@ -327,7 +327,7 @@ func TestTallyDelgatorInherit(t *testing.T) {
assert.NilError(t, err)
proposalID := proposal.Id
proposal.Status = v1.StatusVotingPeriod
err = f.govKeeper.SetProposal(ctx, proposal)
err = f.govKeeper.Proposals.Set(ctx, proposal.Id, proposal)
assert.NilError(t, err)
assert.NilError(t, f.govKeeper.AddVote(ctx, proposalID, addrs[0], v1.NewNonSplitVoteOption(v1.OptionNo), ""))
assert.NilError(t, f.govKeeper.AddVote(ctx, proposalID, addrs[1], v1.NewNonSplitVoteOption(v1.OptionNo), ""))
Expand Down Expand Up @@ -369,7 +369,7 @@ func TestTallyDelgatorMultipleOverride(t *testing.T) {
assert.NilError(t, err)
proposalID := proposal.Id
proposal.Status = v1.StatusVotingPeriod
err = f.govKeeper.SetProposal(ctx, proposal)
err = f.govKeeper.Proposals.Set(ctx, proposal.Id, proposal)
assert.NilError(t, err)
assert.NilError(t, f.govKeeper.AddVote(ctx, proposalID, addrs[0], v1.NewNonSplitVoteOption(v1.OptionYes), ""))
assert.NilError(t, f.govKeeper.AddVote(ctx, proposalID, addrs[1], v1.NewNonSplitVoteOption(v1.OptionYes), ""))
Expand Down Expand Up @@ -414,7 +414,7 @@ func TestTallyDelgatorMultipleInherit(t *testing.T) {
assert.NilError(t, err)
proposalID := proposal.Id
proposal.Status = v1.StatusVotingPeriod
err = f.govKeeper.SetProposal(ctx, proposal)
err = f.govKeeper.Proposals.Set(ctx, proposal.Id, proposal)
assert.NilError(t, err)
assert.NilError(t, f.govKeeper.AddVote(ctx, proposalID, addrs[0], v1.NewNonSplitVoteOption(v1.OptionYes), ""))
assert.NilError(t, f.govKeeper.AddVote(ctx, proposalID, addrs[1], v1.NewNonSplitVoteOption(v1.OptionNo), ""))
Expand Down Expand Up @@ -460,7 +460,7 @@ func TestTallyJailedValidator(t *testing.T) {
assert.NilError(t, err)
proposalID := proposal.Id
proposal.Status = v1.StatusVotingPeriod
err = f.govKeeper.SetProposal(ctx, proposal)
err = f.govKeeper.Proposals.Set(ctx, proposal.Id, proposal)
assert.NilError(t, err)
assert.NilError(t, f.govKeeper.AddVote(ctx, proposalID, addrs[0], v1.NewNonSplitVoteOption(v1.OptionYes), ""))
assert.NilError(t, f.govKeeper.AddVote(ctx, proposalID, addrs[1], v1.NewNonSplitVoteOption(v1.OptionNo), ""))
Expand Down Expand Up @@ -496,7 +496,7 @@ func TestTallyValidatorMultipleDelegations(t *testing.T) {
assert.NilError(t, err)
proposalID := proposal.Id
proposal.Status = v1.StatusVotingPeriod
err = f.govKeeper.SetProposal(ctx, proposal)
err = f.govKeeper.Proposals.Set(ctx, proposal.Id, proposal)
assert.NilError(t, err)
assert.NilError(t, f.govKeeper.AddVote(ctx, proposalID, addrs[0], v1.NewNonSplitVoteOption(v1.OptionYes), ""))
assert.NilError(t, f.govKeeper.AddVote(ctx, proposalID, addrs[1], v1.NewNonSplitVoteOption(v1.OptionNo), ""))
Expand Down
4 changes: 2 additions & 2 deletions tests/sims/gov/operations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ func TestSimulateMsgCancelProposal(t *testing.T) {
proposal, err := v1.NewProposal([]sdk.Msg{contentMsg}, 1, submitTime, submitTime.Add(*depositPeriod), "", "title", "summary", proposer, v1.ProposalType_PROPOSAL_TYPE_STANDARD)
require.NoError(t, err)

err = suite.GovKeeper.SetProposal(ctx, proposal)
err = suite.GovKeeper.Proposals.Set(ctx, proposal.Id, proposal)
require.NoError(t, err)

// execute operation
Expand Down Expand Up @@ -261,7 +261,7 @@ func TestSimulateMsgDeposit(t *testing.T) {
proposal, err := v1.NewProposal([]sdk.Msg{contentMsg}, 1, submitTime, submitTime.Add(*depositPeriod), "", "text proposal", "description", sdk.AccAddress("cosmos1ghekyjucln7y67ntx7cf27m9dpuxxemn4c8g4r"), v1.ProposalType_PROPOSAL_TYPE_STANDARD)
require.NoError(t, err)

err = suite.GovKeeper.SetProposal(ctx, proposal)
err = suite.GovKeeper.Proposals.Set(ctx, proposal.Id, proposal)
require.NoError(t, err)

// execute operation
Expand Down
1 change: 1 addition & 0 deletions x/gov/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ Ref: https://keepachangelog.com/en/1.0.0/

### API Breaking Changes

* [#19349](https://github.com/cosmos/cosmos-sdk/pull/19349) Simplify state management in `x/gov`. Note `k.VotingPeriodProposals` and `k.SetProposal` are no longer needed and have been removed.
* [#18532](https://github.com/cosmos/cosmos-sdk/pull/18532) All functions that were taking an expedited bool parameter now take a `ProposalType` parameter instead.
* [#17496](https://github.com/cosmos/cosmos-sdk/pull/17496) in `x/gov/types/v1beta1/vote.go` `NewVote` was removed, constructing the struct is required for this type.
* [#19101](https://github.com/cosmos/cosmos-sdk/pull/19101) Move `QueryProposalVotesParams` and `QueryVoteParams` from the `types/v1` package to `utils` and remove unused `querier.go` file.
Expand Down
2 changes: 0 additions & 2 deletions x/gov/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -433,8 +433,6 @@ We will use one KVStore `Governance` to store four mappings:
doing a range query on `proposalID:addresses`.
* A mapping from `ParamsKey|'Params'` to `Params`. This map allows to query all
x/gov params.
* A mapping from `VotingPeriodProposalKeyPrefix|proposalID` to a single byte. This allows
us to know if a proposal is in the voting period or not with very low gas cost.

For pseudocode purposes, here are the two function we will use to read or write in stores:

Expand Down
5 changes: 2 additions & 3 deletions x/gov/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,7 @@ func EndBlocker(ctx sdk.Context, keeper *keeper.Keeper) error {

proposal.FinalTallyResult = &tallyResults

err = keeper.SetProposal(ctx, proposal)
if err != nil {
if err = keeper.Proposals.Set(ctx, proposal.Id, proposal); err != nil {
return false, err
}

Expand Down Expand Up @@ -307,7 +306,7 @@ func failUnsupportedProposal(
proposal.FailedReason = fmt.Sprintf("proposal failed because it cannot be processed by gov: %s", errMsg)
proposal.Messages = nil // clear out the messages

if err := keeper.SetProposal(ctx, proposal); err != nil {
if err := keeper.Proposals.Set(ctx, proposal.Id, proposal); err != nil {
return err
}

Expand Down
3 changes: 1 addition & 2 deletions x/gov/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ func InitGenesis(ctx context.Context, ak types.AccountKeeper, bk types.BankKeepe
panic(err)
}
}
err := k.SetProposal(ctx, *proposal)
if err != nil {
if err := k.Proposals.Set(ctx, proposal.Id, *proposal); err != nil {
panic(err)
}
}
Expand Down
3 changes: 1 addition & 2 deletions x/gov/keeper/deposit.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,7 @@ func (k Keeper) AddDeposit(ctx context.Context, proposalID uint64, depositorAddr

// Update proposal
proposal.TotalDeposit = sdk.NewCoins(proposal.TotalDeposit...).Add(depositAmount...)
err = k.SetProposal(ctx, proposal)
if err != nil {
if err = k.Proposals.Set(ctx, proposal.Id, proposal); err != nil {
return false, err
}

Expand Down
32 changes: 16 additions & 16 deletions x/gov/keeper/grpc_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ func (suite *KeeperTestSuite) TestGRPCQueryProposals() {
"request with filter of deposit address",
func() {
testProposals[1].Status = v1.StatusVotingPeriod
err := suite.govKeeper.SetProposal(ctx, *testProposals[1])
err := suite.govKeeper.Proposals.Set(ctx, testProposals[1].Id, *testProposals[1])
suite.Require().NoError(err)
suite.Require().NoError(suite.govKeeper.AddVote(ctx, testProposals[1].Id, addrs[0], v1.NewNonSplitVoteOption(v1.OptionAbstain), ""))

Expand Down Expand Up @@ -520,7 +520,7 @@ func (suite *KeeperTestSuite) TestGRPCQueryVote() {
"valid request",
func() {
proposal.Status = v1.StatusVotingPeriod
err := suite.govKeeper.SetProposal(ctx, proposal)
err := suite.govKeeper.Proposals.Set(suite.ctx, proposal.Id, proposal)
suite.Require().NoError(err)
suite.Require().NoError(suite.govKeeper.AddVote(ctx, proposal.Id, addrs[0], v1.NewNonSplitVoteOption(v1.OptionAbstain), ""))

Expand Down Expand Up @@ -637,7 +637,7 @@ func (suite *KeeperTestSuite) TestLegacyGRPCQueryVote() {
"valid request",
func() {
proposal.Status = v1.StatusVotingPeriod
err := suite.govKeeper.SetProposal(ctx, proposal)
err := suite.govKeeper.Proposals.Set(suite.ctx, proposal.Id, proposal)
suite.Require().NoError(err)
suite.Require().NoError(suite.govKeeper.AddVote(ctx, proposal.Id, addrs[0], v1.NewNonSplitVoteOption(v1.OptionAbstain), ""))

Expand Down Expand Up @@ -743,7 +743,7 @@ func (suite *KeeperTestSuite) TestGRPCQueryVotes() {
"request after adding 2 votes",
func() {
proposal.Status = v1.StatusVotingPeriod
err := suite.govKeeper.SetProposal(ctx, proposal)
err := suite.govKeeper.Proposals.Set(suite.ctx, proposal.Id, proposal)
suite.Require().NoError(err)
votes = []*v1.Vote{
{ProposalId: proposal.Id, Voter: addrs[0].String(), Options: v1.NewNonSplitVoteOption(v1.OptionAbstain)},
Expand Down Expand Up @@ -849,7 +849,7 @@ func (suite *KeeperTestSuite) TestLegacyGRPCQueryVotes() {
"request after adding 2 votes",
func() {
proposal.Status = v1.StatusVotingPeriod
err := suite.govKeeper.SetProposal(ctx, proposal)
err := suite.govKeeper.Proposals.Set(suite.ctx, proposal.Id, proposal)
suite.Require().NoError(err)

votes = []v1beta1.Vote{
Expand Down Expand Up @@ -1503,7 +1503,7 @@ func (suite *KeeperTestSuite) TestLegacyGRPCQueryDeposits() {

func (suite *KeeperTestSuite) TestGRPCQueryTallyResult() {
suite.reset()
ctx, queryClient := suite.ctx, suite.queryClient
queryClient := suite.queryClient

var (
req *v1.QueryTallyResultRequest
Expand Down Expand Up @@ -1559,7 +1559,7 @@ func (suite *KeeperTestSuite) TestGRPCQueryTallyResult() {
VotingEndTime: &propTime,
Metadata: "proposal metadata",
}
err := suite.govKeeper.SetProposal(ctx, proposal)
err := suite.govKeeper.Proposals.Set(suite.ctx, proposal.Id, proposal)
suite.Require().NoError(err)

req = &v1.QueryTallyResultRequest{ProposalId: proposal.Id}
Expand Down Expand Up @@ -1590,7 +1590,7 @@ func (suite *KeeperTestSuite) TestGRPCQueryTallyResult() {
VotingEndTime: &propTime,
Metadata: "proposal metadata",
}
err := suite.govKeeper.SetProposal(ctx, proposal)
err := suite.govKeeper.Proposals.Set(suite.ctx, proposal.Id, proposal)
suite.Require().NoError(err)

req = &v1.QueryTallyResultRequest{ProposalId: proposal.Id}
Expand Down Expand Up @@ -1621,7 +1621,7 @@ func (suite *KeeperTestSuite) TestGRPCQueryTallyResult() {
VotingEndTime: &propTime,
Metadata: "proposal metadata",
}
err := suite.govKeeper.SetProposal(ctx, proposal)
err := suite.govKeeper.Proposals.Set(suite.ctx, proposal.Id, proposal)
suite.Require().NoError(err)

req = &v1.QueryTallyResultRequest{ProposalId: proposal.Id}
Expand Down Expand Up @@ -1664,7 +1664,7 @@ func (suite *KeeperTestSuite) TestGRPCQueryTallyResult() {

func (suite *KeeperTestSuite) TestLegacyGRPCQueryTallyResult() {
suite.reset()
ctx, queryClient := suite.ctx, suite.legacyQueryClient
queryClient := suite.legacyQueryClient

var (
req *v1beta1.QueryTallyResultRequest
Expand Down Expand Up @@ -1716,7 +1716,7 @@ func (suite *KeeperTestSuite) TestLegacyGRPCQueryTallyResult() {
VotingEndTime: &propTime,
Metadata: "proposal metadata",
}
err := suite.govKeeper.SetProposal(ctx, proposal)
err := suite.govKeeper.Proposals.Set(suite.ctx, proposal.Id, proposal)
suite.Require().NoError(err)

req = &v1beta1.QueryTallyResultRequest{ProposalId: proposal.Id}
Expand All @@ -1742,7 +1742,7 @@ func (suite *KeeperTestSuite) TestLegacyGRPCQueryTallyResult() {
VotingEndTime: &propTime,
Metadata: "proposal metadata",
}
err := suite.govKeeper.SetProposal(ctx, proposal)
err := suite.govKeeper.Proposals.Set(suite.ctx, proposal.Id, proposal)
suite.Require().NoError(err)

req = &v1beta1.QueryTallyResultRequest{ProposalId: proposal.Id}
Expand All @@ -1768,7 +1768,7 @@ func (suite *KeeperTestSuite) TestLegacyGRPCQueryTallyResult() {
VotingEndTime: &propTime,
Metadata: "proposal metadata",
}
err := suite.govKeeper.SetProposal(ctx, proposal)
err := suite.govKeeper.Proposals.Set(suite.ctx, proposal.Id, proposal)
suite.Require().NoError(err)
req = &v1beta1.QueryTallyResultRequest{ProposalId: proposal.Id}

Expand Down Expand Up @@ -1836,7 +1836,7 @@ func (suite *KeeperTestSuite) TestProposalVoteOptions() {
Metadata: "proposal metadata",
ProposalType: v1.ProposalType_PROPOSAL_TYPE_STANDARD,
}
err := suite.govKeeper.SetProposal(suite.ctx, proposal)
err := suite.govKeeper.Proposals.Set(suite.ctx, proposal.Id, proposal)
suite.Require().NoError(err)
},
req: &v1.QueryProposalVoteOptionsRequest{ProposalId: 1},
Expand Down Expand Up @@ -1864,7 +1864,7 @@ func (suite *KeeperTestSuite) TestProposalVoteOptions() {
Metadata: "proposal metadata",
ProposalType: v1.ProposalType_PROPOSAL_TYPE_MULTIPLE_CHOICE,
}
err := suite.govKeeper.SetProposal(suite.ctx, proposal)
err := suite.govKeeper.Proposals.Set(suite.ctx, proposal.Id, proposal)
suite.Require().NoError(err)

// multiple choice proposal, but no vote options set
Expand Down Expand Up @@ -1895,7 +1895,7 @@ func (suite *KeeperTestSuite) TestProposalVoteOptions() {
Metadata: "proposal metadata",
ProposalType: v1.ProposalType_PROPOSAL_TYPE_MULTIPLE_CHOICE,
}
err := suite.govKeeper.SetProposal(suite.ctx, proposal)
err := suite.govKeeper.Proposals.Set(suite.ctx, proposal.Id, proposal)
suite.Require().NoError(err)
err = suite.govKeeper.ProposalVoteOptions.Set(suite.ctx, proposal.Id, v1.ProposalVoteOptions{
OptionOne: "Vote for @tac0turle",
Expand Down
Loading

0 comments on commit e4fabeb

Please sign in to comment.