Skip to content

test: add property tests for auction curve monotonicity - #1207

Open
blazesgl wants to merge 1 commit into
Creditra:mainfrom
blazesgl:feat/1160-add-stepped-decay-monotonicity-proptest
Open

blazesgl wants to merge 1 commit into
Creditra:mainfrom
blazesgl:feat/1160-add-stepped-decay-monotonicity-proptest

Conversation

@blazesgl

@blazesgl blazesgl commented Sep 1, 2026

Copy link
Copy Markdown

Summary

Add property-based monotonicity tests for the Stepped decay curve in Dutch auctions, closing the coverage gap identified in #1160.

Why this matters

The existing property tests in tests/curves.rs verify monotonicity for Linear and Exponential decay modes but were missing dedicated coverage for Stepped decay. This gap means regressions in the Stepped decay price calculation could go undetected.

Changes

tests/curves.rs (integration tests)

  • price_never_increases_stepped — 100-case proptest verifying compute_dutch_price produces non-increasing prices over time for Stepped decay with randomized start_price, floor_price, step_count, and t.

src/curves.rs (unit tests)

  • stepped_price_never_increases — Deterministic test verifying calculate_price with Stepped decay is non-increasing over 100 time steps.
  • stepped_price_never_increases_various_intervals — Tests the same property across 6 different interval configurations (1, 3, 5, 10, 20, 50).
  • stepped_monotonic_proptest — 100-case proptest verifying calculate_price with randomized start_price, step_size, interval, and t.

Test strategy

The new tests verify the fundamental invariant that Dutch auction prices never increase over time for the Stepped decay mode. This property is critical because:

  1. Bidders must not be able to pay less by waiting longer (except at step boundaries)
  2. The auction mechanism must be fair and predictable
  3. Price regression would indicate a bug in the decay calculation

The tests complement the existing Kani formal verification proofs in proofs/dutch_price.rs which already prove this property for all decay modes, but the proptests provide an additional runtime safety net with randomized inputs.

Validation

  • cargo fmt --check passes
  • Code follows existing test patterns in the codebase
  • No production code changes; test-only additions

Closes #1160

Add proptest-based monotonicity verification for the Stepped decay
curve in Dutch auctions, closing the gap in property test coverage.

Changes:
- tests/curves.rs: Add price_never_increases_stepped proptest for
  compute_dutch_price with Stepped decay (100 cases)
- src/curves.rs: Add stepped_price_never_increases deterministic test
  for calculate_price
- src/curves.rs: Add stepped_price_never_increases_various_intervals
  testing multiple interval configurations
- src/curves.rs: Add stepped_monotonic_proptest for calculate_price
  with randomized parameters (100 cases)

The new tests verify that Stepped decay prices are non-increasing over
time, matching the existing coverage for Linear and Exponential decay
modes.

Closes Creditra#1160
@drips-wave

drips-wave Bot commented Sep 1, 2026

Copy link
Copy Markdown

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

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.

[Quality-2][High] Add property tests for auction curve monotonicity

1 participant