Skip to content

test(dpp): add numerical assertions to evaluate_interval distribution tests#3102

Merged
PastaPastaPasta merged 3 commits into
dashpay:v3.1-devfrom
thepastaclaw:fix/tautological-evaluate-interval-tests
Feb 20, 2026
Merged

test(dpp): add numerical assertions to evaluate_interval distribution tests#3102
PastaPastaPasta merged 3 commits into
dashpay:v3.1-devfrom
thepastaclaw:fix/tautological-evaluate-interval-tests

Conversation

@thepastaclaw

@thepastaclaw thepastaclaw commented Feb 18, 2026

Copy link
Copy Markdown
Collaborator

Problem

The 72 tests in evaluate_interval.rs verify distribution function outputs by comparing explanation strings. But the expected string is built from the result itself:

let result = dist.evaluate_interval_with_explanation(...).unwrap();

// ❌ Expected string uses result.total_amount — the thing we're testing!
let expected = format!("...{} tokens", format_number_with_separators(result.total_amount));
assert_eq!(result.short_explanation(...), expected);

If the function computes 999 when it should be 1,000, the test builds an expected string with 999, compares to the actual string with 999, and passes. The numerical correctness assertion is tautological — it can never fail.

Fix

Added 30 explicit assert_eq!(result.total_amount, <expected_value>) assertions before the existing string comparisons:

let result = dist.evaluate_interval_with_explanation(...).unwrap();

// ✅ New: independently computed expected value
assert_eq!(result.total_amount, 1_850_000);

// Existing string assertion preserved (still tests formatting)
let expected = format!("...{} tokens", format_number_with_separators(result.total_amount));
assert_eq!(result.short_explanation(...), expected);

Assertions added by distribution type:

  • Epoch-based (9): Random, StepDecreasing, Stepwise, Linear, Polynomial, Exponential, Logarithmic, InvertedLogarithmic
  • Block-based (13): All distribution function types
  • Time-based (8): Linear, Stepwise, Random, StepDecreasing

Reward-ratio tests already had proper numerical assertions — no changes needed.

Verification

All 72 tests pass: cargo test -p dpp --lib --features token-reward-explanations -- evaluate_interval

Found during SDK test quality audit (tracker thepastaclaw/tracker#13).

Summary by CodeRabbit

  • Tests
    • Extended test coverage for token distribution interval evaluation with additional validation checks across multiple distribution scenarios.

thepastaclaw and others added 3 commits February 18, 2026 12:24
Add explicit assert_eq!(result.total_amount, <expected>) checks before
tautological string comparisons in epoch_tests module. This ensures
the numerical correctness of total_amount is independently verified.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add explicit assert_eq!(result.total_amount, <expected>) checks before
tautological string comparisons in block_tests module. This ensures
the numerical correctness of total_amount is independently verified.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add explicit assert_eq!(result.total_amount, <expected>) checks before
tautological string comparisons in time_interval_tests module. This ensures
the numerical correctness of total_amount is independently verified.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Feb 18, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉


📝 Walkthrough

Walkthrough

This pull request adds validation assertions to existing test cases for interval evaluation, checking computed total_amount values across multiple distribution function types (Fixed, Random, StepDecreasing, Stepwise, Linear, Polynomial, Exponential, Logarithmic, and time/block/epoch-based variants). No functional logic is modified.

Changes

Cohort / File(s) Summary
Test Assertions for Interval Evaluation
packages/rs-dpp/src/data_contract/associated_token/token_perpetual_distribution/distribution_function/evaluate_interval.rs
Added total_amount value assertions across 12+ test cases for various distribution function types without altering control flow or error handling.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 Hop, hop! New tests bloom bright,
Validating totals, left and right,
No logic bends, just checks we add,
More confidence makes this bunny glad! 🥕✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding numerical assertions to test cases in evaluate_interval distribution tests to replace tautological string comparisons.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@thepastaclaw

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Feb 18, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@PastaPastaPasta

Copy link
Copy Markdown
Member

I've ran tests; and confirmed this works. Merging

@PastaPastaPasta PastaPastaPasta merged commit 1f0ab59 into dashpay:v3.1-dev Feb 20, 2026
49 of 70 checks 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.

3 participants