mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-30 16:37:57 +00:00
substrate runner: increase line read + dump CLI output if parsing fails (#1781)
* substrate runner: dump CLI output parsing fails * cargo fmt * Update testing/substrate-runner/src/lib.rs * fix grumbles * disable flaky test * ignore reconn test too * ignore more tests * fix tests * improve log parsing * Update testing/integration-tests/src/full_client/client/unstable_rpcs.rs * Update testing/integration-tests/src/full_client/client/unstable_rpcs.rs * fix nits * fix reconn test
This commit is contained in:
@@ -2,7 +2,10 @@
|
||||
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
||||
// see LICENSE for license details.
|
||||
|
||||
use subxt::{client::OnlineClientT, Config};
|
||||
use subxt::{
|
||||
backend::StreamOf, blocks::Block, client::OnlineClientT, Config, Error, OnlineClient,
|
||||
SubstrateConfig,
|
||||
};
|
||||
|
||||
/// Wait for blocks to be produced before running tests. Specifically, we
|
||||
/// wait for one more finalized block to be produced, which is important because
|
||||
@@ -23,3 +26,25 @@ pub async fn wait_for_number_of_blocks<C: Config>(
|
||||
sub.next().await;
|
||||
}
|
||||
}
|
||||
|
||||
/// Consumes the initial blocks from the stream of blocks to ensure that the stream is up-to-date.
|
||||
///
|
||||
/// This may be useful on the unstable backend when the initial blocks may be large
|
||||
/// and one relies on something to included in finalized block in ner future.
|
||||
pub async fn consume_initial_blocks(
|
||||
blocks: &mut StreamOf<Result<Block<SubstrateConfig, OnlineClient<SubstrateConfig>>, Error>>,
|
||||
) {
|
||||
use tokio::time::{interval_at, Duration, Instant};
|
||||
const MAX_DURATION: Duration = Duration::from_millis(200);
|
||||
|
||||
let mut now = interval_at(Instant::now() + MAX_DURATION, MAX_DURATION);
|
||||
|
||||
loop {
|
||||
tokio::select! {
|
||||
_ = now.tick() => {
|
||||
break;
|
||||
}
|
||||
_ = blocks.next() => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user