Rename assert_in_contract to debug_assert_in_contract#1806
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates Soroban SDK’s internal “in-contract” assertion macro to better communicate its intended debugging/test-only role, and applies the rename to call sites that rely on it to produce clearer errors when env methods are invoked outside a contract context during tests.
Changes:
- Rename
assert_in_contract!todebug_assert_in_contract!and mark it#[doc(hidden)]. - Update
Storageaccessors to use the renamed macro. - Update
Prngmethods/traits to use the renamed macro.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
soroban-sdk/src/lib.rs |
Renames and hides the exported macro that checks “in contract” execution context in test/testutils builds. |
soroban-sdk/src/storage.rs |
Switches persistent(), temporary(), and instance() to call debug_assert_in_contract!. |
soroban-sdk/src/prng.rs |
Switches PRNG reseed/shuffle/gen/fill paths to call debug_assert_in_contract!. |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
jayz22
approved these changes
Apr 8, 2026
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.
What
Rename's
assert_in_contracttodebug_assert_in_contract, and adds a#[doc(hidden)]tag.assert_in_contractwas not deprecated as it's primarily a macro used internally.Why
This function is primarily for internal use to provide better errors to users invoking certain env methods during tests outside of the context of a contract.
Closes #1805
Known limitations
This is public interface change, and needs to wait for the next major versionmacro was deprecated instead, just need a minor release