Skip to content

Split EnvBase testutils-gated stuff into its own trait#1623

Draft
graydon wants to merge 1 commit intostellar:mainfrom
graydon:split-envbase-testutils-out
Draft

Split EnvBase testutils-gated stuff into its own trait#1623
graydon wants to merge 1 commit intostellar:mainfrom
graydon:split-envbase-testutils-out

Conversation

@graydon
Copy link
Copy Markdown
Contributor

@graydon graydon commented Dec 16, 2025

Superficial fix for #1570 lazily composed by claude. Whether this is actually a thing we want remains to be seen! Asking followup in the bug.

Copilot AI review requested due to automatic review settings December 16, 2025 00:26
@graydon graydon marked this pull request as draft December 16, 2025 00:27
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 refactors test-only functionality from the EnvBase trait into a separate EnvBaseTestUtils trait to better organize code that is only available when the testutils feature is enabled. This addresses issue #1570 by creating a cleaner separation between core environment functionality and test-specific utilities.

Key Changes:

  • Created new EnvBaseTestUtils trait in soroban-env-common/src/env.rs to hold test-only methods
  • Moved escalate_error_to_panic method and deprecated hook methods from EnvBase to the new trait
  • Updated implementations in both Host and Guest to implement the new trait separately

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
soroban-env-common/src/env.rs Defines new EnvBaseTestUtils trait with test-only methods moved from EnvBase
soroban-env-common/src/lib.rs Exports the new EnvBaseTestUtils trait when testutils feature is enabled
soroban-env-host/src/host.rs Moves escalate_error_to_panic implementation to separate EnvBaseTestUtils impl block
soroban-env-guest/src/guest.rs Moves escalate_error_to_panic implementation to separate EnvBaseTestUtils impl block and adds import

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Member

@leighmcculloch leighmcculloch left a comment

Choose a reason for hiding this comment

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

👏🏻 🎉 ❤️ Thank you!

Comment on lines 73 to 75
/// Return true if the environment wants to receive trace calls and and
/// returns using [`Self::trace_env_call`] and [`Self::trace_env_ret`].
#[cfg(feature = "std")]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The cfg's around these functions gated by a feature could potentially create the same problem in the future.

@leighmcculloch
Copy link
Copy Markdown
Member

Because this change modifies an exported trait, it's a breaking change, so it's going to need to target v26. Is that the intent?

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.

3 participants