Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fetch a failed proposal tally from proposal.FinalTallyResult in the gprc query #1304

Merged
merged 4 commits into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion x/gov/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
28 changes: 28 additions & 0 deletions x/gov/keeper/grpc_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
gocontext "context"
"fmt"
"strconv"
"time"

"github.com/Finschia/finschia-sdk/simapp"
sdk "github.com/Finschia/finschia-sdk/types"
Expand Down Expand Up @@ -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 {
Expand Down
Loading