Skip to content

test: add comprehensive tests for normalize and dynamic emissions modules#187

Closed
avantikau wants to merge 1 commit intoentrius:testfrom
avantikau:add-normalize-and-dynamic-emissions-tests
Closed

test: add comprehensive tests for normalize and dynamic emissions modules#187
avantikau wants to merge 1 commit intoentrius:testfrom
avantikau:add-normalize-and-dynamic-emissions-tests

Conversation

@avantikau
Copy link

Summary

  • Adds 37 unit tests covering two previously untested critical pipeline functions: normalize_rewards_linear() in normalize.py and apply_dynamic_emissions_using_network_contributions() in dynamic_emissions.py
  • These modules sit at the core of the reward distribution pipeline (scoring -> tier emissions -> normalization -> dynamic emissions) but had zero test coverage
  • All 236 tests pass (199 existing + 37 new), no production code was modified

Test Coverage Added

Test Class Count Module Tested
TestNormalizeRewardsLinear 13 normalize.py
TestExponentialUnlockScalar 6 dynamic_emissions.py
TestGetNetworkTotals 6 dynamic_emissions.py
TestApplyDynamicEmissions 9 dynamic_emissions.py
TestNormalizeToDynamicEmissionsPipeline 3 Both (integration)

Key scenarios tested:

  • Normalization invariants: sum-to-one, proportion preservation, division-by-zero protection
  • Edge cases: empty inputs, all-zero scores, single miner, very small/large values
  • Exponential unlock curve: boundary values (0 and 1), monotonic increase, mathematical correctness
  • Network totals aggregation: duplicate repo deduplication, inactive miner filtering
  • Dynamic emissions: recycling to RECYCLE_UID, emission conservation, low/high network contribution scenarios
  • End-to-end pipeline: full normalize -> dynamic emissions flow verification

Test plan

  • All 37 new tests pass locally (pytest tests/validator/test_normalize_and_dynamic_emissions.py -v)
  • Full test suite passes (pytest tests/ -v — 236 tests, 0 failures)
  • No production code modified

🤖 Generated with Claude Code

…ules

Add 37 unit tests covering two previously untested critical pipeline
functions: normalize_rewards_linear() and
apply_dynamic_emissions_using_network_contributions().

Test classes:
- TestNormalizeRewardsLinear (13 tests): proportion preservation,
  sum-to-one invariant, zero-score handling, single miner, edge cases
- TestExponentialUnlockScalar (6 tests): boundary values, monotonicity,
  mathematical correctness of the unlock curve
- TestGetNetworkTotals (6 tests): aggregation logic, empty inputs,
  duplicate repo deduplication, inactive miner filtering
- TestApplyDynamicEmissions (9 tests): recycling to RECYCLE_UID,
  emission conservation, low/high network contribution scenarios
- TestNormalizeToDynamicEmissionsPipeline (3 tests): end-to-end
  integration verifying the full normalize -> dynamic emissions flow

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@anderdc anderdc closed this Feb 13, 2026
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