diff --git a/testing/integration-tests/src/utils/context.rs b/testing/integration-tests/src/utils/context.rs index f572cb5b5e..2ad0d8edfb 100644 --- a/testing/integration-tests/src/utils/context.rs +++ b/testing/integration-tests/src/utils/context.rs @@ -6,6 +6,12 @@ pub(crate) use crate::{node_runtime, utils::TestNodeProcess}; use subxt::SubstrateConfig; +#[cfg(lightclient)] +use subxt::client::LightClient; + +#[cfg(fullclient)] +use subxt::client::OnlineClient; + /// `substrate-node` should be installed on the $PATH. We fall back /// to also checking for an older `substrate` binary. const SUBSTRATE_NODE_PATHS: &str = "substrate-node,substrate"; @@ -20,8 +26,16 @@ pub async fn test_context_with(authority: String) -> TestContext { proc.spawn::().await.unwrap() } +pub type TestConfig = SubstrateConfig; + pub type TestContext = TestNodeProcess; +#[cfg(fullclient)] +pub type TestClient = OnlineClient; + +#[cfg(lightclient)] +pub type TestClient = LightClient; + pub async fn test_context() -> TestContext { test_context_with("alice".to_string()).await } diff --git a/testing/integration-tests/src/utils/node_proc.rs b/testing/integration-tests/src/utils/node_proc.rs index d3ac752fec..419ce50b57 100644 --- a/testing/integration-tests/src/utils/node_proc.rs +++ b/testing/integration-tests/src/utils/node_proc.rs @@ -11,7 +11,7 @@ use subxt::{ Config, OnlineClient, }; -#[cfg(feature = "unstable-light-client")] +#[cfg(lightclient)] use subxt::client::{LightClient, LightClientBuilder}; /// Spawn a local substrate node for testing subxt. @@ -25,10 +25,10 @@ pub struct TestNodeProcess { rpc_client: rpc::RpcClient, - #[cfg(not(feature = "unstable-light-client"))] + #[cfg(fullclient)] client: OnlineClient, - #[cfg(feature = "unstable-light-client")] + #[cfg(lightclient)] client: LightClient, } @@ -92,13 +92,13 @@ where /// will use the legacy backend by default or the unstable backend if the /// "unstable-backend-client" feature is enabled, so that we can run each /// test against both. - #[cfg(not(feature = "unstable-light-client"))] + #[cfg(fullclient)] pub fn client(&self) -> OnlineClient { self.client.clone() } /// Returns the subxt client connected to the running node. - #[cfg(feature = "unstable-light-client")] + #[cfg(lightclient)] pub fn client(&self) -> LightClient { self.client.clone() } @@ -160,7 +160,7 @@ impl TestNodeProcessBuilder { #[allow(unused_assignments, unused_mut)] let mut legacy_client = None; - #[cfg(feature = "unstable-light-client")] + #[cfg(lightclient)] let client = build_light_client(&proc).await?; #[cfg(feature = "unstable-backend-client")] @@ -170,10 +170,7 @@ impl TestNodeProcessBuilder { client }; - #[cfg(all( - not(feature = "unstable-light-client"), - not(feature = "unstable-backend-client") - ))] + #[cfg(all(not(lightclient), not(feature = "unstable-backend-client")))] let client = { let client = build_legacy_client(rpc_client.clone()).await?; legacy_client = Some(client.clone()); @@ -234,7 +231,7 @@ async fn build_unstable_client( Ok(client) } -#[cfg(feature = "unstable-light-client")] +#[cfg(lightclient)] async fn build_light_client(proc: &SubstrateNode) -> Result, String> { // RPC endpoint. let ws_url = format!("ws://127.0.0.1:{}", proc.ws_port());