diff --git a/xmtp_api_grpc/src/lib.rs b/xmtp_api_grpc/src/lib.rs index 10472c2a8..67dffa905 100644 --- a/xmtp_api_grpc/src/lib.rs +++ b/xmtp_api_grpc/src/lib.rs @@ -8,7 +8,7 @@ pub const DEV_ADDRESS: &str = "https://grpc.dev.xmtp.network:443"; pub use grpc_api_helper::Client; #[cfg(test)] -mod tests { +pub mod tests { use std::time::{SystemTime, UNIX_EPOCH}; use self::auth_token::Authenticator; diff --git a/xmtp_mls/Cargo.toml b/xmtp_mls/Cargo.toml index 28dbcc2f2..f00e8f83e 100644 --- a/xmtp_mls/Cargo.toml +++ b/xmtp_mls/Cargo.toml @@ -89,10 +89,8 @@ gloo-timers = { workspace = true, features = ["futures"] } [dev-dependencies] -ctor.workspace = true ethers.workspace = true mockall = "0.13.0" -mockito = "1.4.0" tracing-log = "0.2.0" tracing-test = "0.2.4" xmtp_id = { path = "../xmtp_id", features = ["test-utils"] } @@ -102,6 +100,8 @@ anyhow.workspace = true xmtp_api_grpc = { path = "../xmtp_api_grpc" } tracing-subscriber.workspace = true tempfile = "3.5.0" +mockito = "1.4.0" +ctor.workspace = true [target.'cfg(target_arch = "wasm32")'.dev-dependencies] xmtp_api_http = { path = "../xmtp_api_http" } diff --git a/xmtp_mls/src/api/identity.rs b/xmtp_mls/src/api/identity.rs index 93c7f6767..e75d240a0 100644 --- a/xmtp_mls/src/api/identity.rs +++ b/xmtp_mls/src/api/identity.rs @@ -151,7 +151,7 @@ where } #[cfg(test)] -mod tests { +pub(crate) mod tests { use super::super::test_utils::*; use super::GetIdentityUpdatesV2Filter; use crate::{api::ApiClientWrapper, retry::Retry}; diff --git a/xmtp_mls/src/api/test_utils.rs b/xmtp_mls/src/api/test_utils.rs index 973ab17b4..ffea784d3 100644 --- a/xmtp_mls/src/api/test_utils.rs +++ b/xmtp_mls/src/api/test_utils.rs @@ -38,6 +38,8 @@ pub fn build_group_messages(num_messages: usize, group_id: Vec) -> Vec Self { ApiClient } } } + +#[cfg(target_arch = "wasm32")] +mock! { + pub ApiClient {} + + impl ClientWithMetadata for ApiClient { + fn set_libxmtp_version(&mut self, version: String) -> Result<(), Error>; + fn set_app_version(&mut self, version: String) -> Result<(), Error>; + } + + #[async_trait::async_trait(?Send)] + impl XmtpMlsClient for ApiClient { + async fn upload_key_package(&self, request: UploadKeyPackageRequest) -> Result<(), Error>; + async fn fetch_key_packages( + &self, + request: FetchKeyPackagesRequest, + ) -> Result; + async fn send_group_messages(&self, request: SendGroupMessagesRequest) -> Result<(), Error>; + async fn send_welcome_messages(&self, request: SendWelcomeMessagesRequest) -> Result<(), Error>; + async fn query_group_messages(&self, request: QueryGroupMessagesRequest) -> Result; + async fn query_welcome_messages(&self, request: QueryWelcomeMessagesRequest) -> Result; + async fn subscribe_group_messages(&self, request: SubscribeGroupMessagesRequest) -> Result; + async fn subscribe_welcome_messages(&self, request: SubscribeWelcomeMessagesRequest) -> Result; + } + + #[async_trait::async_trait(?Send)] + impl XmtpIdentityClient for ApiClient { + async fn publish_identity_update(&self, request: PublishIdentityUpdateRequest) -> Result; + async fn get_identity_updates_v2(&self, request: GetIdentityUpdatesV2Request) -> Result; + async fn get_inbox_ids(&self, request: GetInboxIdsRequest) -> Result; + } + + #[async_trait::async_trait(?Send)] + impl XmtpTestClient for ApiClient { + async fn create_local() -> Self { ApiClient } + async fn create_dev() -> Self { ApiClient } + } +} diff --git a/xmtp_mls/src/builder.rs b/xmtp_mls/src/builder.rs index e58775179..20d8edeab 100644 --- a/xmtp_mls/src/builder.rs +++ b/xmtp_mls/src/builder.rs @@ -132,7 +132,7 @@ where } #[cfg(test)] -mod tests { +pub(crate) mod tests { use crate::api::ApiClientWrapper; use crate::builder::ClientBuilderError; use crate::identity::IdentityError; diff --git a/xmtp_mls/src/client.rs b/xmtp_mls/src/client.rs index 1756529ae..f7052b62a 100644 --- a/xmtp_mls/src/client.rs +++ b/xmtp_mls/src/client.rs @@ -746,7 +746,7 @@ pub fn deserialize_welcome(welcome_bytes: &Vec) -> Result for GroupUpdatedCodec { } #[cfg(test)] -mod tests { +pub(crate) mod tests { use xmtp_proto::xmtp::mls::message_contents::{group_updated::Inbox, GroupUpdated}; use crate::utils::test::rand_string; diff --git a/xmtp_mls/src/codecs/membership_change.rs b/xmtp_mls/src/codecs/membership_change.rs index 27359275a..8f46828a9 100644 --- a/xmtp_mls/src/codecs/membership_change.rs +++ b/xmtp_mls/src/codecs/membership_change.rs @@ -48,7 +48,7 @@ impl ContentCodec for GroupMembershipChangeCodec { } #[cfg(test)] -mod tests { +pub(crate) mod tests { use xmtp_proto::xmtp::mls::message_contents::MembershipChange; use crate::utils::test::{rand_string, rand_vec}; diff --git a/xmtp_mls/src/codecs/text.rs b/xmtp_mls/src/codecs/text.rs index 503443a86..6e79b65b6 100644 --- a/xmtp_mls/src/codecs/text.rs +++ b/xmtp_mls/src/codecs/text.rs @@ -54,7 +54,7 @@ impl ContentCodec for TextCodec { } #[cfg(test)] -mod tests { +pub(crate) mod tests { use crate::codecs::{text::TextCodec, ContentCodec}; #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] diff --git a/xmtp_mls/src/groups/group_membership.rs b/xmtp_mls/src/groups/group_membership.rs index 3d08e8468..aa6c687fb 100644 --- a/xmtp_mls/src/groups/group_membership.rs +++ b/xmtp_mls/src/groups/group_membership.rs @@ -113,7 +113,7 @@ pub struct MembershipDiff<'inbox_id> { } #[cfg(test)] -mod tests { +pub(crate) mod tests { use super::GroupMembership; #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] diff --git a/xmtp_mls/src/groups/group_permissions.rs b/xmtp_mls/src/groups/group_permissions.rs index 827c79cd7..e3af38463 100644 --- a/xmtp_mls/src/groups/group_permissions.rs +++ b/xmtp_mls/src/groups/group_permissions.rs @@ -1149,7 +1149,7 @@ impl std::fmt::Display for PreconfiguredPolicies { } #[cfg(test)] -mod tests { +pub(crate) mod tests { use crate::{ groups::{group_mutable_metadata::MetadataField, validated_commit::MutableMetadataChanges}, utils::test::{rand_string, rand_vec}, diff --git a/xmtp_mls/src/groups/intents.rs b/xmtp_mls/src/groups/intents.rs index 0296115b5..d04fa5fac 100644 --- a/xmtp_mls/src/groups/intents.rs +++ b/xmtp_mls/src/groups/intents.rs @@ -668,7 +668,7 @@ impl TryFrom> for PostCommitAction { } #[cfg(test)] -mod tests { +pub(crate) mod tests { use super::*; #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] diff --git a/xmtp_mls/src/groups/message_history.rs b/xmtp_mls/src/groups/message_history.rs index 0f0768397..686a50639 100644 --- a/xmtp_mls/src/groups/message_history.rs +++ b/xmtp_mls/src/groups/message_history.rs @@ -779,8 +779,8 @@ fn new_pin() -> String { format!("{:04}", pin) } -#[cfg(test)] -mod tests { +#[cfg(all(not(target_arch = "wasm32"), test))] +pub(crate) mod tests { const HISTORY_SERVER_HOST: &str = "0.0.0.0"; const HISTORY_SERVER_PORT: u16 = 5558; diff --git a/xmtp_mls/src/groups/mod.rs b/xmtp_mls/src/groups/mod.rs index 86a5aa4f7..a93fe846d 100644 --- a/xmtp_mls/src/groups/mod.rs +++ b/xmtp_mls/src/groups/mod.rs @@ -3,11 +3,11 @@ pub mod group_metadata; pub mod group_mutable_metadata; pub mod group_permissions; pub mod intents; -pub mod members; +pub(super) mod members; #[allow(dead_code)] pub mod message_history; -mod subscriptions; -mod sync; +pub(super) mod subscriptions; +pub(super) mod sync; pub mod validated_commit; use intents::SendMessageIntentData; @@ -1273,13 +1273,12 @@ fn build_group_join_config() -> MlsGroupJoinConfig { } #[cfg(test)] -mod tests { +pub(crate) mod tests { use diesel::connection::SimpleConnection; use futures::future::join_all; use openmls::prelude::{tls_codec::Serialize, Member, MlsGroup as OpenMlsGroup}; use prost::Message; use std::sync::Arc; - use tracing_test::traced_test; use xmtp_cryptography::utils::generate_local_wallet; use xmtp_proto::xmtp::mls::message_contents::EncodedContent; @@ -1607,8 +1606,11 @@ mod tests { not(target_arch = "wasm32"), tokio::test(flavor = "multi_thread", worker_threads = 1) )] - #[traced_test] + #[tracing_test::traced_test] async fn test_create_from_welcome_validation() { + if cfg!(target_arch = "wasm32") { + let _ = tracing_log::LogTracer::init_with_filter(log::LevelFilter::Debug); + } let alix = ClientBuilder::new_test_client(&generate_local_wallet()).await; let bo = ClientBuilder::new_test_client(&generate_local_wallet()).await; @@ -1950,7 +1952,10 @@ mod tests { } #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] - #[cfg_attr(not(target_arch = "wasm32"), tokio::test(flavor = "multi_thread", worker_threads = 10))] + #[cfg_attr( + not(target_arch = "wasm32"), + tokio::test(flavor = "multi_thread", worker_threads = 10) + )] async fn test_self_resolve_epoch_mismatch() { let amal = ClientBuilder::new_test_client(&generate_local_wallet()).await; let bola = ClientBuilder::new_test_client(&generate_local_wallet()).await; @@ -2070,7 +2075,6 @@ mod tests { assert_eq!(amal_group_pinned_frame_url, "pinned frame"); } - #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] #[cfg_attr(not(target_arch = "wasm32"), tokio::test(flavor = "current_thread"))] #[ignore] @@ -3009,7 +3013,10 @@ mod tests { } #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] - #[cfg_attr(not(target_arch = "wasm32"), tokio::test(flavor = "multi_thread", worker_threads = 5))] + #[cfg_attr( + not(target_arch = "wasm32"), + tokio::test(flavor = "multi_thread", worker_threads = 5) + )] async fn test_parallel_syncs() { let wallet = generate_local_wallet(); let alix1 = Arc::new(ClientBuilder::new_test_client(&wallet).await); @@ -3025,7 +3032,7 @@ mod tests { let client_clone = alix1.clone(); // Each of these syncs is going to trigger the client to invite alix2 to the group // because of the race - tokio::spawn(async move { group_clone.sync(&client_clone).await }) + crate::spawn(async move { group_clone.sync(&client_clone).await }) }) .collect(); @@ -3119,7 +3126,11 @@ mod tests { * We need to be safe even in situations where there are multiple * intents that do the same thing, leading to conflicts */ - #[tokio::test(flavor = "multi_thread", worker_threads = 5)] + #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] + #[cfg_attr( + not(target_arch = "wasm32"), + tokio::test(flavor = "multi_thread", worker_threads = 5) + )] async fn add_missing_installs_reentrancy() { let wallet = generate_local_wallet(); let alix1 = ClientBuilder::new_test_client(&wallet).await; @@ -3207,7 +3218,10 @@ mod tests { } #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] - #[cfg_attr(not(target_arch = "wasm32"), tokio::test(flavor = "multi_thread", worker_threads = 5))] + #[cfg_attr( + not(target_arch = "wasm32"), + tokio::test(flavor = "multi_thread", worker_threads = 5) + )] async fn respect_allow_epoch_increment() { let wallet = generate_local_wallet(); let client = ClientBuilder::new_test_client(&wallet).await; diff --git a/xmtp_mls/src/groups/subscriptions.rs b/xmtp_mls/src/groups/subscriptions.rs index c767dd418..3a468d7d1 100644 --- a/xmtp_mls/src/groups/subscriptions.rs +++ b/xmtp_mls/src/groups/subscriptions.rs @@ -162,7 +162,7 @@ impl MlsGroup { } #[cfg(test)] -mod tests { +pub(crate) mod tests { use super::*; use std::time::Duration; use tokio_stream::wrappers::UnboundedReceiverStream; @@ -243,7 +243,7 @@ mod tests { let notify_ptr = notify.clone(); let (tx, rx) = tokio::sync::mpsc::unbounded_channel(); let mut stream = UnboundedReceiverStream::new(rx); - tokio::spawn(async move { + crate::spawn(async move { let stream = bola_group_ptr.stream(bola_ptr).await.unwrap(); futures::pin_mut!(stream); while let Some(item) = stream.next().await { @@ -292,7 +292,7 @@ mod tests { let stream = tokio_stream::wrappers::UnboundedReceiverStream::new(rx); let amal_ptr = amal.clone(); let group_ptr = group.clone(); - tokio::spawn(async move { + crate::spawn(async move { let stream = group_ptr.stream(amal_ptr).await.unwrap(); futures::pin_mut!(stream); while let Some(item) = stream.next().await { @@ -339,7 +339,7 @@ mod tests { let (tx, rx) = tokio::sync::mpsc::unbounded_channel(); let (start_tx, start_rx) = tokio::sync::oneshot::channel(); let mut stream = UnboundedReceiverStream::new(rx); - tokio::spawn(async move { + crate::spawn(async move { let stream = amal_group_ptr.stream(amal_ptr).await.unwrap(); let _ = start_tx.send(()); futures::pin_mut!(stream); diff --git a/xmtp_mls/src/groups/sync.rs b/xmtp_mls/src/groups/sync.rs index 36b927da4..10ffe2a5d 100644 --- a/xmtp_mls/src/groups/sync.rs +++ b/xmtp_mls/src/groups/sync.rs @@ -1304,7 +1304,7 @@ fn decode_staged_commit(data: Vec) -> Result( #[cfg(test)] pub(crate) mod tests { use ethers::signers::LocalWallet; - use tracing_test::traced_test; use xmtp_cryptography::utils::generate_local_wallet; use xmtp_id::{ associations::{builder::SignatureRequest, AssociationState, RecoverableEcdsaSignature}, @@ -565,8 +564,11 @@ pub(crate) mod tests { #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] #[cfg_attr(not(target_arch = "wasm32"), tokio::test)] - #[traced_test] + #[tracing_test::traced_test] async fn cache_association_state() { + if cfg!(target_arch = "wasm32") { + let _ = tracing_log::LogTracer::init_with_filter(log::LevelFilter::Debug); + } let wallet = generate_local_wallet(); let wallet_2 = generate_local_wallet(); let wallet_address = wallet.get_address(); diff --git a/xmtp_mls/src/lib.rs b/xmtp_mls/src/lib.rs index 7caf5cdfb..5ac8e9c85 100644 --- a/xmtp_mls/src/lib.rs +++ b/xmtp_mls/src/lib.rs @@ -50,7 +50,8 @@ impl XmtpApi for T where } #[cfg(any(test, feature = "test-utils", feature = "bench"))] -#[async_trait::async_trait] +#[cfg_attr(target_arch = "wasm32", async_trait::async_trait(?Send))] +#[cfg_attr(not(target_arch = "wasm32"), async_trait::async_trait)] pub trait XmtpTestClient { async fn create_local() -> Self; async fn create_dev() -> Self; @@ -125,12 +126,13 @@ mod wasm_test { pub use crate::groups::group_membership::tests::*; pub use crate::groups::group_permissions::tests::*; pub use crate::groups::intents::tests::*; - pub use crate::groups::members::tests::*; + // message history test use `mockito` and `tempfile` + // which are incompatible with wasm since they use + // system sockets/files // pub use crate::groups::message_history::tests::*; pub use crate::groups::subscriptions::tests::*; pub use crate::groups::sync::tests::*; pub use crate::groups::tests::*; - pub use crate::groups::validated_commit::tests::*; pub use crate::identity_updates::tests::*; pub use crate::retry::tests::*; pub use crate::storage::encrypted_store::association_state::tests::*; @@ -146,14 +148,13 @@ mod wasm_test { } #[cfg(test)] -mod tests { +pub(crate) mod tests { use log::LevelFilter; - use tracing_test::traced_test; // Execute once before any tests are run - #[ctor::ctor] + #[cfg_attr(not(target_arch = "wasm32"), ctor::ctor)] // Capture traces in a variable that can be checked in tests, as well as outputting them to stdout on test failure - #[traced_test] + #[cfg_attr(not(target_arch = "wasm32"), tracing_test::traced_test)] fn setup() { // Capture logs (e.g. log::info!()) as traces too let _ = tracing_log::LogTracer::init_with_filter(LevelFilter::Debug); diff --git a/xmtp_mls/src/retry.rs b/xmtp_mls/src/retry.rs index 5585e6527..f91b2638c 100644 --- a/xmtp_mls/src/retry.rs +++ b/xmtp_mls/src/retry.rs @@ -214,7 +214,7 @@ impl RetryableError for xmtp_proto::api_client::Error { } #[cfg(test)] -mod tests { +pub(crate) mod tests { use super::*; use thiserror::Error; use tokio::sync::mpsc; diff --git a/xmtp_mls/src/storage/encrypted_store/association_state.rs b/xmtp_mls/src/storage/encrypted_store/association_state.rs index 97723f463..ff51966ae 100644 --- a/xmtp_mls/src/storage/encrypted_store/association_state.rs +++ b/xmtp_mls/src/storage/encrypted_store/association_state.rs @@ -119,7 +119,7 @@ impl StoredAssociationState { } #[cfg(test)] -mod tests { +pub(crate) mod tests { use crate::storage::encrypted_store::tests::with_connection; use super::*; diff --git a/xmtp_mls/src/storage/encrypted_store/group_intent.rs b/xmtp_mls/src/storage/encrypted_store/group_intent.rs index b5a90a1ba..18a5eb703 100644 --- a/xmtp_mls/src/storage/encrypted_store/group_intent.rs +++ b/xmtp_mls/src/storage/encrypted_store/group_intent.rs @@ -387,7 +387,7 @@ where } #[cfg(test)] -mod tests { +pub(crate) mod tests { use super::*; use crate::{ storage::encrypted_store::{ diff --git a/xmtp_mls/src/storage/encrypted_store/group_message.rs b/xmtp_mls/src/storage/encrypted_store/group_message.rs index 87758e71b..fa69631e0 100644 --- a/xmtp_mls/src/storage/encrypted_store/group_message.rs +++ b/xmtp_mls/src/storage/encrypted_store/group_message.rs @@ -204,7 +204,7 @@ impl DbConnection { } #[cfg(test)] -mod tests { +pub(crate) mod tests { use super::*; use crate::{ assert_err, assert_ok, diff --git a/xmtp_mls/src/storage/encrypted_store/identity.rs b/xmtp_mls/src/storage/encrypted_store/identity.rs index b84bf9dea..affd0c62b 100644 --- a/xmtp_mls/src/storage/encrypted_store/identity.rs +++ b/xmtp_mls/src/storage/encrypted_store/identity.rs @@ -60,7 +60,7 @@ impl TryFrom for Identity { } #[cfg(test)] -mod tests { +pub(crate) mod tests { use super::{ super::{EncryptedMessageStore, StorageOption}, StoredIdentity, diff --git a/xmtp_mls/src/storage/encrypted_store/identity_update.rs b/xmtp_mls/src/storage/encrypted_store/identity_update.rs index 660d19690..7815ba674 100644 --- a/xmtp_mls/src/storage/encrypted_store/identity_update.rs +++ b/xmtp_mls/src/storage/encrypted_store/identity_update.rs @@ -130,7 +130,7 @@ impl DbConnection { } #[cfg(test)] -mod tests { +pub(crate) mod tests { use crate::{ storage::encrypted_store::tests::with_connection, utils::test::{rand_time, rand_vec}, diff --git a/xmtp_mls/src/storage/encrypted_store/mod.rs b/xmtp_mls/src/storage/encrypted_store/mod.rs index 9dd67aca5..c644b4f3b 100644 --- a/xmtp_mls/src/storage/encrypted_store/mod.rs +++ b/xmtp_mls/src/storage/encrypted_store/mod.rs @@ -454,7 +454,7 @@ where } #[cfg(test)] -mod tests { +pub(crate) mod tests { use super::{ db_connection::DbConnection, identity::StoredIdentity, EncryptedMessageStore, StorageError, StorageOption, @@ -745,7 +745,7 @@ mod tests { let store_pointer = store.clone(); - let handle = tokio::spawn(async move { + let handle = crate::spawn(async move { store_pointer .transaction_async(|provider| async move { let conn1 = provider.conn_ref(); diff --git a/xmtp_mls/src/storage/mod.rs b/xmtp_mls/src/storage/mod.rs index dcc9663c9..0ce88f647 100644 --- a/xmtp_mls/src/storage/mod.rs +++ b/xmtp_mls/src/storage/mod.rs @@ -1,4 +1,4 @@ -mod encrypted_store; +pub(super) mod encrypted_store; mod errors; pub mod serialization; pub mod sql_key_store; diff --git a/xmtp_mls/src/storage/sql_key_store.rs b/xmtp_mls/src/storage/sql_key_store.rs index 3e882cfbc..9f0c7f330 100644 --- a/xmtp_mls/src/storage/sql_key_store.rs +++ b/xmtp_mls/src/storage/sql_key_store.rs @@ -1013,7 +1013,7 @@ impl From for SqlKeyStoreError { } #[cfg(test)] -mod tests { +pub(crate) mod tests { use openmls::group::GroupId; use openmls_basic_credential::{SignatureKeyPair, StorageId}; use openmls_traits::{ diff --git a/xmtp_mls/src/subscriptions.rs b/xmtp_mls/src/subscriptions.rs index 230d22cf8..9e0812022 100644 --- a/xmtp_mls/src/subscriptions.rs +++ b/xmtp_mls/src/subscriptions.rs @@ -383,7 +383,7 @@ where } #[cfg(test)] -mod tests { +pub(crate) mod tests { use crate::utils::test::{Delivery, TestClient}; use crate::{ builder::ClientBuilder, groups::GroupMetadataOptions, @@ -415,7 +415,7 @@ mod tests { let (tx, rx) = tokio::sync::mpsc::unbounded_channel(); let mut stream = tokio_stream::wrappers::UnboundedReceiverStream::new(rx); let bob_ptr = bob.clone(); - tokio::spawn(async move { + crate::spawn(async move { let bob_stream = bob_ptr.stream_conversations().await.unwrap(); futures::pin_mut!(bob_stream); while let Some(item) = bob_stream.next().await { @@ -457,7 +457,7 @@ mod tests { let notify = Delivery::new(None); let notify_ptr = notify.clone(); let (tx, rx) = tokio::sync::mpsc::unbounded_channel(); - tokio::spawn(async move { + crate::spawn(async move { let stream = alice_group.stream(alice).await.unwrap(); futures::pin_mut!(stream); while let Some(item) = stream.next().await { @@ -695,7 +695,7 @@ mod tests { let alix_group_pointer = alix_group.clone(); let alix_pointer = alix.clone(); - tokio::spawn(async move { + crate::spawn(async move { for _ in 0..50 { alix_group_pointer .send_message(b"spam", &alix_pointer) diff --git a/xmtp_mls/src/utils/test.rs b/xmtp_mls/src/utils/test.rs index e39f615e9..df01c320d 100755 --- a/xmtp_mls/src/utils/test.rs +++ b/xmtp_mls/src/utils/test.rs @@ -23,10 +23,10 @@ use xmtp_api_grpc::grpc_api_helper::Client as GrpcClient; #[cfg(any(feature = "http-api", target_arch = "wasm32"))] use xmtp_api_http::XmtpHttpApiClient; -#[cfg(not(feature = "http-api"))] +#[cfg(not(any(feature = "http-api", target_arch = "wasm32")))] pub type TestClient = GrpcClient; -#[cfg(feature = "http-api")] +#[cfg(any(feature = "http-api", target_arch = "wasm32"))] pub type TestClient = XmtpHttpApiClient; pub fn rand_string() -> String { @@ -51,8 +51,9 @@ pub fn rand_time() -> i64 { rng.gen_range(0..1_000_000_000) } -#[async_trait::async_trait] -#[cfg(feature = "http-api")] +#[cfg_attr(target_arch = "wasm32", async_trait::async_trait(?Send))] +#[cfg_attr(not(target_arch = "wasm32"), async_trait::async_trait)] +#[cfg(any(feature = "http-api", target_arch = "wasm32"))] impl XmtpTestClient for XmtpHttpApiClient { async fn create_local() -> Self { XmtpHttpApiClient::new("http://localhost:5555".into()).unwrap() @@ -63,7 +64,8 @@ impl XmtpTestClient for XmtpHttpApiClient { } } -#[async_trait::async_trait] +#[cfg(not(target_arch = "wasm32"))] +#[cfg_attr(not(target_arch = "wasm32"), async_trait::async_trait)] impl XmtpTestClient for GrpcClient { async fn create_local() -> Self { GrpcClient::create("http://localhost:5556".into(), false)