Skip to content

Commit

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

func TestTallyOnlyValidatorsAbstainPasses(t *testing.T) {
ctx, _, _, keeper, sk, _ := createTestInput(t, false, 100)
createValidators(ctx, sk, []int64{6, 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.OptionAbstain))
require.NoError(t, keeper.AddVote(ctx, proposalID, valAccAddr2, types.OptionNo))
require.NoError(t, keeper.AddVote(ctx, proposalID, valAccAddr3, types.OptionYes))

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

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

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

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

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

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.OptionAbstain))
require.NoError(t, app.GovKeeper.AddVote(ctx, proposalID, valAccAddr2, types.OptionNo))
require.NoError(t, app.GovKeeper.AddVote(ctx, proposalID, valAccAddr3, types.OptionYes))

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

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

0 comments on commit b83755f

Please sign in to comment.