Skip to content
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

Closed
wants to merge 3 commits into from
Closed

Conversation

fedekunze
Copy link
Collaborator

@fedekunze fedekunze commented Nov 19, 2018

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 explorer


For Admin Use:

  • Added appropriate labels to PR (ex. wip, ready-for-review, docs)
  • Reviewers Assigned
  • Squashed all commits, uses message "Merge pull request #XYZ: [title]" (coding standards)

@fedekunze fedekunze added the wip label Nov 19, 2018
@fedekunze fedekunze changed the title WIP: Add test cases WIP: Fix tally result Nov 19, 2018
@fedekunze fedekunze changed the title WIP: Fix tally result R4R: Fix tally result Nov 19, 2018
Copy link
Contributor

@alexanderbez alexanderbez left a 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)
Copy link
Contributor

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))
Copy link
Contributor

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))
Copy link
Contributor

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)
Copy link
Contributor

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?

Copy link
Member

@sunnya97 sunnya97 left a 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.

@jackzampolin
Copy link
Member

Closing per discussion between @fedekunze and @sunnya97 that resolves this.

@cwgoes cwgoes deleted the fedekunze/2859-fix-tally-vote branch November 20, 2018 10:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants