Skip to content

Commit 6b11b65

Browse files
mergify[bot]traviolusjulienrbrt
authored
fix(x/gov): grpc query tally for failed proposal (backport #19725) (#19728)
Co-authored-by: David Tumcharoen <[email protected]> Co-authored-by: Julien Robert <[email protected]>
1 parent 1cf2940 commit 6b11b65

File tree

3 files changed

+67
-1
lines changed

3 files changed

+67
-1
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ Ref: https://keepachangelog.com/en/1.0.0/
3737

3838
## [Unreleased]
3939

40+
### Bug Fixes
41+
42+
* (x/gov) [#19725](https://github.com/cosmos/cosmos-sdk/pull/19725) Fetch a failed proposal tally from proposal.FinalTallyResult in the gprc query.
43+
4044
## [v0.47.10](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.47.10) - 2024-02-27
4145

4246
### Bug Fixes

x/gov/keeper/grpc_query.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ func (q Keeper) TallyResult(c context.Context, req *v1.QueryTallyResultRequest)
270270
case proposal.Status == v1.StatusDepositPeriod:
271271
tallyResult = v1.EmptyTallyResult()
272272

273-
case proposal.Status == v1.StatusPassed || proposal.Status == v1.StatusRejected:
273+
case proposal.Status == v1.StatusPassed || proposal.Status == v1.StatusRejected || proposal.Status == v1.StatusFailed:
274274
tallyResult = *proposal.FinalTallyResult
275275

276276
default:

x/gov/keeper/grpc_query_test.go

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1478,6 +1478,37 @@ func (suite *KeeperTestSuite) TestGRPCQueryTallyResult() {
14781478
},
14791479
true,
14801480
},
1481+
{
1482+
"proposal status failed",
1483+
func() {
1484+
propTime := time.Now()
1485+
proposal := v1.Proposal{
1486+
Id: 1,
1487+
Status: v1.StatusFailed,
1488+
FinalTallyResult: &v1.TallyResult{
1489+
YesCount: "4",
1490+
AbstainCount: "1",
1491+
NoCount: "0",
1492+
NoWithVetoCount: "0",
1493+
},
1494+
SubmitTime: &propTime,
1495+
VotingStartTime: &propTime,
1496+
VotingEndTime: &propTime,
1497+
Metadata: "proposal metadata",
1498+
}
1499+
suite.govKeeper.SetProposal(suite.ctx, proposal)
1500+
1501+
req = &v1.QueryTallyResultRequest{ProposalId: proposal.Id}
1502+
1503+
expTally = &v1.TallyResult{
1504+
YesCount: "4",
1505+
AbstainCount: "1",
1506+
NoCount: "0",
1507+
NoWithVetoCount: "0",
1508+
}
1509+
},
1510+
true,
1511+
},
14811512
}
14821513

14831514
for _, testCase := range testCases {
@@ -1614,6 +1645,37 @@ func (suite *KeeperTestSuite) TestLegacyGRPCQueryTallyResult() {
16141645
},
16151646
true,
16161647
},
1648+
{
1649+
"proposal status failed",
1650+
func() {
1651+
propTime := time.Now()
1652+
proposal := v1.Proposal{
1653+
Id: 1,
1654+
Status: v1.StatusFailed,
1655+
FinalTallyResult: &v1.TallyResult{
1656+
YesCount: "4",
1657+
AbstainCount: "1",
1658+
NoCount: "0",
1659+
NoWithVetoCount: "0",
1660+
},
1661+
SubmitTime: &propTime,
1662+
VotingStartTime: &propTime,
1663+
VotingEndTime: &propTime,
1664+
Metadata: "proposal metadata",
1665+
}
1666+
suite.govKeeper.SetProposal(suite.ctx, proposal)
1667+
1668+
req = &v1beta1.QueryTallyResultRequest{ProposalId: proposal.Id}
1669+
1670+
expTally = &v1beta1.TallyResult{
1671+
Yes: math.NewInt(4),
1672+
Abstain: math.NewInt(1),
1673+
No: math.NewInt(0),
1674+
NoWithVeto: math.NewInt(0),
1675+
}
1676+
},
1677+
true,
1678+
},
16171679
}
16181680

16191681
for _, testCase := range testCases {

0 commit comments

Comments
 (0)