Skip to content

test(governance-polls): verify vote change updates tally without double counting#566

Merged
Chucks1093 merged 1 commit into
accesslayerorg:mainfrom
Fury03:test/vote-change-tally-no-double-counting
Jul 23, 2026
Merged

test(governance-polls): verify vote change updates tally without double counting#566
Chucks1093 merged 1 commit into
accesslayerorg:mainfrom
Fury03:test/vote-change-tally-no-double-counting

Conversation

@Fury03

@Fury03 Fury03 commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Add a regression test covering a holder who changes their vote before a poll
expires. Wallet A votes option 0 with 10 keys, then switches to option 1.
Asserts option 0 tally decrements by 10, option 1 increments by 10, and total
vote weight stays unchanged, confirming the previous weight is removed rather
than double-counted.

Summary

  • Add changing_vote_before_expiry_removes_previous_weight_without_double_counting
    to creator-keys/tests/governance_polls.rs
  • Buys 10 keys for a single holder, casts a vote for option 0, then re-votes for
    option 1
  • Verifies the intermediate tally (option 0 = 10, total = 10), then the final
    tally (option 0 = 0, option 1 = 10, total = 10), proving weight moves rather
    than accumulates
  • Test-only change; no contract logic, storage, or event schema touched

Testing

  • cargo fmt --all -- --check
  • cargo clippy --workspace --all-targets -- -D warnings
  • cargo test --workspace

Checklist

  • Linked issue or backlog item
  • Added or updated creator-keys unit/integration tests for every changed contract behavior, including failure paths for new or reachable ContractError variants
  • Ran cargo fmt --all -- --check, cargo clippy --workspace --all-targets -- -D warnings, and cargo test --workspace, or explained exactly why a command was not run
  • Reviewed persistent storage changes against docs/storage-key-invariants.md; any storage layout change includes a migration/backward-compatibility note — N/A, no storage changes
  • Confirmed event names, topic order, payload field order, and field meanings remain compatible with docs/contract-event-conventions.md, or documented the breaking change and versioning plan — N/A, no event changes
  • Updated docs for any changed public contract interface, read-only method, event schema, storage behavior, fee logic, or deployment workflow — N/A, test-only change
  • Scope stays limited to one contract concern and does not include unrelated formatting, lockfile, generated artifact, or dependency changes
    Closes Add regression test for governance poll vote weight updating correctly when voter changes their vote #539

…le-counting

Add a regression test covering a holder who changes their vote before a
poll expires. Wallet A votes option 0 with 10 keys, then switches to
option 1. Asserts option 0 tally decrements by 10, option 1 increments
by 10, and total vote weight stays unchanged, confirming the previous
weight is removed rather than double-counted.
@Chucks1093
Chucks1093 merged commit 930a2f1 into accesslayerorg:main Jul 23, 2026
1 check 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.

Add regression test for governance poll vote weight updating correctly when voter changes their vote

2 participants