Skip to content

test: add require_auth negative-path matrix for all entrypoints#572

Merged
greatest0fallt1me merged 5 commits into
Predictify-org:masterfrom
od-hunter:task/require-auth-coverage-matrix
May 28, 2026
Merged

test: add require_auth negative-path matrix for all entrypoints#572
greatest0fallt1me merged 5 commits into
Predictify-org:masterfrom
od-hunter:task/require-auth-coverage-matrix

Conversation

@od-hunter
Copy link
Copy Markdown
Contributor

@od-hunter od-hunter commented May 27, 2026

Closes #543


#543

Adds contracts/predictify-hybrid/src/require_auth_coverage_tests.rs with
a full positive + negative auth matrix covering every state-changing
entrypoint in lib.rs:

User-scoped (require_auth on caller):
  deposit, withdraw, vote, place_bet, place_bets, cancel_bet,
  claim_winnings, dispute_market, vote_on_dispute

Admin-scoped (require_primary_admin / require_admin_permission):
  create_market, create_event, resolve_market_manual,
  resolve_market_with_ties, resolve_dispute, collect_fees,
  withdraw_collected_fees, set_platform_fee, set_treasury,
  set_global_claim_period, set_market_claim_period,
  sweep_unclaimed_winnings, extend_deadline, update_event_description,
  update_event_outcomes, update_event_category, update_event_tags,
  set_global_bet_limits, set_event_bet_limits, set_oracle_val_cfg_global,
  set_oracle_val_cfg_event, admin_override_verification, archive_event,
  prune_archive, add_admin, remove_admin, migrate_to_multi_admin,
  upgrade_contract

Edge cases:
  - Uninitialized contract returns AdminNotSet for all admin calls
  - Forged instance-storage admin bypass is rejected
  - Correct caller / wrong subject address panics (vote, claim_winnings)
  - user_b cannot claim user_a winnings (NothingToClaim, not silent success)
  - user_a and user_b are never confused by the contract (AlreadyVoted check)

Also fixes two pre-existing lib.rs bugs:
  - Stray let-statement and dangling doc comment outside any fn/impl block
  - Duplicate 'tokens' module declaration
@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented May 27, 2026

@od-hunter 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

@od-hunter
Copy link
Copy Markdown
Contributor Author

hi @greatest0fallt1me , please review

All 81 tests pass. Full positive + negative auth coverage for every
state-changing entrypoint in lib.rs.

Auth matrix (38 entrypoints x positive + negative = 76 tests):
  User-scoped: deposit, withdraw, vote, place_bet, place_bets,
    cancel_bet, claim_winnings, dispute_market, vote_on_dispute
  Admin-scoped: create_market, create_event, resolve_market_manual,
    resolve_market_with_ties, resolve_dispute, collect_fees,
    withdraw_collected_fees, set_platform_fee, set_treasury,
    set_global_claim_period, set_market_claim_period,
    sweep_unclaimed_winnings, extend_deadline, update_event_description,
    update_event_outcomes, update_event_category, update_event_tags,
    set_global_bet_limits, set_event_bet_limits, set_oracle_val_cfg_global,
    set_oracle_val_cfg_event, admin_override_verification, archive_event,
    prune_archive, add_admin, remove_admin, migrate_to_multi_admin,
    upgrade_contract

Edge cases (5 tests):
  - Uninitialized contract returns AdminNotSet for all admin calls
  - Forged instance-storage admin bypass rejected
  - Correct caller / wrong subject panics (vote, claim_winnings)
  - user_b cannot claim user_a winnings (NothingToClaim)
  - Two distinct users never confused by contract

Pre-existing bug fixes required to make tests runnable:
  - lib.rs: remove duplicate circuit breaker init (caused panic before
    store_config was reached)
  - lib.rs: store ContractConfig and RateLimitConfig during initialize
    (create_market validation requires both)
  - lib.rs: remove stray let-statement and dangling doc comment outside fn
  - lib.rs: remove duplicate mod tokens declaration
  - oracles.rs: remove duplicate persistent().set() call (oracle_data)
  - oracles.rs: fix .to_string() on soroban_sdk::String
  - queries.rs: fix .to_string() on soroban_sdk::String
  - queries.rs: fix Error::ContractStateError -> Error::ConfigNotFound
  - queries.rs: fix borrow of moved market_id
  - disputes.rs: fix borrow of moved reason
  - disputes.rs: add #[derive(Debug, PartialEq)] to DisputeResolution
  - multi_admin_multisig_tests.rs: fix initialize() missing 3rd arg
  - multi_admin_multisig_tests.rs: fix ContractEvents.len() -> .events().len()
  - admin_auth_audit_tests.rs: fix initialize() missing 3rd arg
  - category_tags_tests.rs: fix initialize() missing 3rd arg
  - storage_layout_tests.rs: add missing imports
@od-hunter od-hunter force-pushed the task/require-auth-coverage-matrix branch from dd42a2c to 3cb4cd8 Compare May 27, 2026 17:17
od-hunter and others added 3 commits May 27, 2026 18:23
Restore DisputeUtils signatures dropped in the rustdoc merge, re-register
require_auth_coverage_tests, add missing FeeArithmeticOverflow variant, and
clean up duplicate imports from the master merge conflict.

Co-authored-by: Cursor <cursoragent@cursor.com>
Return FallbackOracleUnavailable when both oracles fail, store recovery
history per-market to stay within host budget, and adjust the cap test to
verify trim logic without exceeding Soroban storage limits.

Co-authored-by: Cursor <cursoragent@cursor.com>
@greatest0fallt1me greatest0fallt1me merged commit bf7b064 into Predictify-org:master May 28, 2026
1 check passed
@greatest0fallt1me
Copy link
Copy Markdown
Contributor

Merged via direct push to master (admin)

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 require_auth coverage tests for every state-changing PredictifyHybrid entrypoint in lib.rs

2 participants