Skip to content

feat(voting): token-weighted voting module — expand test coverage to 25 cases#496

Merged
truthixify merged 2 commits intoDistinctCodes:mainfrom
KevinMB0220:feat/token-weighted-voting-module
Feb 22, 2026
Merged

feat(voting): token-weighted voting module — expand test coverage to 25 cases#496
truthixify merged 2 commits intoDistinctCodes:mainfrom
KevinMB0220:feat/token-weighted-voting-module

Conversation

@KevinMB0220
Copy link
Contributor

Summary

Closes #471

Implements comprehensive test coverage for the token-weighted voting module (cast_vote, get_vote_tally, has_voted, proposal_passed), expanding from 6 to 25 test cases that verify all acceptance criteria from the issue.

  • cast_vote: double-vote returns AlreadyVoted, insufficient balance returns InsufficientVotingPower, non-holder returns HolderNotFound, non-tokenized asset returns AssetNotTokenized, vote weight equals token balance at time of voting, exact threshold boundary, same voter on independent proposals, multiple voters on same proposal
  • get_vote_tally: starts at zero, error on non-tokenized asset, accumulates weighted votes across multiple voters, tally is isolated per proposal ID
  • has_voted: returns false before voting, true after voting, error on non-tokenized asset, independent per proposal
  • proposal_passed: returns false with no votes, error on non-tokenized asset, respects min_voting_threshold, correctly transitions from failing to passing as more voters cross the threshold

Test plan

  • cargo fmt — no formatting issues
  • cargo clippy — 0 warnings
  • cargo build — compiles successfully
  • cargo test92/92 tests pass

…ted voting module

Covers all acceptance criteria from issue DistinctCodes#471:
- cast_vote: AlreadyVoted error, InsufficientVotingPower error, holder not found,
  asset not tokenized, vote weight equals token balance, exact threshold boundary,
  same voter on different proposals, multiple voters on same proposal
- get_vote_tally: starts at zero, error on non-tokenized asset, accumulates
  multiple voters, isolated per proposal ID
- has_voted: returns false before voting, true after voting, error on non-tokenized
  asset, independent per proposal
- proposal_passed: no votes case, non-tokenized asset error, respects
  min_voting_threshold, multiple voters crossing the threshold
@vercel
Copy link

vercel bot commented Feb 22, 2026

@KevinMB0220 is attempting to deploy a commit to the naijabuz's projects Team on Vercel.

A member of the Team first needs to authorize it.

@truthixify truthixify merged commit 602dde8 into DistinctCodes:main Feb 22, 2026
4 of 5 checks passed
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.

[Contract] Implement Token-Weighted Voting Module for Asset Proposals

2 participants