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

Fix flaky domain tests #2220

Merged
merged 1 commit into from
Jan 20, 2024
Merged
Show file tree
Hide file tree
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
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion test/subspace-test-service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ cross-domain-message-gossip = { version = "0.1.0", path = "../../domains/client/
codec = { package = "parity-scale-codec", version = "3.2.1", features = ["derive"] }
domain-runtime-primitives = { version = "0.1.0", path = "../../domains/primitives/runtime" }
futures = "0.3.29"
futures-timer = "3.0.1"
jsonrpsee = { version = "0.16.3", features = ["server"] }
rand = "0.8.5"
pallet-domains = { version = "0.1.0", path = "../../crates/pallet-domains" }
Expand Down
36 changes: 9 additions & 27 deletions test/subspace-test-service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use codec::{Decode, Encode};
use cross_domain_message_gossip::GossipWorkerBuilder;
use domain_runtime_primitives::opaque::{Block as DomainBlock, Header as DomainHeader};
use futures::channel::mpsc;
use futures::{select, Future, FutureExt, StreamExt};
use futures::{Future, StreamExt};
use jsonrpsee::RpcModule;
use parking_lot::Mutex;
use sc_block_builder::BlockBuilderProvider;
Expand Down Expand Up @@ -241,7 +241,7 @@ pub struct MockConsensusNode {
next_slot: u64,
/// The slot notification subscribers
#[allow(clippy::type_complexity)]
new_slot_notification_subscribers: Vec<TracingUnboundedSender<(Slot, Randomness)>>,
new_slot_notification_subscribers: Vec<mpsc::UnboundedSender<(Slot, Randomness)>>,
/// The acknowledgement sender subscribers
#[allow(clippy::type_complexity)]
acknowledgement_sender_subscribers: Vec<TracingUnboundedSender<mpsc::Sender<()>>>,
Expand Down Expand Up @@ -441,8 +441,8 @@ impl MockConsensusNode {
}

/// Subscribe the new slot notification
pub fn new_slot_notification_stream(&mut self) -> TracingUnboundedReceiver<(Slot, Randomness)> {
let (tx, rx) = tracing_unbounded("subspace_new_slot_notification_stream", 100);
pub fn new_slot_notification_stream(&mut self) -> mpsc::UnboundedReceiver<(Slot, Randomness)> {
let (tx, rx) = mpsc::unbounded();
self.new_slot_notification_subscribers.push(tx);
rx
}
Expand Down Expand Up @@ -624,29 +624,11 @@ impl MockConsensusNode {
&self,
parent_number: NumberFor<Block>,
) -> Vec<<Block as BlockT>::Extrinsic> {
let mut t1 = self.transaction_pool.ready_at(parent_number).fuse();
let mut t2 = futures_timer::Delay::new(time::Duration::from_micros(100)).fuse();
let pending_iterator = select! {
res = t1 => res,
_ = t2 => {
tracing::warn!(
"Timeout fired waiting for transaction pool at #{}, proceeding with production.",
parent_number,
);
self.transaction_pool.ready()
}
};
let pushing_duration = time::Duration::from_micros(500);
let start = time::Instant::now();
let mut extrinsics = Vec::new();
for pending_tx in pending_iterator {
if start.elapsed() >= pushing_duration {
break;
}
let pending_tx_data = pending_tx.data().clone();
extrinsics.push(pending_tx_data);
}
extrinsics
self.transaction_pool
.ready_at(parent_number)
.await
.map(|pending_tx| pending_tx.data().clone())
.collect()
}

async fn mock_inherent_data(slot: Slot) -> Result<InherentData, Box<dyn Error>> {
Expand Down
Loading