Skip to content

Commit 38557b4

Browse files
committed
builder for XmtpTestClient
1 parent d538e53 commit 38557b4

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

xmtp_api/src/test_utils.rs

+2
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ mod not_wasm {
144144

145145
#[async_trait::async_trait]
146146
impl XmtpTestClient for ApiClient {
147+
type Builder = ApiClient;
147148
async fn create_local() -> Self { ApiClient }
148149
async fn create_dev() -> Self { ApiClient }
149150
}
@@ -207,6 +208,7 @@ mod wasm {
207208

208209
#[async_trait::async_trait(?Send)]
209210
impl XmtpTestClient for ApiClient {
211+
type Builder = ApiClient;
210212
async fn create_local() -> Self { ApiClient }
211213
async fn create_dev() -> Self { ApiClient }
212214
}

xmtp_api_http/src/util.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -48,29 +48,30 @@ where
4848
}
4949
}
5050

51-
#[cfg(feature = "test-utils")]
51+
#[cfg(any(test, feature = "test-utils"))]
5252
#[cfg_attr(not(target_arch = "wasm32"), async_trait::async_trait)]
5353
#[cfg_attr(target_arch = "wasm32", async_trait::async_trait(?Send))]
5454
#[allow(clippy::unwrap_used)]
5555
impl xmtp_proto::api_client::XmtpTestClient for crate::XmtpHttpApiClient {
56-
async fn create_local() -> Self {
56+
type Builder = crate::XmtpHttpApiClientBuilder;
57+
async fn create_local() -> Self::Builder {
5758
use xmtp_proto::api_client::ApiBuilder;
5859
let mut api = crate::XmtpHttpApiClient::builder();
5960
api.set_host(crate::constants::ApiUrls::LOCAL_ADDRESS.into());
6061
api.set_libxmtp_version(env!("CARGO_PKG_VERSION").into())
6162
.unwrap();
6263
api.set_app_version("0.0.0".into()).unwrap();
63-
api.build().await.unwrap()
64+
api
6465
}
6566

66-
async fn create_dev() -> Self {
67+
async fn create_dev() -> Self::Builder {
6768
use xmtp_proto::api_client::ApiBuilder;
6869
let mut api = crate::XmtpHttpApiClient::builder();
6970
api.set_host(crate::constants::ApiUrls::DEV_ADDRESS.into());
7071
api.set_libxmtp_version(env!("CARGO_PKG_VERSION").into())
7172
.unwrap();
7273
api.set_app_version("0.0.0".into()).unwrap();
73-
api.build().await.unwrap()
74+
api
7475
}
7576
}
7677

0 commit comments

Comments
 (0)