Skip to content

Commit a877c47

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

File tree

3 files changed

+66
-1
lines changed

3 files changed

+66
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
5050

5151
### Bug Fixes
5252

53+
* (x/gov) [#19725](https://github.com/cosmos/cosmos-sdk/pull/19725) Fetch a failed proposal tally from proposal.FinalTallyResult in the gprc query.
5354
* (types) [#19709](https://github.com/cosmos/cosmos-sdk/pull/19709) Fix skip staking genesis export when using `CoreAppModuleAdaptor` / `CoreAppModuleBasicAdaptor` for it.
5455
* (x/auth) [#19549](https://github.com/cosmos/cosmos-sdk/pull/19549) Accept custom get signers when injecting `x/auth/tx`.
5556
* (x/staking) Fix a possible bypass of delegator slashing: [GHSA-86h5-xcpx-cfqc](https://github.com/cosmos/cosmos-sdk/security/advisories/GHSA-86h5-xcpx-cfqc)

x/gov/keeper/grpc_query.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ func (q queryServer) TallyResult(ctx context.Context, req *v1.QueryTallyResultRe
260260
case proposal.Status == v1.StatusDepositPeriod:
261261
tallyResult = v1.EmptyTallyResult()
262262

263-
case proposal.Status == v1.StatusPassed || proposal.Status == v1.StatusRejected:
263+
case proposal.Status == v1.StatusPassed || proposal.Status == v1.StatusRejected || proposal.Status == v1.StatusFailed:
264264
tallyResult = *proposal.FinalTallyResult
265265

266266
default:

x/gov/keeper/grpc_query_test.go

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1560,6 +1560,38 @@ func (suite *KeeperTestSuite) TestGRPCQueryTallyResult() {
15601560
},
15611561
true,
15621562
},
1563+
{
1564+
"proposal status failed",
1565+
func() {
1566+
propTime := time.Now()
1567+
proposal := v1.Proposal{
1568+
Id: 1,
1569+
Status: v1.StatusFailed,
1570+
FinalTallyResult: &v1.TallyResult{
1571+
YesCount: "4",
1572+
AbstainCount: "1",
1573+
NoCount: "0",
1574+
NoWithVetoCount: "0",
1575+
},
1576+
SubmitTime: &propTime,
1577+
VotingStartTime: &propTime,
1578+
VotingEndTime: &propTime,
1579+
Metadata: "proposal metadata",
1580+
}
1581+
err := suite.govKeeper.Proposals.Set(suite.ctx, proposal.Id, proposal)
1582+
suite.Require().NoError(err)
1583+
1584+
req = &v1.QueryTallyResultRequest{ProposalId: proposal.Id}
1585+
1586+
expTally = &v1.TallyResult{
1587+
YesCount: "4",
1588+
AbstainCount: "1",
1589+
NoCount: "0",
1590+
NoWithVetoCount: "0",
1591+
}
1592+
},
1593+
true,
1594+
},
15631595
}
15641596

15651597
for _, testCase := range testCases {
@@ -1696,6 +1728,38 @@ func (suite *KeeperTestSuite) TestLegacyGRPCQueryTallyResult() {
16961728
},
16971729
true,
16981730
},
1731+
{
1732+
"proposal status failed",
1733+
func() {
1734+
propTime := time.Now()
1735+
proposal := v1.Proposal{
1736+
Id: 1,
1737+
Status: v1.StatusFailed,
1738+
FinalTallyResult: &v1.TallyResult{
1739+
YesCount: "4",
1740+
AbstainCount: "1",
1741+
NoCount: "0",
1742+
NoWithVetoCount: "0",
1743+
},
1744+
SubmitTime: &propTime,
1745+
VotingStartTime: &propTime,
1746+
VotingEndTime: &propTime,
1747+
Metadata: "proposal metadata",
1748+
}
1749+
err := suite.govKeeper.Proposals.Set(suite.ctx, proposal.Id, proposal)
1750+
suite.Require().NoError(err)
1751+
1752+
req = &v1beta1.QueryTallyResultRequest{ProposalId: proposal.Id}
1753+
1754+
expTally = &v1beta1.TallyResult{
1755+
Yes: math.NewInt(4),
1756+
Abstain: math.NewInt(1),
1757+
No: math.NewInt(0),
1758+
NoWithVeto: math.NewInt(0),
1759+
}
1760+
},
1761+
true,
1762+
},
16991763
}
17001764

17011765
for _, testCase := range testCases {

0 commit comments

Comments
 (0)