Skip to content

Commit

Permalink
chore(rs-dapi-client): fix rs-dapi-client tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lklimek committed Jan 23, 2025
1 parent e7213a7 commit 8993532
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 19 deletions.
4 changes: 2 additions & 2 deletions packages/rs-dapi-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ edition = "2021"

[features]

default = []
default = ["offline-testing"]

mocks = [
"dep:sha2",
Expand All @@ -18,7 +18,7 @@ mocks = [
# dump requests and responses to file
dump = ["mocks"]
# skip tests that require connection to the platform; enabled by default
online-testing = []
offline-testing = []

# non-wasm dependencies
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
Expand Down
7 changes: 0 additions & 7 deletions packages/rs-dapi-client/src/transport/tonic_channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,6 @@ pub type CoreGrpcClient = CoreClient<Channel>;
// #[derive(Default, Clone, Debug)]
pub type TokioBackonSleeper = backon::TokioSleeper;

// impl backon::Sleeper for TonicBackonSleeper {
// type Sleep = <backon::TokioSleeper as backon::Sleeper>::Sleep;
// fn sleep(&self, dur: Duration) -> Self::Sleep {
// self.0.sleep(dur)
// }
// }

/// Create channel (connection) for gRPC transport.
pub fn create_channel(
uri: Uri,
Expand Down
19 changes: 9 additions & 10 deletions packages/rs-dapi-client/tests/local_platform_connectivity.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
#[cfg(feature = "online-testing")]
#[cfg(not(feature = "offline-testing"))]
mod tests {
use dapi_grpc::{
platform::v0::{
self as platform_proto, get_identity_response, GetIdentityResponse, ResponseMetadata,
},
tonic::transport::Uri,
use dapi_grpc::platform::v0::{
self as platform_proto, get_identity_response, GetIdentityResponse, ResponseMetadata,
};
use rs_dapi_client::{AddressList, DapiClient, DapiRequest, RequestSettings};
use std::str::FromStr;

pub const OWNER_ID_BYTES: [u8; 32] = [
65, 63, 57, 243, 204, 9, 106, 71, 187, 2, 94, 221, 190, 127, 141, 114, 137, 209, 243, 50,
Expand All @@ -15,10 +13,10 @@ mod tests {

#[tokio::test]
async fn get_identity() {
let mut address_list = AddressList::new();
address_list.add_uri(Uri::from_static("http://127.0.0.1:2443"));
let address_list =
AddressList::from_str("http://127.0.0.1:2443").expect("unable to parse address list");

let mut client = DapiClient::new(address_list, RequestSettings::default());
let client = DapiClient::new(address_list, RequestSettings::default());
let request = platform_proto::GetIdentityRequest {
version: Some(platform_proto::get_identity_request::Version::V0(
platform_proto::get_identity_request::GetIdentityRequestV0 {
Expand All @@ -39,9 +37,10 @@ mod tests {
}),
})),
} = request
.execute(&mut client, RequestSettings::default())
.execute(&client, RequestSettings::default())
.await
.expect("unable to perform dapi request")
.inner
{
assert!(!bytes.is_empty());
assert_eq!(protocol_version, 1);
Expand Down

0 comments on commit 8993532

Please sign in to comment.