diff --git a/CHANGELOG.md b/CHANGELOG.md index 4cbb973ea6..590e0d2ff5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -64,6 +64,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (client) [\#1303](https://github.com/Finschia/finschia-sdk/pull/1303) fix possible overflow in BuildUnsignedTx * (types) [\#1299](https://github.com/Finschia/finschia-sdk/pull/1299) add missing nil checks * (x/staking) [\#1301](https://github.com/Finschia/finschia-sdk/pull/1301) Use bytes instead of string comparison in delete validator queue (backport cosmos/cosmos-sdk#12303) +* (x/gov) [\#1304](https://github.com/Finschia/finschia-sdk/pull/1304) fetch a failed proposal tally from proposal.FinalTallyResult in the gprc query ### Removed diff --git a/x/gov/keeper/grpc_query.go b/x/gov/keeper/grpc_query.go index 80a86cab85..226f4221e6 100644 --- a/x/gov/keeper/grpc_query.go +++ b/x/gov/keeper/grpc_query.go @@ -264,7 +264,7 @@ func (q Keeper) TallyResult(c context.Context, req *types.QueryTallyResultReques case proposal.Status == types.StatusDepositPeriod: tallyResult = types.EmptyTallyResult() - case proposal.Status == types.StatusPassed || proposal.Status == types.StatusRejected: + case proposal.Status == types.StatusPassed || proposal.Status == types.StatusRejected || proposal.Status == types.StatusFailed: tallyResult = proposal.FinalTallyResult default: diff --git a/x/gov/keeper/grpc_query_test.go b/x/gov/keeper/grpc_query_test.go index dae0206801..73aa23e555 100644 --- a/x/gov/keeper/grpc_query_test.go +++ b/x/gov/keeper/grpc_query_test.go @@ -4,6 +4,7 @@ import ( gocontext "context" "fmt" "strconv" + "time" "github.com/Finschia/finschia-sdk/simapp" sdk "github.com/Finschia/finschia-sdk/types" @@ -798,6 +799,33 @@ func (suite *KeeperTestSuite) TestGRPCQueryTally() { }, true, }, + { + "proposal status failed", + func() { + propTime := time.Now() + proposal := types.Proposal{ + ProposalId: 1, + Status: types.StatusFailed, + FinalTallyResult: types.TallyResult{ + Yes: sdk.NewInt(4), + Abstain: sdk.NewInt(1), + No: sdk.NewInt(0), + NoWithVeto: sdk.NewInt(0), + }, + SubmitTime: propTime, + VotingStartTime: propTime, + VotingEndTime: propTime, + } + app.GovKeeper.SetProposal(ctx, proposal) + + req = &types.QueryTallyResultRequest{ProposalId: proposal.ProposalId} + + expRes = &types.QueryTallyResultResponse{ + Tally: proposal.FinalTallyResult, + } + }, + true, + }, } for _, testCase := range testCases {