Fix 87#191
Open
Hydrax117 wants to merge 2 commits into
Open
Conversation
|
@Hydrax117 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.
Pull Request — Issue #87
Title
test(progress): verify advance_level returns NotInitialized on uninitialized contractCloses
Closes #87
Summary
No test existed to confirm that calling
advance_levelon a contract that has never been initialized returns theNotInitializederror. This PR addsfn test_advance_level_not_initialized()to cover that guard path. No production code was changed.Changes
contracts/progress/src/lib.rsAdded
fn test_advance_level_not_initialized()inside the#[cfg(test)] mod testsblock.Acceptance Criteria
fn test_advance_level_not_initializedadded tomod testsinitializeregister_contractcalled,initializedeliberately skippedadvance_levelattemptedtry_advance_levelinvokedNotInitializedassert_eq!(result, Err(Ok(ProgressError::NotInitialized)))require_initializedDesign Notes
setup()— the shared helper callsinitialize, which would defeat the purpose of the test. The contract is registered inline and initialization is deliberately omitted.try_advance_level(theResult-returning client variant) rather than#[should_panic]. This pins the specific error variant so the test gives a precise failure message if the error code ever changes or the wrong guard fires, rather than passing on any panic.Err(Ok(ProgressError::NotInitialized))is the Soroban SDK's typed error shape: the outerErrmeans the invocation returned a contract error; the innerOkmeans it decoded cleanly into theProgressErrorenum.advance_level:require_not_pausedruns beforerequire_initialized. On an uninitialized contract thePausedkey is absent and defaults tofalse, so execution reachesrequire_initializedand returnsNotInitializedas expected.player_id = 99andmilestone_ref = 1are arbitrary values — the call never reaches the point where they matter.How to Verify
Expected output:
Checklist
cargo test --workspacecargo clippy --workspace -- -D warningscargo fmt --all -- --check