diff --git a/polkadot/zombienet-sdk-tests/tests/elastic_scaling/helpers.rs b/polkadot/zombienet-sdk-tests/tests/elastic_scaling/helpers.rs deleted file mode 100644 index 7d4ad4a1dd8b..000000000000 --- a/polkadot/zombienet-sdk-tests/tests/elastic_scaling/helpers.rs +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright (C) Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 - -use super::rococo; -use std::{collections::HashMap, ops::Range}; -use subxt::{OnlineClient, PolkadotConfig}; - -// Helper function for asserting the throughput of parachains (total number of backed candidates in -// a window of relay chain blocks), after the first session change. -pub async fn assert_para_throughput( - relay_client: &OnlineClient, - stop_at: u32, - expected_candidate_ranges: HashMap>, -) -> Result<(), anyhow::Error> { - let mut blocks_sub = relay_client.blocks().subscribe_finalized().await?; - let mut candidate_count: HashMap = HashMap::new(); - let mut current_block_count = 0; - let mut had_first_session_change = false; - - while let Some(block) = blocks_sub.next().await { - let block = block?; - log::debug!("Finalized relay chain block {}", block.number()); - let events = block.events().await?; - let is_session_change = events.has::()?; - - if !had_first_session_change && is_session_change { - had_first_session_change = true; - } - - if had_first_session_change && !is_session_change { - current_block_count += 1; - - for event in events.find::() { - *(candidate_count.entry(event?.0.descriptor.para_id.0).or_default()) += 1; - } - } - - if current_block_count == stop_at { - break; - } - } - - log::info!( - "Reached {} finalized relay chain blocks that contain backed candidates. The per-parachain distribution is: {:#?}", - stop_at, - candidate_count - ); - - for (para_id, expected_candidate_range) in expected_candidate_ranges { - let actual = candidate_count - .get(¶_id) - .expect("ParaId did not have any backed candidates"); - assert!( - expected_candidate_range.contains(actual), - "Candidate count {actual} not within range {expected_candidate_range:?}" - ); - } - - Ok(()) -}