Skip to content

Commit

Permalink
fix: fetch a failed proposal tally from proposal.FinalTallyResult in …
Browse files Browse the repository at this point in the history
…the gprc query (#1304)

* fix(x/gov): grpc query tally for failed proposal (#19725)

* fix: fix conflict

Signed-off-by: 170210 <j170210@icloud.com>

* chore: update CHANGELOG.md

Signed-off-by: 170210 <j170210@icloud.com>

---------

Signed-off-by: 170210 <j170210@icloud.com>
Co-authored-by: David Tumcharoen <david@alleslabs.com>
  • Loading branch information
170210 and traviolus authored Mar 27, 2024
1 parent 1038a39 commit e986f03
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
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

0 comments on commit e986f03

Please sign in to comment.