Skip to content

test: fee rounding proptest (#746)#893

Open
karanjadavi wants to merge 1 commit into
Predictify-org:masterfrom
karanjadavi:task/fee-rounding-proptest
Open

test: fee rounding proptest (#746)#893
karanjadavi wants to merge 1 commit into
Predictify-org:masterfrom
karanjadavi:task/fee-rounding-proptest

Conversation

@karanjadavi

Copy link
Copy Markdown

Summary

Closes #746. Adds a property-based test suite for FeeCalculator that asserts platform fees never exceed the configured basis-point rate.

What changed

  • Replaced the previously-registered but non-compiling contracts/predictify-hybrid/src/tests/fee_calculator_proptest.rs (it referenced proptest APIs that don't exist: proptest::strategy::StrategyWrapper, .proptest_individuals(), testutils::test()) with a working suite built on the real proptest! macro, following the same pattern already used by fee_calculator_proptest.rs's sibling fees.rs unit tests and ValidationTestingUtils::create_test_market.

Why not contracts/predictify-hybrid/tests/proptest_fee_rounding.rs as suggested in the issue

fees, types, and markets are declared as private mod (not pub mod) in lib.rs, so an external integration test under tests/ cannot reach FeeCalculator at all. Every existing fee-related test (fee_idempotency_tests.rs, fee_config_commit_reveal_tests.rs) lives under src/tests/ for the same reason. I kept that pattern instead of introducing a file that can't compile.

Properties covered

  1. fee <= total_staked for every generated stake
  2. fee never exceeds the configured bps rate (fee * 10_000 <= total_staked * PLATFORM_FEE_PERCENTAGE)
  3. Rounding is strictly floor (fee is the largest integer satisfying the bound above)
  4. platform_fee + user_payout_amount == total_staked (breakdown reconciles exactly)
  5. Fee is monotonically non-decreasing as stake increases
  6. Focused edge cases: zero stake, i128::MAX (overflow guard), MIN_FEE_AMOUNT boundary, small-pool rounding

Verification

This branch is based on current master (43fdfdd), which does not compile as-is (325 pre-existing error[...] diagnostics from unrelated modules — missing mod declarations for disputes, edge_cases, market_analytics, performance_benchmarks, graceful_degradation, plus renamed/removed functions like require_primary_admin). I confirmed this new test file introduces zero new error locations by diffing cargo test -p predictify-hybrid --no-run output with and without this change (identical --> locations both ways). Once the unrelated build breakage upstream is fixed, this suite should compile and run cleanly — happy to re-verify at that point if useful.

@drips-wave

drips-wave Bot commented Jul 23, 2026

Copy link
Copy Markdown

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

@karanjadavi

Copy link
Copy Markdown
Author

Heads up: CI will likely fail on this PR — master (43fdfdd) currently has 325 pre-existing compile errors unrelated to this change (missing mod declarations for disputes/edge_cases/market_analytics/performance_benchmarks/graceful_degradation, plus several renamed/removed functions like require_primary_admin). Verified this file adds zero new error locations by diffing cargo build output with/without it. Flagging in case a separate issue should track the master breakage.

@karanjadavi

Copy link
Copy Markdown
Author

Update: CI is failing for an additional, separate reason beyond the local mod/function issues I flagged earlier — the ethnum v1.5.0 dependency (pulled in transitively via num-bigint) fails to compile on the CI runner with error[E0512] (transmute size mismatch in TryFromIntError). This is unrelated to this PR's change as well; it's a dependency/rustc-version compatibility issue in the workspace's Cargo.lock, not something introduced here. Not attempting to fix it in this PR since pinning a different ethnum version is a separate, workspace-wide change outside this task's scope.

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 proptest for FeeCalculator rounding

1 participant