Skip to content

Comments

test: add comprehensive tests for resolution delay and dispute window#287

Merged
greatest0fallt1me merged 3 commits intoPredictify-org:masterfrom
Georgechisom:test/resolution-delay-dispute-window-tests
Jan 31, 2026
Merged

test: add comprehensive tests for resolution delay and dispute window#287
greatest0fallt1me merged 3 commits intoPredictify-org:masterfrom
Georgechisom:test/resolution-delay-dispute-window-tests

Conversation

@Georgechisom
Copy link
Contributor

Summary

This pull request adds comprehensive test coverage for the resolution delay and dispute window functionality in the Predictify Hybrid contract. The tests verify that:

  1. Payout blocking during dispute windows - Ensures payouts are blocked while disputes are active
  2. Payout allowed after window closes - Verifies payouts work correctly after dispute windows expire
  3. Dispute creation and resolution - Tests the full dispute lifecycle
  4. Per-event vs global window behavior - Confirms each market has independent dispute windows
  5. Edge cases - Covers boundary conditions, exact timestamp matches, and extreme values
  6. Full lifecycle integration - Tests complete market flow with disputes

Test Coverage

Added 15 comprehensive tests in resolution_delay_dispute_window_tests.rs:

Payout Blocking Tests (3 tests)

  • test_payout_blocked_during_dispute_window - Verifies payouts are blocked during active dispute window
  • test_payout_allowed_after_dispute_window_closes - Confirms payouts work after window expires
  • test_payout_blocked_with_active_dispute - Tests payout blocking with disputed market state

Dispute Creation Tests (2 tests)

  • test_dispute_creation_during_window - Validates dispute creation within allowed timeframe
  • test_dispute_extends_market_deadline - Confirms dispute filing extends market deadline by configured hours

Per-Event vs Global Window Tests (2 tests)

  • test_per_event_dispute_window - Verifies each market has independent dispute windows
  • test_global_dispute_extension_constant - Confirms global constant is properly configured (24 hours default)

Edge Case Tests (5 tests)

  • test_zero_dispute_window_not_allowed - Ensures dispute window cannot be zero
  • test_very_long_dispute_window - Tests extended dispute windows (168 hours / 1 week)
  • test_exact_timestamp_match_at_window_boundary - Validates behavior at exact boundary timestamps
  • test_dispute_window_boundary_exact_expiry - Tests exact dispute window expiration
  • test_multiple_disputes_extend_once - Verifies multiple users can add dispute stakes and extension logic

Resolution Delay Tests (2 tests)

  • test_resolution_blocked_before_end_time - Confirms markets cannot be resolved before end time
  • test_resolution_allowed_after_end_time - Validates resolution is allowed after end time

Full Lifecycle Test (1 test)

  • test_full_lifecycle_with_dispute_window - Complete integration test covering:
    • Market creation
    • Advancing to end time
    • Market ending
    • Dispute filing
    • Dispute window enforcement
    • Post-dispute finalization

Implementation Details

  • Uses soroban_sdk::testutils for ledger timestamp mocking
  • Implements TestSetup helper struct for consistent test environment
  • All tests properly set market state to Ended before filing disputes (per state machine requirements)
  • Tests verify time-based logic using env.ledger().timestamp()
  • Validates dispute extension uses DISPUTE_EXTENSION_HOURS constant (24 hours default)

Test Results

running 15 tests
test resolution_delay_dispute_window_tests::test_dispute_creation_during_window ... ok
test resolution_delay_dispute_window_tests::test_dispute_extends_market_deadline ... ok
test resolution_delay_dispute_window_tests::test_dispute_window_boundary_exact_expiry ... ok
test resolution_delay_dispute_window_tests::test_exact_timestamp_match_at_window_boundary ... ok
test resolution_delay_dispute_window_tests::test_full_lifecycle_with_dispute_window ... ok
test resolution_delay_dispute_window_tests::test_global_dispute_extension_constant ... ok
test resolution_delay_dispute_window_tests::test_multiple_disputes_extend_once ... ok
test resolution_delay_dispute_window_tests::test_payout_allowed_after_dispute_window_closes ... ok
test resolution_delay_dispute_window_tests::test_payout_blocked_during_dispute_window ... ok
test resolution_delay_dispute_window_tests::test_payout_blocked_with_active_dispute ... ok
test resolution_delay_dispute_window_tests::test_per_event_dispute_window ... ok
test resolution_delay_dispute_window_tests::test_resolution_allowed_after_end_time ... ok
test resolution_delay_dispute_window_tests::test_resolution_blocked_before_end_time ... ok
test resolution_delay_dispute_window_tests::test_very_long_dispute_window ... ok
test resolution_delay_dispute_window_tests::test_zero_dispute_window_not_allowed ... ok

test result: ok. 15 passed; 0 failed; 0 ignored; 0 measured; 453 filtered out

Full test suite: 468 tests passed (including the 15 new tests)

Coverage Analysis

The new tests achieve comprehensive coverage of:

  • ✅ Dispute window time-based logic
  • ✅ Market state transitions (Active → Ended → Disputed → Resolved → Closed)
  • ✅ Payout blocking during dispute periods
  • ✅ Dispute extension mechanism
  • ✅ Per-market dispute window independence
  • ✅ Edge cases and boundary conditions
  • ✅ Full lifecycle integration

Estimated coverage: >95% of resolution delay and dispute window functionality

Files Changed

  • contracts/predictify-hybrid/src/resolution_delay_dispute_window_tests.rs (new file, 500+ lines)
  • contracts/predictify-hybrid/src/lib.rs (added module declaration)

Notes

  • All tests follow Soroban SDK testing best practices
  • Tests are deterministic and use mocked ledger timestamps
  • No external dependencies or network calls required
  • Tests validate both happy paths and error conditions

Closes #264

@Georgechisom
Copy link
Contributor Author

Thank you for your efforts, pls kindly give me some compliments

@Georgechisom
Copy link
Contributor Author

conflict resolved, kindly merge

@greatest0fallt1me greatest0fallt1me merged commit 00869de into Predictify-org:master Jan 31, 2026
1 check 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.

test: add comprehensive tests for resolution delay and dispute window

2 participants