diff --git a/soroban-env-host/src/host.rs b/soroban-env-host/src/host.rs index a47ab8c33..3faf67096 100644 --- a/soroban-env-host/src/host.rs +++ b/soroban-env-host/src/host.rs @@ -744,17 +744,10 @@ impl Host { self.create_contract_internal(Some(deployer), args, constructor_args_vec) } - pub fn check_same_env(&self, other: &Self) -> Result<(), HostError> { - if Rc::ptr_eq(&self.0, &other.0) { - Ok(()) - } else { - Err(self.err( - ScErrorType::Context, - ScErrorCode::InternalError, - "check_same_env on different Hosts", - &[], - )) - } + /// Returns true if the Host contains the same instance of HostImpl and therefore changes to + /// one will be observable via the other. If true, both are essentially the same Host. + pub fn is_same(&self, other: &Self) -> bool { + Rc::ptr_eq(&self.0, &other.0) } } diff --git a/soroban-env-host/src/test/host.rs b/soroban-env-host/src/test/host.rs index b68818b0e..926ee01bc 100644 --- a/soroban-env-host/src/test/host.rs +++ b/soroban-env-host/src/test/host.rs @@ -7,6 +7,17 @@ use crate::{ Env, Host, HostError, }; +#[test] +fn is_same_host_impl() { + let host1 = Host::default(); + let host1_clone = host1.clone(); + let host2 = Host::default(); + + assert!(host1.is_same(&host1)); + assert!(host1.is_same(&host1_clone)); + assert!(!host1.is_same(&host2)); +} + #[test] fn invalid_object_handles() -> Result<(), HostError> { let create_host = || -> Result {