mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 19:11:04 +00:00
stabilize reconnecting-rpc-client (#1803)
* stabilize reconnecting-rpc-client * fix build * remove missed unstable stuff
This commit is contained in:
@@ -261,7 +261,7 @@ jobs:
|
|||||||
uses: actions-rs/cargo@v1.0.3
|
uses: actions-rs/cargo@v1.0.3
|
||||||
with:
|
with:
|
||||||
command: test
|
command: test
|
||||||
args: --doc --features unstable-reconnecting-rpc-client
|
args: --doc --features reconnecting-rpc-client
|
||||||
|
|
||||||
- if: "failure()"
|
- if: "failure()"
|
||||||
uses: "andymckay/cancel-action@a955d435292c0d409d104b57d8e78435a93a6ef1" # v0.5
|
uses: "andymckay/cancel-action@a955d435292c0d409d104b57d8e78435a93a6ef1" # v0.5
|
||||||
@@ -295,7 +295,7 @@ jobs:
|
|||||||
uses: actions-rs/cargo@v1.0.3
|
uses: actions-rs/cargo@v1.0.3
|
||||||
with:
|
with:
|
||||||
command: nextest
|
command: nextest
|
||||||
args: run --workspace --features unstable-reconnecting-rpc-client
|
args: run --workspace --features reconnecting-rpc-client
|
||||||
|
|
||||||
- if: "failure()"
|
- if: "failure()"
|
||||||
uses: "andymckay/cancel-action@a955d435292c0d409d104b57d8e78435a93a6ef1" # v0.5
|
uses: "andymckay/cancel-action@a955d435292c0d409d104b57d8e78435a93a6ef1" # v0.5
|
||||||
|
|||||||
+2
-2
@@ -56,7 +56,7 @@ web = [
|
|||||||
runtime = ["tokio/rt", "wasm-bindgen-futures"]
|
runtime = ["tokio/rt", "wasm-bindgen-futures"]
|
||||||
|
|
||||||
# Enable this to use the reconnecting rpc client
|
# Enable this to use the reconnecting rpc client
|
||||||
unstable-reconnecting-rpc-client = ["dep:finito", "jsonrpsee"]
|
reconnecting-rpc-client = ["dep:finito", "jsonrpsee"]
|
||||||
|
|
||||||
# Enable this to use jsonrpsee (allowing for example `OnlineClient::from_url`).
|
# Enable this to use jsonrpsee (allowing for example `OnlineClient::from_url`).
|
||||||
jsonrpsee = [
|
jsonrpsee = [
|
||||||
@@ -165,7 +165,7 @@ required-features = ["unstable-light-client", "jsonrpsee", "native"]
|
|||||||
[[example]]
|
[[example]]
|
||||||
name = "setup_reconnecting_rpc_client"
|
name = "setup_reconnecting_rpc_client"
|
||||||
path = "examples/setup_reconnecting_rpc_client.rs"
|
path = "examples/setup_reconnecting_rpc_client.rs"
|
||||||
required-features = ["unstable-reconnecting-rpc-client"]
|
required-features = ["reconnecting-rpc-client"]
|
||||||
|
|
||||||
[package.metadata.docs.rs]
|
[package.metadata.docs.rs]
|
||||||
features = ["default", "substrate-compat", "unstable-light-client"]
|
features = ["default", "substrate-compat", "unstable-light-client"]
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//! Example to utilize the `reconnecting rpc client` in subxt
|
//! Example to utilize the `reconnecting rpc client` in subxt
|
||||||
//! which hidden behind behind `--feature unstable-reconnecting-rpc-client`
|
//! which hidden behind behind `--feature reconnecting-rpc-client`
|
||||||
//!
|
//!
|
||||||
//! To utilize full logs from the RPC client use:
|
//! To utilize full logs from the RPC client use:
|
||||||
//! `RUST_LOG="jsonrpsee=trace,subxt-reconnecting-rpc-client=trace"`
|
//! `RUST_LOG="jsonrpsee=trace,subxt-reconnecting-rpc-client=trace"`
|
||||||
|
|||||||
+2
-2
@@ -56,8 +56,8 @@ macro_rules! cfg_jsonrpsee_web {
|
|||||||
macro_rules! cfg_reconnecting_rpc_client {
|
macro_rules! cfg_reconnecting_rpc_client {
|
||||||
($($item:item)*) => {
|
($($item:item)*) => {
|
||||||
$(
|
$(
|
||||||
#[cfg(all(feature = "unstable-reconnecting-rpc-client", any(feature = "native", feature = "web")))]
|
#[cfg(all(feature = "reconnecting-rpc-client", any(feature = "native", feature = "web")))]
|
||||||
#[cfg_attr(docsrs, doc(cfg(feature = "unstable-reconnecting-rpc-client")))]
|
#[cfg_attr(docsrs, doc(cfg(feature = "reconnecting-rpc-client")))]
|
||||||
$item
|
$item
|
||||||
)*
|
)*
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ serde = { workspace = true }
|
|||||||
scale-info = { workspace = true, features = ["bit-vec"] }
|
scale-info = { workspace = true, features = ["bit-vec"] }
|
||||||
sp-core = { workspace = true }
|
sp-core = { workspace = true }
|
||||||
syn = { workspace = true }
|
syn = { workspace = true }
|
||||||
subxt = { workspace = true, features = ["unstable-metadata", "native", "jsonrpsee", "substrate-compat", "unstable-reconnecting-rpc-client"] }
|
subxt = { workspace = true, features = ["unstable-metadata", "native", "jsonrpsee", "substrate-compat", "reconnecting-rpc-client"] }
|
||||||
subxt-signer = { workspace = true, features = ["default"] }
|
subxt-signer = { workspace = true, features = ["default"] }
|
||||||
subxt-codegen = { workspace = true }
|
subxt-codegen = { workspace = true }
|
||||||
subxt-metadata = { workspace = true }
|
subxt-metadata = { workspace = true }
|
||||||
|
|||||||
@@ -35,5 +35,5 @@ pub async fn test_context() -> TestContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn test_context_reconnecting_rpc_client() -> TestContext {
|
pub async fn test_context_reconnecting_rpc_client() -> TestContext {
|
||||||
test_context_with("alice".to_string(), RpcClientKind::UnstableReconnecting).await
|
test_context_with("alice".to_string(), RpcClientKind::Reconnecting).await
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ use subxt::{
|
|||||||
// The URL that we'll connect to for our tests comes from SUBXT_TEXT_HOST env var,
|
// The URL that we'll connect to for our tests comes from SUBXT_TEXT_HOST env var,
|
||||||
// defaulting to localhost if not provided. If the env var is set, we won't spawn
|
// defaulting to localhost if not provided. If the env var is set, we won't spawn
|
||||||
// a binary. Note though that some tests expect and modify a fresh state, and so will
|
// a binary. Note though that some tests expect and modify a fresh state, and so will
|
||||||
// fail. Fo a similar reason wyou should also use `--test-threads 1` when running tests
|
// fail. For a similar reason you should also use `--test-threads 1` when running tests
|
||||||
// to reduce the number of conflicts between state altering tests.
|
// to reduce the number of conflicts between state altering tests.
|
||||||
const URL_ENV_VAR: &str = "SUBXT_TEST_URL";
|
const URL_ENV_VAR: &str = "SUBXT_TEST_URL";
|
||||||
fn is_url_provided() -> bool {
|
fn is_url_provided() -> bool {
|
||||||
@@ -124,7 +124,7 @@ where
|
|||||||
/// Kind of rpc client to use in tests
|
/// Kind of rpc client to use in tests
|
||||||
pub enum RpcClientKind {
|
pub enum RpcClientKind {
|
||||||
Legacy,
|
Legacy,
|
||||||
UnstableReconnecting,
|
Reconnecting,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Construct a test node process.
|
/// Construct a test node process.
|
||||||
@@ -153,7 +153,7 @@ impl TestNodeProcessBuilder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set the testRunner to use a preferred RpcClient impl, ie Legacy or Unstable
|
/// Set the testRunner to use a preferred RpcClient impl, ie Legacy or Reconnecting.
|
||||||
pub fn with_rpc_client_kind(&mut self, rpc_client_kind: RpcClientKind) -> &mut Self {
|
pub fn with_rpc_client_kind(&mut self, rpc_client_kind: RpcClientKind) -> &mut Self {
|
||||||
self.rpc_client = rpc_client_kind;
|
self.rpc_client = rpc_client_kind;
|
||||||
self
|
self
|
||||||
@@ -187,7 +187,7 @@ impl TestNodeProcessBuilder {
|
|||||||
let ws_url = get_url(proc.as_ref().map(|p| p.ws_port()));
|
let ws_url = get_url(proc.as_ref().map(|p| p.ws_port()));
|
||||||
let rpc_client = match self.rpc_client {
|
let rpc_client = match self.rpc_client {
|
||||||
RpcClientKind::Legacy => build_rpc_client(&ws_url).await,
|
RpcClientKind::Legacy => build_rpc_client(&ws_url).await,
|
||||||
RpcClientKind::UnstableReconnecting => build_reconnecting_rpc_client(&ws_url).await,
|
RpcClientKind::Reconnecting => build_reconnecting_rpc_client(&ws_url).await,
|
||||||
}
|
}
|
||||||
.map_err(|e| format!("Failed to connect to node at {ws_url}: {e}"))?;
|
.map_err(|e| format!("Failed to connect to node at {ws_url}: {e}"))?;
|
||||||
|
|
||||||
|
|||||||
@@ -15,4 +15,4 @@ futures-util = "0.3.30"
|
|||||||
# This crate is not a part of the workspace, because it
|
# This crate is not a part of the workspace, because it
|
||||||
# requires the "jsonrpsee web" features to be enabled, which we don't
|
# requires the "jsonrpsee web" features to be enabled, which we don't
|
||||||
# want enabled for workspace builds in general.
|
# want enabled for workspace builds in general.
|
||||||
subxt = { path = "../../subxt", default-features = false, features = ["web", "jsonrpsee", "unstable-reconnecting-rpc-client", "runtime"] }
|
subxt = { path = "../../subxt", default-features = false, features = ["web", "jsonrpsee", "reconnecting-rpc-client"] }
|
||||||
|
|||||||
Reference in New Issue
Block a user