fix(x/gov): grpc query tally for failed proposal (#19725)
This commit is contained in:
parent
d808ef82e5
commit
d961aef76b
@ -85,6 +85,7 @@ Every module contains its own CHANGELOG.md. Please refer to the module you are i
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* (x/gov) [#19725](https://github.com/cosmos/cosmos-sdk/pull/19725) Fetch a failed proposal tally from proposal.FinalTallyResult in the gprc query.
|
||||
* (baseapp) [#18727](https://github.com/cosmos/cosmos-sdk/pull/18727) Ensure that `BaseApp.Init` firstly returns any errors from a nil commit multistore instead of panicking on nil dereferencing and before sealing the app.
|
||||
* (client) [#18622](https://github.com/cosmos/cosmos-sdk/pull/18622) Fixed a potential under/overflow from `uint64->int64` when computing gas fees as a LegacyDec.
|
||||
* (client/keys) [#18562](https://github.com/cosmos/cosmos-sdk/pull/18562) `keys delete` won't terminate when a key is not found.
|
||||
|
||||
@ -319,7 +319,7 @@ func (q queryServer) TallyResult(ctx context.Context, req *v1.QueryTallyResultRe
|
||||
case proposal.Status == v1.StatusDepositPeriod:
|
||||
tallyResult = v1.EmptyTallyResult()
|
||||
|
||||
case proposal.Status == v1.StatusPassed || proposal.Status == v1.StatusRejected:
|
||||
case proposal.Status == v1.StatusPassed || proposal.Status == v1.StatusRejected || proposal.Status == v1.StatusFailed:
|
||||
tallyResult = *proposal.FinalTallyResult
|
||||
|
||||
default:
|
||||
|
||||
@ -1640,6 +1640,48 @@ func (suite *KeeperTestSuite) TestGRPCQueryTallyResult() {
|
||||
},
|
||||
true,
|
||||
},
|
||||
{
|
||||
"proposal status failed",
|
||||
func() {
|
||||
propTime := time.Now()
|
||||
proposal := v1.Proposal{
|
||||
Id: 1,
|
||||
Status: v1.StatusFailed,
|
||||
FinalTallyResult: &v1.TallyResult{
|
||||
YesCount: "4",
|
||||
AbstainCount: "1",
|
||||
NoCount: "0",
|
||||
NoWithVetoCount: "0",
|
||||
OptionOneCount: "4",
|
||||
OptionTwoCount: "1",
|
||||
OptionThreeCount: "0",
|
||||
OptionFourCount: "0",
|
||||
SpamCount: "0",
|
||||
},
|
||||
SubmitTime: &propTime,
|
||||
VotingStartTime: &propTime,
|
||||
VotingEndTime: &propTime,
|
||||
Metadata: "proposal metadata",
|
||||
}
|
||||
err := suite.govKeeper.Proposals.Set(suite.ctx, proposal.Id, proposal)
|
||||
suite.Require().NoError(err)
|
||||
|
||||
req = &v1.QueryTallyResultRequest{ProposalId: proposal.Id}
|
||||
|
||||
expTally = &v1.TallyResult{
|
||||
YesCount: "4",
|
||||
AbstainCount: "1",
|
||||
NoCount: "0",
|
||||
NoWithVetoCount: "0",
|
||||
OptionOneCount: "4",
|
||||
OptionTwoCount: "1",
|
||||
OptionThreeCount: "0",
|
||||
OptionFourCount: "0",
|
||||
SpamCount: "0",
|
||||
}
|
||||
},
|
||||
true,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
@ -1781,6 +1823,39 @@ func (suite *KeeperTestSuite) TestLegacyGRPCQueryTallyResult() {
|
||||
},
|
||||
true,
|
||||
},
|
||||
{
|
||||
"proposal status failed",
|
||||
func() {
|
||||
propTime := time.Now()
|
||||
proposal := v1.Proposal{
|
||||
Id: 1,
|
||||
Status: v1.StatusFailed,
|
||||
FinalTallyResult: &v1.TallyResult{
|
||||
YesCount: "4",
|
||||
AbstainCount: "1",
|
||||
NoCount: "0",
|
||||
NoWithVetoCount: "0",
|
||||
SpamCount: "0",
|
||||
},
|
||||
SubmitTime: &propTime,
|
||||
VotingStartTime: &propTime,
|
||||
VotingEndTime: &propTime,
|
||||
Metadata: "proposal metadata",
|
||||
}
|
||||
err := suite.govKeeper.Proposals.Set(suite.ctx, proposal.Id, proposal)
|
||||
suite.Require().NoError(err)
|
||||
|
||||
req = &v1beta1.QueryTallyResultRequest{ProposalId: proposal.Id}
|
||||
|
||||
expTally = &v1beta1.TallyResult{
|
||||
Yes: math.NewInt(4),
|
||||
Abstain: math.NewInt(1),
|
||||
No: math.NewInt(0),
|
||||
NoWithVeto: math.NewInt(0),
|
||||
}
|
||||
},
|
||||
true,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user