Skip to content

Commit

Permalink
test(x/gov): assert EndBlocker decrements ActiveProposalNumber
Browse files Browse the repository at this point in the history
  • Loading branch information
tbruyelle committed Dec 20, 2024
1 parent c043895 commit fa0d021
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions x/gov/abci_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ func TestTickPassedVotingPeriod(t *testing.T) {
activeQueue = suite.GovKeeper.ActiveProposalQueueIterator(ctx, ctx.BlockHeader().Time)
require.True(t, activeQueue.Valid())

require.EqualValues(t, 1, suite.GovKeeper.GetActiveProposalsNumber(ctx))
activeProposalID := types.GetProposalIDFromBytes(activeQueue.Value())
proposal, ok := suite.GovKeeper.GetProposal(ctx, activeProposalID)
require.True(t, ok)
Expand All @@ -285,6 +286,7 @@ func TestTickPassedVotingPeriod(t *testing.T) {

gov.EndBlocker(ctx, suite.GovKeeper)

require.EqualValues(t, 0, suite.GovKeeper.GetActiveProposalsNumber(ctx))
activeQueue = suite.GovKeeper.ActiveProposalQueueIterator(ctx, ctx.BlockHeader().Time)
require.False(t, activeQueue.Valid())
activeQueue.Close()
Expand Down Expand Up @@ -379,10 +381,12 @@ func TestEndBlockerProposalHandlerFailed(t *testing.T) {
newHeader := ctx.BlockHeader()
newHeader.Time = ctx.BlockHeader().Time.Add(*suite.GovKeeper.GetParams(ctx).MaxDepositPeriod).Add(*suite.GovKeeper.GetParams(ctx).VotingPeriod)
ctx = ctx.WithBlockHeader(newHeader)
require.EqualValues(t, 1, suite.GovKeeper.GetActiveProposalsNumber(ctx))

// validate that the proposal fails/has been rejected
gov.EndBlocker(ctx, suite.GovKeeper)

require.EqualValues(t, 0, suite.GovKeeper.GetActiveProposalsNumber(ctx))
proposal, ok := suite.GovKeeper.GetProposal(ctx, proposal.Id)
require.True(t, ok)
require.Equal(t, v1.StatusFailed, proposal.Status)
Expand Down

0 comments on commit fa0d021

Please sign in to comment.