Skip to content

test(staking): cover staking-to-governance voting power flow (#1521) - #1569

Merged
nanaf6203-bit merged 1 commit into
MettaChain:mainfrom
Moonwalker-rgb:test/staking-governance-voting-1521
Nov 24, 2026
Merged

nanaf6203-bit merged 1 commit into
MettaChain:mainfrom
Moonwalker-rgb:test/staking-governance-voting-1521

Conversation

@Moonwalker-rgb

@Moonwalker-rgb Moonwalker-rgb commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Closes #1521

Summary

Adds a standalone integration suite at
contract-extensions/tests/staking-governance-voting-tests/ that drives the
staking contract's own parameter-governance module through the real compiled
contract: stake -> propose_param_change -> vote_on_proposal -> execute_param_proposal, plus unstaking and delegation.

Changes

  • contract-extensions/tests/staking-governance-voting-tests/Cargo.toml
  • contract-extensions/tests/staking-governance-voting-tests/src/lib.rs

Checklist

  • All changes are within contract-extensions/
  • No modifications to contracts/, tests/, scripts/, or root configuration files
  • Rust code follows existing ink! patterns
  • Tests are included and passing
  • cargo clippy passes with no warnings
  • cargo test passes
  • cargo build succeeds (the test run builds the crate and its contract dependency)
  • PR references the issue number above

Testing

cargo test --manifest-path contract-extensions/tests/staking-governance-voting-tests/Cargo.toml
# 11 passed; 0 failed

cargo clippy --manifest-path contract-extensions/tests/staking-governance-voting-tests/Cargo.toml --all-targets -- -D warnings
# clean

Coverage against the acceptance criteria

  • Stakes with a lock period and verifies voting power is assigned.
  • Proposes, votes, and executes a parameter change after the voting window.
  • Voting power is proportional to the staked amount (10k vs 30k vs 60k).
  • Unstaking removes power, and an account that unstakes before voting cannot
    spend its old power (NoVotingPower); the orphaned proposal then fails
    quorum.
  • Multiple accounts stake different amounts and vote on the same proposal.
  • Pending reward accrual does not change voting power; a plain claim leaves
    principal and power untouched.
  • Delegation moves power to the delegate and blocks the delegator's ballot.
  • Quorum, majority rejection, double-vote and closed-window paths.

Two behaviours pinned rather than assumed

The shipped contract differs from the usual token-weighted DAO model, so the
tests state the actual semantics instead of asserting behaviour the code does
not implement:

  1. Lock duration does not change voting power. stake grants the raw
    amount in governance_power; LockPeriod is only used in reward pricing.
    lock_period_changes_rewards_but_not_voting_power asserts equal power for
    equal principals and a higher reward projection for the longer lock.
  2. Reward accrual is separate from power; auto-compounding is not. Pending
    rewards and an ordinary claim leave power alone. Auto-compounding adds the
    reward to stake.amount, which is new principal and therefore increases
    power; the test asserts that distinction explicitly.

Add an integration suite under contract-extensions/tests that stakes with
different amounts and lock periods, then drives proposal creation, weighted
voting, execution, unstaking and delegation through the compiled staking
contract.

Voting power is pinned to the staked principal. Lock duration and pending
rewards are asserted to move rewards only; auto-compounding becomes
principal and therefore power, which the suite states explicitly.
@drips-wave

drips-wave Bot commented Nov 23, 2026

Copy link
Copy Markdown

@Moonwalker-rgb Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@nanaf6203-bit nanaf6203-bit left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me. Thanks for the effort!

@nanaf6203-bit
nanaf6203-bit merged commit 142315c into MettaChain:main Nov 24, 2026
1 of 2 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.

Integration Test: Staking-to-Governance Voting Power Flow

2 participants