Skip to content

Commit

Permalink
migrate TestTallyOnlyValidatorsNonVoter to simapp
Browse files Browse the repository at this point in the history
  • Loading branch information
jgimeno committed Mar 2, 2020
1 parent 759181c commit 46a70d5
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 23 deletions.
23 changes: 0 additions & 23 deletions x/gov/keeper/old_tally_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,6 @@ import (
"github.com/cosmos/cosmos-sdk/x/staking"
)

func TestTallyOnlyValidatorsNonVoter(t *testing.T) {
ctx, _, _, keeper, sk, _ := createTestInput(t, false, 100)
createValidators(ctx, sk, []int64{5, 6, 7})

tp := TestProposal
proposal, err := keeper.SubmitProposal(ctx, tp)
require.NoError(t, err)
proposalID := proposal.ProposalID
proposal.Status = types.StatusVotingPeriod
keeper.SetProposal(ctx, proposal)

require.NoError(t, keeper.AddVote(ctx, proposalID, valAccAddr1, types.OptionYes))
require.NoError(t, keeper.AddVote(ctx, proposalID, valAccAddr2, types.OptionNo))

proposal, ok := keeper.GetProposal(ctx, proposalID)
require.True(t, ok)
passes, burnDeposits, tallyResults := keeper.Tally(ctx, proposal)

require.False(t, passes)
require.False(t, burnDeposits)
require.False(t, tallyResults.Equals(types.EmptyTallyResult()))
}

func TestTallyDelgatorOverride(t *testing.T) {
ctx, _, _, keeper, sk, _ := createTestInput(t, false, 100)
createValidators(ctx, sk, []int64{5, 6, 7})
Expand Down
26 changes: 26 additions & 0 deletions x/gov/keeper/tally_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,3 +212,29 @@ func TestTallyOnlyValidatorsAbstainFails(t *testing.T) {
require.False(t, burnDeposits)
require.False(t, tallyResults.Equals(types.EmptyTallyResult()))
}

func TestTallyOnlyValidatorsNonVoter(t *testing.T) {
app := simapp.Setup(false)
ctx := app.BaseApp.NewContext(false, abci.Header{})

valAccAddrs, _ := createValidators(ctx, app, []int64{5, 6, 7})
valAccAddr1, valAccAddr2 := valAccAddrs[0], valAccAddrs[1]

tp := TestProposal
proposal, err := app.GovKeeper.SubmitProposal(ctx, tp)
require.NoError(t, err)
proposalID := proposal.ProposalID
proposal.Status = types.StatusVotingPeriod
app.GovKeeper.SetProposal(ctx, proposal)

require.NoError(t, app.GovKeeper.AddVote(ctx, proposalID, valAccAddr1, types.OptionYes))
require.NoError(t, app.GovKeeper.AddVote(ctx, proposalID, valAccAddr2, types.OptionNo))

proposal, ok := app.GovKeeper.GetProposal(ctx, proposalID)
require.True(t, ok)
passes, burnDeposits, tallyResults := app.GovKeeper.Tally(ctx, proposal)

require.False(t, passes)
require.False(t, burnDeposits)
require.False(t, tallyResults.Equals(types.EmptyTallyResult()))
}

0 comments on commit 46a70d5

Please sign in to comment.