Comprehensive Tests for carbon credit registry contract#101
Merged
salazarsebas merged 10 commits intoScaffoldRust:mainfrom Oct 4, 2025
FrankiePower:test-carbon-credit-registry
Merged
Comprehensive Tests for carbon credit registry contract#101salazarsebas merged 10 commits intoScaffoldRust:mainfrom FrankiePower:test-carbon-credit-registry
salazarsebas merged 10 commits intoScaffoldRust:mainfrom
FrankiePower:test-carbon-credit-registry
Conversation
Contributor
Author
|
@salazarsebas this PR is ready to be reviewed and merged |
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.
Pull Request: Comprehensive Tests for Carbon Credit Registry
📌 Description
This PR modularizes the test suite for the
carbon-credit-registrycontract, organizing tests into focused modules and adding comprehensive edge case coverage. The implementation creates 31 comprehensive tests across three modules (issuance, trading, retirement), with reusable test utilities for improved maintainability and compliance verification.closes #59
📌 Type of Change
🎯 Motivation and Context
This PR addresses the need for comprehensive test coverage for the carbon credit registry system. The previous implementation had an empty
test.rsfile with no tests. This implementation provides:🛠️ How to Test the Changes
Navigate to contract directory:
cd soroban/contracts/carbon-credit-registryRun all tests:
cargo test✅ Checklist Before Merging
📝 Notes
Unique Credit ID Generation: Implemented timestamp-based uniqueness in test utilities to ensure each issued credit receives a unique ID. Both
issue_test_credit()andissue_credit_with_params()now embed the current ledger timestamp in verification hashes and increment the timestamp after each issuance.Compliance Ready: All tests verify carbon credit standards compliance with proper audit logging through credit history tracking.
Integration Note: Tests are designed to validate integration with renewable-energy-certificate-tracker for renewable energy offsets (as mentioned in requirements).
Conclusion
This PR successfully implements comprehensive test coverage for the carbon-credit-registry contract, providing robust verification of credit issuance, trading, and retirement flows. The modular structure ensures compliant and transparent carbon credit management through well-organized tests that verify data integrity, authorization, and audit logging at every stage of the credit lifecycle.