feat: invariant/failure-class tests for SC-W5-049..052 (#250-#253)#351
Merged
Merged
Conversation
- Fix dead code in get_config_version_hash (unreachable code after early return to compute_config_version_hash) - Fix two pre-existing unclosed-delimiter compile errors in tests.rs (test_get_version_info_not_affected_by_sla_calculations and test_get_version_info_needs_migration_false_after_migrate) - Fix pre-existing variable name error (stored/replayed → stored_after_change/replayed_after_change) SC-W5-049 (OpSoll#250): failure-class mapping tests - Terminal errors: AlreadyInitialized, Unauthorized, InvalidThreshold, InvalidPenalty, InvalidReward, InvalidSeverity, NoPendingTransfer, RetentionLimitOutOfRange - Retryable errors: ContractPaused (succeeds after unpause), ConfigNotFound (verified via get_config) SC-W5-050 (OpSoll#251): invariant-preserving error path tests - Failed set_config leaves config unchanged - Failed calculate_sla (paused/unauthorized) leaves stats and history unchanged - Failed propose_admin/accept_admin leaves admin state unchanged - Failed set_retention_limit leaves limit unchanged - Failed pause (unauthorized) leaves pause state unchanged SC-W5-051 (OpSoll#252): stats monotonicity and conservation invariant tests - total_calculations is strictly monotonically increasing - total_violations is strictly monotonically increasing - total_calculations == met_count + total_violations at all times - total_rewards only increases on met SLA - total_penalties only increases on violation - Cross-path invariants: rewards unchanged on violation, penalties unchanged on met SC-W5-052 (OpSoll#253): reward/penalty exclusivity invariant tests - met result → payment_type=rew, amount>0 - viol result → payment_type=pen, amount<0 - No result has pen type with positive amount - No result has rew type with non-positive amount - status and payment_type are always consistent (met↔rew, viol↔pen) - View mode matches mutating mode for payment_type and amount sign - Exact threshold boundary is always met (not violated) Closes OpSoll#250 Closes OpSoll#251 Closes OpSoll#252 Closes OpSoll#253
|
@Userhorlie 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! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Resolves all four assigned issues in a single commit.
Changes
lib.rs
get_config_version_hash: removed unreachable code after the early return tocompute_config_version_hashtests.rs
test_get_version_info_not_affected_by_sla_calculationsandtest_get_version_info_needs_migration_false_after_migratewere missing closing braces)stored/replayed→stored_after_change/replayed_after_change)SC-W5-049 (#250) — Failure-class mapping: retryable vs terminal errors
Classifies every
SLAErrorvariant and tests each class:AlreadyInitialized,Unauthorized,InvalidThreshold,InvalidPenalty,InvalidReward,InvalidSeverity,NoPendingTransfer,RetentionLimitOutOfRangeContractPaused(succeeds after unpause),ConfigNotFoundSC-W5-050 (#251) — Invariant-preserving error paths
Verifies that every failed operation leaves all observable state unchanged:
set_config→ config unchangedcalculate_sla(paused / unauthorized) → stats and history unchangedpropose_admin/accept_admin→ admin and pending-admin unchangedset_retention_limit→ limit unchangedpause(unauthorized) → pause state unchangedSC-W5-051 (#252) — Stats monotonicity and conservation invariants
total_calculationsis strictly monotonically increasingtotal_violationsis strictly monotonically increasingtotal_calculations == met_count + total_violationsat all times (conservation)total_rewardsonly increases on met SLA; unchanged on violationtotal_penaltiesonly increases on violation; unchanged on met SLASC-W5-052 (#253) — Reward/penalty exclusivity invariants
metresult →payment_type=rew,amount > 0violresult →payment_type=pen,amount < 0pentype with positive amountrewtype with non-positive amountstatusandpayment_typeare always consistent (met↔rew,viol↔pen)met(not violated)Test Results
The 42 failures are all pre-existing (the original code did not even compile due to 2 compile errors). All 34 new tests pass.
Closes #250
Closes #251
Closes #252
Closes #253