Skip to content

Commit

Permalink
gate the worker handle behind test utils
Browse files Browse the repository at this point in the history
  • Loading branch information
codabrink committed Dec 12, 2024
1 parent aa9cbe9 commit d81cd9d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion xmtp_mls/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ where
)
.await?;

let mut client = Client::new(
let client = Client::new(
api_client_wrapper,
identity,
store,
Expand Down
11 changes: 9 additions & 2 deletions xmtp_mls/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,11 @@ pub struct Client<ApiClient, V = RemoteSignatureVerifier<ApiClient>> {
pub(crate) context: Arc<XmtpMlsLocalContext>,
pub(crate) history_sync_url: Option<String>,
pub(crate) local_events: broadcast::Sender<LocalEvents<Self>>,
sync_worker_handle: Arc<Mutex<Option<Arc<WorkerHandle>>>>,
/// The method of verifying smart contract wallet signatures for this Client
pub(crate) scw_verifier: Arc<V>,

#[cfg(feature = "test-utils")]
sync_worker_handle: Arc<Mutex<Option<Arc<WorkerHandle>>>>,
}

// most of these things are `Arc`'s
Expand All @@ -157,8 +159,10 @@ impl<ApiClient, V> Clone for Client<ApiClient, V> {
context: self.context.clone(),
history_sync_url: self.history_sync_url.clone(),
local_events: self.local_events.clone(),
sync_worker_handle: self.sync_worker_handle.clone(),
scw_verifier: self.scw_verifier.clone(),

#[cfg(feature = "test-utils")]
sync_worker_handle: self.sync_worker_handle.clone(),
}
}
}
Expand Down Expand Up @@ -244,6 +248,7 @@ where
context,
history_sync_url,
local_events: tx,
#[cfg(feature = "test-utils")]
sync_worker_handle: Arc::new(Mutex::default()),
scw_verifier: scw_verifier.into(),
}
Expand All @@ -253,10 +258,12 @@ where
&self.scw_verifier
}

#[cfg(feature = "test-utils")]
pub fn sync_worker_handle(&self) -> Option<Arc<WorkerHandle>> {
self.sync_worker_handle.lock().clone()
}

#[cfg(feature = "test-utils")]
pub(crate) fn set_sync_worker_handle(&self, handle: Arc<WorkerHandle>) {
*self.sync_worker_handle.lock() = Some(handle);
}
Expand Down

0 comments on commit d81cd9d

Please sign in to comment.