Skip to content

Commit

Permalink
light client tests: use `ChainheadBackendBuilder::build_with_backgrou…
Browse files Browse the repository at this point in the history
…nd_driver` (#1823)

* backend rpc tests: use background task

* fix build
  • Loading branch information
niklasad1 authored Oct 14, 2024
1 parent da2fcd5 commit bcdf0bb
Showing 1 changed file with 3 additions and 17 deletions.
20 changes: 3 additions & 17 deletions testing/integration-tests/src/light_client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit bcdf0bb

Please sign in to comment.