Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 4 additions & 11 deletions soroban-env-host/src/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Comment thread
anupsdf marked this conversation as resolved.
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)
}
}

Expand Down
11 changes: 11 additions & 0 deletions soroban-env-host/src/test/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Host, HostError> {
Expand Down