test: fee rounding proptest (#746)#893
Conversation
|
@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! 🚀 |
|
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. |
|
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. |
Summary
Closes #746. Adds a property-based test suite for FeeCalculator that asserts platform fees never exceed the configured basis-point rate.
What changed
proptest::strategy::StrategyWrapper,.proptest_individuals(),testutils::test()) with a working suite built on the realproptest!macro, following the same pattern already used byfee_calculator_proptest.rs's siblingfees.rsunit tests andValidationTestingUtils::create_test_market.Why not contracts/predictify-hybrid/tests/proptest_fee_rounding.rs as suggested in the issue
fees,types, andmarketsare declared as privatemod(notpub mod) inlib.rs, so an external integration test undertests/cannot reachFeeCalculatorat all. Every existing fee-related test (fee_idempotency_tests.rs,fee_config_commit_reveal_tests.rs) lives undersrc/tests/for the same reason. I kept that pattern instead of introducing a file that can't compile.Properties covered
fee <= total_stakedfor every generated stakefeenever exceeds the configured bps rate (fee * 10_000 <= total_staked * PLATFORM_FEE_PERCENTAGE)platform_fee + user_payout_amount == total_staked(breakdown reconciles exactly)i128::MAX(overflow guard), MIN_FEE_AMOUNT boundary, small-pool roundingVerification
This branch is based on current
master(43fdfdd), which does not compile as-is (325 pre-existingerror[...]diagnostics from unrelated modules — missingmoddeclarations fordisputes,edge_cases,market_analytics,performance_benchmarks,graceful_degradation, plus renamed/removed functions likerequire_primary_admin). I confirmed this new test file introduces zero new error locations by diffingcargo test -p predictify-hybrid --no-runoutput 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.