Skip to content

Rename assert_in_contract to debug_assert_in_contract#1806

Merged
mootz12 merged 7 commits intomainfrom
debug-assert-in-contract
Apr 8, 2026
Merged

Rename assert_in_contract to debug_assert_in_contract#1806
mootz12 merged 7 commits intomainfrom
debug-assert-in-contract

Conversation

@mootz12
Copy link
Copy Markdown
Contributor

@mootz12 mootz12 commented Mar 31, 2026

What

Rename's assert_in_contract to debug_assert_in_contract, and adds a #[doc(hidden)] tag.

assert_in_contract was 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 version macro was deprecated instead, just need a minor release

Copilot AI review requested due to automatic review settings March 31, 2026 20:26
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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! to debug_assert_in_contract! and mark it #[doc(hidden)].
  • Update Storage accessors to use the renamed macro.
  • Update Prng methods/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>
@mootz12 mootz12 requested a review from a team April 8, 2026 00:31
@mootz12 mootz12 enabled auto-merge April 8, 2026 18:35
@mootz12 mootz12 added this pull request to the merge queue Apr 8, 2026
Merged via the queue into main with commit 8ce917a Apr 8, 2026
111 checks passed
@mootz12 mootz12 deleted the debug-assert-in-contract branch April 8, 2026 19:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

assert_in_contract! is a no-op in production builds and needs clarification

4 participants