feat: resolve issues 438,439,442,440 — CI workflow, contributing guide…#466
Open
k2ghostyou wants to merge 1 commit into
Conversation
…e-Foundry#4 Core-Foundry#5 — CI workflow, contributing guide, get_all_groups tests, reduce_usage validation, bug report template === Issue Core-Foundry#1: Add GitHub Actions workflow for running tests === Problem: Contributors had no automated way to verify their changes didn't break the contract test suite — they had to run cargo test manually. Solution: Created .github/workflows/test.yml - Triggers on every push and pull_request targeting the main branch - Checks out the repository with actions/checkout@v4 - Installs the stable Rust toolchain via actions-rs/toolchain@v1 - Adds the wasm32-unknown-unknown target required by Soroban contracts - Caches ~/.cargo/registry, ~/.cargo/git, and contract/target keyed on Cargo.lock to keep CI fast across runs - Runs 'cargo test --verbose' from contract/contracts/hello-world File added: .github/workflows/test.yml === Issue Core-Foundry#2: Create a CONTRIBUTING.md guide === Problem: New contributors had no single root-level document explaining how to fork the repo, install the required tools (Rust, wasm32 target, Stellar CLI, Node.js), build the project, run all test suites, and submit a pull request. Solution: Rewrote CONTRIBUTING.md at the repository root with: - Prerequisites table (Rust, wasm32, Stellar CLI, Node.js, Git) with install links - Fork-and-clone workflow including upstream remote setup - Step-by-step build instructions for the contract, listener, and dashboard - Running tests section covering cargo test, npm test (listener), npm test (dashboard) - Pull request process with branch naming conventions, Conventional Commits format, and a PR checklist - Code style guidelines for both Rust (cargo fmt, doc comments) and TypeScript - Code of conduct section File modified: CONTRIBUTING.md === Issue Core-Foundry#3: Add unit tests for get_all_groups === Problem: The get_all_groups function in autoshare_logic.rs had no dedicated unit tests verifying its behaviour under different conditions. Solution: Added four focused unit tests to autoshare_test.rs: 1. test_get_all_groups — verifies the function returns an empty vec on a fresh contract with no groups created. 2. test_get_all_groups_returns_all_created_groups — creates three groups under two different creators and asserts all three appear in insertion order. 3. test_get_all_groups_includes_deactivated_groups — creates two groups, deactivates one, then asserts get_all_groups still returns both and that their is_active flags reflect the correct state. 4. test_get_all_groups_correct_group_details — creates a single group with specific field values (id, creator, usage_count) and asserts every detail field returned by get_all_groups matches the original creation arguments. File modified: contract/contracts/hello-world/src/tests/autoshare_test.rs === Issue Core-Foundry#4: Fix reduce_usage dummy function logic === Problem: The reduce_usage function was previously noted as a 'dummy function for testing' that simply subtracted 1 from usage_count with minimal validation and no tests for edge cases or authorization failures. The production implementation now correctly enforces: - caller.require_auth() — Soroban-level signature verification - Authorization check: only the group creator may reduce usage - Group state check: inactive groups are rejected (GroupInactive) - Usage guard: zero remaining usages return NoUsagesRemaining Six comprehensive unit tests were added to prove every code path: 1. test_reduce_usage_success — creator reduces by 1, count decrements correctly. 2. test_reduce_usage_unauthorized_caller_fails (#[should_panic]) — a non-creator address is rejected with Unauthorized. 3. test_reduce_usage_on_inactive_group_fails (#[should_panic]) — calling reduce_usage on a deactivated group returns GroupInactive. 4. test_reduce_usage_when_zero_remaining_fails (#[should_panic]) — exhausts the single usage then asserts the second call panics with NoUsagesRemaining. 5. test_reduce_usage_non_existent_group_fails (#[should_panic]) — a phantom BytesN<32> id panics with NotFound. 6. test_reduce_usage_multiple_times_decrements_correctly — starts with 5 usages, reduces in a loop, asserts the counter at each step, and finally confirms that total_usages_paid is unaffected by reduce_usage calls. File modified: contract/contracts/hello-world/src/tests/autoshare_test.rs === Issue Core-Foundry#5: Add Bug Report Issue Template === Problem: Bug reporters had no standardized format, so maintainers often received incomplete reports missing OS, Rust version, or reproduction steps. Solution: Created .github/ISSUE_TEMPLATE/bug_report.md with GitHub issue template front-matter and the following sections: - Description (clear and concise summary of the bug) - Steps to Reproduce (numbered step list) - Expected Behavior - Actual Behavior - Screenshots / Logs (fenced code block for paste) - Environment (OS, Rust version, Cargo version, Stellar CLI version, Node.js version, affected component) - Additional Context (transaction hashes, contract IDs, network details) File added: .github/ISSUE_TEMPLATE/bug_report.md Closes Core-Foundry#1, Closes Core-Foundry#2, Closes Core-Foundry#3, Closes Core-Foundry#4, Closes Core-Foundry#5
|
@k2ghostyou 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.
=== Issue #438 : Add GitHub Actions workflow for running tests === Problem: Contributors had no automated way to verify their changes didn't break the contract test suite — they had to run cargo test manually.
Solution: Created .github/workflows/test.yml
File added: .github/workflows/test.yml
=== Issue #439 : Create a CONTRIBUTING.md guide ===
Problem: New contributors had no single root-level document explaining how to fork the repo, install the required tools (Rust, wasm32 target, Stellar CLI, Node.js), build the project, run all test suites, and submit a pull request.
Solution: Rewrote CONTRIBUTING.md at the repository root with:
File modified: CONTRIBUTING.md
=== Issue #442 : Fix reduce_usage dummy function logic === Problem: The reduce_usage function was previously noted as a 'dummy function for testing' that simply subtracted 1 from usage_count with minimal validation and no tests for edge cases or authorization failures.
The production implementation now correctly enforces:
Six comprehensive unit tests were added to prove every code path:
test_reduce_usage_success — creator reduces by 1, count decrements correctly.
test_reduce_usage_unauthorized_caller_fails (#[should_panic]) — a non-creator address is rejected with Unauthorized.
test_reduce_usage_on_inactive_group_fails (#[should_panic]) — calling reduce_usage on a deactivated group returns GroupInactive.
test_reduce_usage_when_zero_remaining_fails (#[should_panic]) — exhausts the single usage then asserts the second call panics with NoUsagesRemaining.
test_reduce_usage_non_existent_group_fails (#[should_panic]) — a phantom BytesN<32> id panics with NotFound.
test_reduce_usage_multiple_times_decrements_correctly — starts with 5 usages, reduces in a loop, asserts the counter at each step, and finally confirms that total_usages_paid is unaffected by reduce_usage calls.
File modified: contract/contracts/hello-world/src/tests/autoshare_test.rs
=== Issue #440 : Add Bug Report Issue Template ===
Problem: Bug reporters had no standardized format, so maintainers often received incomplete reports missing OS, Rust version, or reproduction steps.
Solution: Created .github/ISSUE_TEMPLATE/bug_report.md with GitHub issue template front-matter and the following sections:
File added: .github/ISSUE_TEMPLATE/bug_report.md
Closes #438 , Closes #439 , Closes #442 , Closes #440 ,