Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

light client tests: use ChainheadBackendBuilder::build_with_background_driver #1823

Merged
merged 3 commits into from
Oct 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading