Skip to content

fix(learn-token): require at least one vote to execute proposal - #512

Open
lmduy2612 wants to merge 1 commit into
ChainLearnOfficial:mainfrom
lmduy2612:fix/execute-proposal-zero-votes-check-503
Open

lmduy2612 wants to merge 1 commit into
ChainLearnOfficial:mainfrom
lmduy2612:fix/execute-proposal-zero-votes-check-503

Conversation

@lmduy2612

Copy link
Copy Markdown

Description

Resolves #503.

In execute_proposal (contracts/learn-token/src/lib.rs), after tallying all choices, we now validate that winning_votes > 0. If no votes were cast (winning_votes == 0), the function panics with "no votes cast". This prevents empty, unvoted proposals from being executed with a default winning choice of 0.

Changes

  • contracts/learn-token/src/lib.rs: Added check if winning_votes == 0 { panic!("no votes cast"); } after the tally loop in execute_proposal.
  • tests/unit/token_tests.rs: Added unit test test_execute_proposal_fails_with_zero_votes verifying that proposals with 0 votes cannot be executed after the voting period ends.
  • tests/unit/token_tests.rs: Cleaned up spliced function signatures and sequence numbers from recent upstream merge.

Testing

  • cargo test --test token_tests: All 79 tests passed green.
  • cargo clippy --test token_tests: 0 warnings.

…nLearnOfficial#503)

- Validate winning_votes > 0 in execute_proposal and panic with 'no votes cast' if zero votes were cast
- Add test_execute_proposal_fails_with_zero_votes to verify zero-vote proposals cannot be executed
- Repair test setup syntax and sequence alignment in token_tests.rs
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.

execute_proposal succeeds with zero votes -- no quorum or minimum vote check

2 participants