-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
R4R: Fix tally result #2861
R4R: Fix tally result #2861
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fedekunze thanks! I left some initial feedback 🍍
// create SubmitProposal TX | ||
resultTx = doVote(t, port, seed, name, password, addr, proposalID) | ||
resultTx = doVote(t, port, seed, name, password, addr, proposalID, option.String()) | ||
tests.WaitForHeight(resultTx.Height 1, port) | ||
|
||
vote := getVote(t, port, proposalID, addr) | ||
require.Equal(t, proposalID, vote.ProposalID) | ||
require.Equal(t, gov.OptionYes, vote.Option) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use option
here since we already have a variable for it.
tally := proposal.GetTallyResult() | ||
switch { | ||
case option == OptionYes: | ||
tally.Yes = tally.Yes.Sub(sdk.NewDec(1)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use sdk.OneDec
in these cases?
tally := proposal.GetTallyResult() | ||
switch { | ||
case option == OptionYes: | ||
tally.Yes = tally.Yes.Add(sdk.NewDec(1)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto.
if oldVote.Option != option { | ||
// Case 1.1: new option is different than the previous one | ||
keeper.decreaseProposalTally(ctx, proposal, oldVote.Option) | ||
keeper.SetProposal(ctx, proposal) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we setting the proposal twice?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See my comment in #2859. This is not the correct usage of TallyResult.
Closing per discussion between @fedekunze and @sunnya97 that resolves this. |
Fixes #2859
__
Targeted PR against correct branch (see CONTRIBUTING.md)
Linked to github-issue with discussion and accepted design OR link to spec that describes this work.
Wrote tests
Updated relevant documentation (
docs/
)Added entries in
PENDING.md
with issue #rereviewed
Files changed
in the github PR explorerFor Admin Use: