Merged
Conversation
deaa967 to
8e416de
Compare
Contributor
Author
|
@1nonlypiece please review |
Contributor
|
please resolve the conflicts |
Contributor
Author
@1nonlypiece conflict resolved |
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.
Closes: #131
verify_compliance Implementation for Different Commitment States
Issue Description
The
verify_compliancefunction needed to return defined results for commitments in different states (settled, violated, active).Implementation
Changes Made
1. Updated
verify_complianceincontracts/attestation_engine/src/lib.rsThe function now handles all commitment states explicitly:
true(commitment was compliant until settlement)false(rule violation occurred)false(exited before maturity)false(safe default)2. Added Comprehensive Test Coverage in
contracts/attestation_engine/src/tests.rsAdded 7 new test cases:
test_verify_compliance_settled_commitment_returns_true- Verifies settled commitments return truetest_verify_compliance_violated_commitment_returns_false- Verifies violated commitments return falsetest_verify_compliance_early_exit_returns_false- Verifies early exit commitments return falsetest_verify_compliance_active_commitment_within_rules_returns_true- Verifies active commitments within rules return truetest_verify_compliance_active_commitment_exceeds_loss_returns_false- Verifies active commitments exceeding loss limit return falsetest_verify_compliance_nonexistent_commitment_returns_false- Verifies nonexistent commitments return falsetest_verify_compliance_uninitialized_contract_returns_false- Verifies uninitialized contract returns false3. Fixed Test Compilation Issues in
contracts/commitment_core/src/tests.rsAdded missing
grace_period_days: 0field to allCommitmentRulesstruct initializations that were missing it.Test Results
All tests pass successfully:
Workspace tests also pass:
Acceptance Criteria Met
✅
verify_compliance(commitment_id)when commitment status is "settled" → returnstrue✅
verify_compliance(commitment_id)when "violated" → returnsfalse✅
verify_compliance(commitment_id)when "early_exit" → returnsfalse✅
verify_compliance(commitment_id)when "active" and rules met → returnstrue✅
verify_compliance(commitment_id)when "active" and rules violated → returnsfalse✅ Behavior for non-active commitments is defined and tested
✅ All workspace tests pass without errors
CI Workflow Compatibility
The implementation is compatible with the
.github/workflows/soroban-contracts-ci.ymlworkflow:cargo build --target wasm32-unknown-unknown --releasecargo test --workspaceFiles Modified
contracts/attestation_engine/src/lib.rs- Updatedverify_compliancefunctioncontracts/attestation_engine/src/tests.rs- Added 7 comprehensive test casescontracts/commitment_core/src/tests.rs- Fixed missinggrace_period_daysfieldsDocumentation
The
verify_compliancefunction now includes comprehensive documentation explaining the behavior for each commitment state: