Skip to content

Expand test coverage: dex competitions/cross-chain, governance private voting, insurance triggers, staking penalties - #1051

Merged
nanaf6203-bit merged 3 commits into
MettaChain:mainfrom
khaadish:feature/expand-contract-test-coverage
Aug 25, 2026
Merged

Expand test coverage: dex competitions/cross-chain, governance private voting, insurance triggers, staking penalties#1051
nanaf6203-bit merged 3 commits into
MettaChain:mainfrom
khaadish:feature/expand-contract-test-coverage

Conversation

@khaadish

Copy link
Copy Markdown
Contributor

Summary

Expands test coverage across four contracts, closing all four assigned coverage issues.

  • dex (DEX tests cover ~41 of 98 messages: competitions, cross-chain trades and liquidity-mining are untested #997): new tests cover the trading-competition lifecycle end to end (admin-only creation with input validation, swap-driven score accrual, pro-rata reward claims after the window closes, double-claim and zero-score rejections), the cross-chain trade flow (create_cross_chain_trade -> attach_bridge_request -> finalize_cross_chain_trade with authorization checks, unknown-pool/unconfigured-route rejections and open-position accounting via portfolio snapshots), and set_liquidity_mining_campaign (authorization, validation, storage round-trip).
  • governance (Governance private voting has no tests: commit_vote, reveal_vote and vote_with_signature are uncovered #998): covers the previously untested voting-privacy feature: commit -> start_reveal_phase -> reveal with the correct salt records the vote; wrong salt or altered support flag is rejected; reveal before phase start rejected; commitment cleared to prevent double reveal; duplicate commits rejected; non-signers blocked. vote_with_signature is tested with None (plain vote) and with an approval from an unregistered key / invalid signature (rejected without recording). register_public_key signer gating included.
  • insurance (Insurance claim-trigger path has no tests: register, deactivate and report_oracle_event are uncovered #999): covers register_claim_trigger (holder/admin paths, unauthorized rejection, invalid payout modes), deactivate_claim_trigger (one-shot deactivation, stranger rejection, TriggerNotFound) and report_oracle_event (admin and authorized-oracle acceptance, unauthorized reporter rejection, threshold met-vs-unmet including exact boundary 149/150, auto-created claim paid from the pool with ClaimStatus::Paid, one-shot re-fire rejection).
  • staking (Staking slashing and unbonding paths are untested: 92 tests skip the penalty and withdrawal flows #1000): pins the unbonding boundary - claim at exactly start + UNBONDING_PERIOD_BLOCKS succeeds, one block before fails then succeeds on the next block; fixes a mangled #[ink::test] attribute that silently disabled two existing tests; adds exact early-withdrawal penalty math assertions on non-round amounts (12_345 @ 333 bps = 411 retained; 9_999 @ default 1_000 bps = 999 retained). Slashing flows were already covered by existing tests (slash_validator_*, slash_multiple_delegators).

Test results

  • cargo test -p propchain-dex: 30 passed
  • cargo test -p governance: 22 passed
  • cargo test -p propchain-insurance: 102 passed
  • cargo test -p staking: 107 passed

Closes #997
Closes #998
Closes #999
Closes #1000

…nce triggers and staking penalties

- dex: cover the trading-competition lifecycle (creation, validation,
  scoring via swaps, pro-rata reward claims, double-claim rejection,
  activate/deactivate toggles), the cross-chain trade flow (create,
  attach bridge request, finalize, authorization and error branches)
  and liquidity-mining campaign configuration (MettaChain#997)
- governance: test the private voting feature end to end - commit,
  start reveal phase, reveal with correct/wrong salt, reveal before
  phase start, double reveal, plus vote_with_signature with and without
  an approval and register_public_key signer gating (MettaChain#998)
- insurance: cover claim-trigger registration and deactivation, the
  admin/oracle authorization boundary of report_oracle_event, one-shot
  firing, threshold met/unmet boundaries and the auto-paid claim path
  (MettaChain#999)
- staking: pin the unbonding period boundary (claim exactly at and one
  block before/after), fix a mangled attribute that silently disabled
  two tests, and assert exact early-withdrawal penalty math on
  non-round amounts for default and custom bps (MettaChain#1000)

Closes MettaChain#997, closes MettaChain#998, closes MettaChain#999, closes MettaChain#1000
@drips-wave

drips-wave Bot commented Aug 25, 2026

Copy link
Copy Markdown

@khaadish 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

The gate fails for all PRs independent of their contents: the pinned
dependency set (trie-db 0.28.0) no longer compiles under the stable
rustc (1.98.0) that CI installs fresh on every run, so clippy aborts
inside dependency code before reaching project code.

Per maintainer request, comment out the workflow until the dependency
baseline is refreshed.
@nanaf6203-bit
nanaf6203-bit merged commit 71be3ac into MettaChain:main Aug 25, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment