Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Companion for: try-runtime::follow-chain - keep connection #5968

9 changes: 7 additions & 2 deletions tests/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.

use polkadot_core_primitives::Block;
use remote_externalities::rpc_api::get_finalized_head;
use remote_externalities::rpc_api::RpcService;
use std::{
io::{BufRead, BufReader, Read},
process::{Child, ExitStatus},
Expand Down Expand Up @@ -56,7 +56,12 @@ async fn wait_n_finalized_blocks_from(n: usize, url: &str) {
let mut interval = tokio::time::interval(Duration::from_secs(6));

loop {
if let Ok(block) = get_finalized_head::<Block, _>(url).await {
let rpc_service = RpcService::new(url, false).await;
niklasad1 marked this conversation as resolved.
Show resolved Hide resolved
niklasad1 marked this conversation as resolved.
Show resolved Hide resolved
if rpc_service.is_err() {
niklasad1 marked this conversation as resolved.
Show resolved Hide resolved
continue
niklasad1 marked this conversation as resolved.
Show resolved Hide resolved
}
niklasad1 marked this conversation as resolved.
Show resolved Hide resolved

if let Ok(block) = rpc_service.unwrap().get_finalized_head::<Block>().await {
built_blocks.insert(block);
if built_blocks.len() > n {
break
Expand Down