Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
minor: naming
  • Loading branch information
dmitry-markin committed Dec 15, 2022
commit 8b79253baaddff2b98bf83c8adea4dca812bb23f
2 changes: 1 addition & 1 deletion client/beefy/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ impl BeefyTestNet {

block
});
self.wait_until_sync().await;
self.run_until_sync().await;
}
}

Expand Down
18 changes: 9 additions & 9 deletions client/finality-grandpa/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ async fn finalize_3_voters_no_observers() {
let mut net = GrandpaTestNet::new(TestApi::new(voters), 3, 0);
tokio::spawn(initialize_grandpa(&mut net, peers));
net.peer(0).push_blocks(20, false);
net.wait_until_sync().await;
net.run_until_sync().await;
let hashof20 = net.peer(0).client().info().best_hash;

for i in 0..3 {
Expand Down Expand Up @@ -498,7 +498,7 @@ async fn transition_3_voters_twice_1_full_observer() {
}

net.lock().peer(0).push_blocks(1, false);
net.lock().wait_until_sync().await;
net.lock().run_until_sync().await;

for (i, peer) in net.lock().peers().iter().enumerate() {
let full_client = peer.client().as_client();
Expand Down Expand Up @@ -600,7 +600,7 @@ async fn justification_is_generated_periodically() {
let mut net = GrandpaTestNet::new(TestApi::new(voters), 3, 0);
tokio::spawn(initialize_grandpa(&mut net, peers));
net.peer(0).push_blocks(32, false);
net.wait_until_sync().await;
net.run_until_sync().await;

let hashof32 = net.peer(0).client().info().best_hash;

Expand Down Expand Up @@ -640,7 +640,7 @@ async fn sync_justifications_on_change_blocks() {

// add more blocks on top of it (until we have 25)
net.peer(0).push_blocks(4, false);
net.wait_until_sync().await;
net.run_until_sync().await;

for i in 0..4 {
assert_eq!(net.peer(i).client().info().best_number, 25, "Peer #{} failed to sync", i);
Expand Down Expand Up @@ -722,7 +722,7 @@ async fn finalizes_multiple_pending_changes_in_order() {
// add more blocks on top of it (until we have 30)
net.peer(0).push_blocks(4, false);

net.wait_until_sync().await;
net.run_until_sync().await;

// all peers imported both change blocks
for i in 0..6 {
Expand Down Expand Up @@ -772,7 +772,7 @@ async fn force_change_to_new_set() {
});

net.lock().peer(0).push_blocks(25, false);
net.lock().wait_until_sync().await;
net.lock().run_until_sync().await;

for (i, peer) in net.lock().peers().iter().enumerate() {
assert_eq!(peer.client().info().best_number, 26, "Peer #{} failed to sync", i);
Expand Down Expand Up @@ -1021,7 +1021,7 @@ async fn voter_persists_its_votes() {
tokio::spawn(alice_voter1);

net.peer(0).push_blocks(20, false);
net.wait_until_sync().await;
net.run_until_sync().await;

assert_eq!(net.peer(0).client().info().best_number, 20, "Peer #{} failed to sync", 0);

Expand Down Expand Up @@ -1165,7 +1165,7 @@ async fn finalize_3_voters_1_light_observer() {
)
.unwrap();
net.peer(0).push_blocks(20, false);
net.wait_until_sync().await;
net.run_until_sync().await;

for i in 0..4 {
assert_eq!(net.peer(i).client().info().best_number, 20, "Peer #{} failed to sync", i);
Expand Down Expand Up @@ -1241,7 +1241,7 @@ async fn voter_catches_up_to_latest_round_when_behind() {
}

net.lock().peer(0).push_blocks(50, false);
net.lock().wait_until_sync().await;
net.lock().run_until_sync().await;

// wait for them to finalize block 50. since they'll vote on 3/4 of the
// unfinalized chain it will take at least 4 rounds to do it.
Expand Down
13 changes: 6 additions & 7 deletions client/network/test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1016,12 +1016,11 @@ where
Poll::Pending
}

/// Wait until we are sync'ed.
/// Run the network until we are sync'ed.
///
/// Calls `poll_until_sync` repeatedly.
/// (If we've not synced within 10 mins then panic rather than hang.)
async fn wait_until_sync(&mut self) {
// TODO: rename into run_until_sync() (and below).
async fn run_until_sync(&mut self) {
timeout(
Duration::from_secs(10 * 60),
futures::future::poll_fn::<(), _>(|cx| self.poll_until_sync(cx)),
Expand All @@ -1030,17 +1029,17 @@ where
.expect("sync didn't happen within 10 mins");
}

/// Wait until there are no pending packets.
/// Run the network until there are no pending packets.
///
/// Calls `poll_until_idle` repeatedly with the runtime passed as parameter.
async fn wait_until_idle(&mut self) {
async fn run_until_idle(&mut self) {
futures::future::poll_fn::<(), _>(|cx| self.poll_until_idle(cx)).await;
}

/// Wait until all peers are connected to each other.
/// Run the network until all peers are connected to each other.
///
/// Calls `poll_until_connected` repeatedly with the runtime passed as parameter.
async fn wait_until_connected(&mut self) {
async fn run_until_connected(&mut self) {
futures::future::poll_fn::<(), _>(|cx| self.poll_until_connected(cx)).await;
}

Expand Down
Loading