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: make sure to join all arbiters #3932

Closed
Closed
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
6 changes: 6 additions & 0 deletions chain/network/src/peer_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,12 @@ pub struct PeerManagerActor {
scheduled_routing_table_update: bool,
}

impl Drop for PeerManagerActor {
fn drop(&mut self) {
while self.edge_verifier_pool.connected() {}
}
}

impl PeerManagerActor {
pub fn new(
store: Arc<Store>,
Expand Down
67 changes: 39 additions & 28 deletions neard/tests/run_nodes.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use actix::{Actor, System};
use actix::{Actor, Arbiter, System};
use futures::{future, FutureExt};

use near_client::GetBlock;
Expand All @@ -16,37 +16,48 @@ fn run_nodes(
) {
let mut rng = thread_rng();
let genesis_height = rng.gen_range(0, 10000);
let mut arbiters = Vec::new();
System::builder()
.stop_on_panic(true)
.run(move || {
let dirs = (0..num_nodes)
.map(|i| {
tempfile::Builder::new()
.prefix(&format!("run_nodes_{}_{}_{}", num_nodes, num_validators, i))
.tempdir()
.unwrap()
})
.collect::<Vec<_>>();
let (_, _, clients) =
start_nodes(num_shards, &dirs, num_validators, 0, epoch_length, genesis_height);
let view_client = clients[clients.len() - 1].1.clone();
WaitOrTimeout::new(
Box::new(move |_ctx| {
actix::spawn(view_client.send(GetBlock::latest()).then(move |res| {
match &res {
Ok(Ok(b)) if b.header.height > num_blocks => System::current().stop(),
Err(_) => return future::ready(()),
_ => {}
};
future::ready(())
}));
}),
100,
40000,
)
.start();
.run({
let arbiters = &mut arbiters;
move || {
let dirs = (0..num_nodes)
.map(|i| {
tempfile::Builder::new()
.prefix(&format!("run_nodes_{}_{}_{}", num_nodes, num_validators, i))
.tempdir()
.unwrap()
})
.collect::<Vec<_>>();
let (_, _, clients) =
start_nodes(num_shards, &dirs, num_validators, 0, epoch_length, genesis_height);
let view_client = clients.last().unwrap().1.clone();
WaitOrTimeout::new(
Box::new(move |_ctx| {
actix::spawn(view_client.send(GetBlock::latest()).then(move |res| {
match &res {
Ok(Ok(b)) if b.header.height > num_blocks => {
System::current().stop()
}
Err(_) => return future::ready(()),
_ => {}
};
future::ready(())
}));
}),
100,
40000,
)
.start();
arbiters.extend(clients.into_iter().flat_map(|it| it.2));
}
})
.unwrap();
arbiters.push(Arbiter::current());
for mut arb in arbiters {
arb.join().unwrap()
}
}

/// Runs two nodes that should produce blocks one after another.
Expand Down