mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-25 02:27:58 +00:00
light client tests: use ChainheadBackendBuilder::build_with_background_driver (#1823)
* backend rpc tests: use background task * fix build
This commit is contained in:
@@ -29,7 +29,6 @@
|
||||
|
||||
use crate::utils::node_runtime;
|
||||
use codec::Compact;
|
||||
use futures::StreamExt;
|
||||
use std::sync::Arc;
|
||||
use subxt::backend::chain_head::ChainHeadBackend;
|
||||
use subxt::backend::rpc::RpcClient;
|
||||
@@ -178,27 +177,14 @@ async fn run_test(backend: BackendType) -> Result<(), subxt::Error> {
|
||||
// .unwrap();
|
||||
// let chain_config = chainspec.get();
|
||||
|
||||
tracing::trace!("Init light clinet");
|
||||
tracing::trace!("Init light client");
|
||||
let now = std::time::Instant::now();
|
||||
let (_lc, rpc) = LightClient::relay_chain(POLKADOT_SPEC)?;
|
||||
|
||||
let api = match backend {
|
||||
BackendType::Unstable => {
|
||||
let (backend, mut driver) = ChainHeadBackend::builder().build(RpcClient::new(rpc));
|
||||
tokio::spawn(async move {
|
||||
while let Some(val) = driver.next().await {
|
||||
if let Err(e) = val {
|
||||
if e.is_disconnected_will_reconnect() {
|
||||
tracing::info!(
|
||||
"The RPC connection was lost and we may have missed a few blocks"
|
||||
);
|
||||
continue;
|
||||
}
|
||||
|
||||
tracing::error!("Error driving unstable backend: {e}");
|
||||
}
|
||||
}
|
||||
});
|
||||
let backend =
|
||||
ChainHeadBackend::builder().build_with_background_driver(RpcClient::new(rpc));
|
||||
let api: OnlineClient<PolkadotConfig> =
|
||||
OnlineClient::from_backend(Arc::new(backend)).await?;
|
||||
api
|
||||
|
||||
Reference in New Issue
Block a user