Skip to content

Commit

Permalink
moved time related utils to testing utils
Browse files Browse the repository at this point in the history
  • Loading branch information
dkijania committed Oct 19, 2020
1 parent 1c047c6 commit 4fb7133
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 23 deletions.
26 changes: 3 additions & 23 deletions testing/jormungandr-integration-tests/src/jormungandr/vit/mod.rs
Expand Up @@ -18,7 +18,7 @@ use jormungandr_lib::{
interfaces::{ActiveSlotCoefficient, CommitteeIdDef, Tally, VotePlanStatus},
};
use jormungandr_testing_utils::{
testing::{node::Explorer, vote_plan_cert, FragmentSender, FragmentSenderSetup},
testing::{node::Explorer, time, vote_plan_cert, FragmentSender, FragmentSenderSetup},
wallet::Wallet,
};
use rand::rngs::OsRng;
Expand Down Expand Up @@ -308,13 +308,13 @@ pub fn test_vote_flow_praos() {
.parse::<u64>()
.unwrap();

wait_for_epoch(1, jormungandr.explorer().clone());
time::wait_for_epoch(1, jormungandr.explorer().clone());

transaction_sender
.send_vote_tally(&mut alice, &vote_plan, &jormungandr)
.unwrap();

wait_for_epoch(2, jormungandr.explorer().clone());
time::wait_for_epoch(2, jormungandr.explorer().clone());

let rewards_after = jormungandr
.explorer()
Expand All @@ -336,23 +336,3 @@ pub fn test_vote_flow_praos() {
"Vote was unsuccessful"
)
}

fn wait_for_epoch(epoch_id: u64, mut explorer: Explorer) {
explorer.disable_logs();
while explorer
.status()
.unwrap()
.data
.unwrap()
.status
.latest_block
.date
.epoch
.id
.parse::<u64>()
.unwrap()
< epoch_id
{
std::thread::sleep(std::time::Duration::from_secs(1));
}
}
1 change: 1 addition & 0 deletions testing/jormungandr-testing-utils/src/testing/node/mod.rs
Expand Up @@ -4,6 +4,7 @@ pub mod grpc;
mod legacy;
mod logger;
mod rest;
pub mod time;
mod verifier;

pub mod explorer;
Expand Down
21 changes: 21 additions & 0 deletions testing/jormungandr-testing-utils/src/testing/node/time.rs
@@ -0,0 +1,21 @@
use crate::testing::node::explorer::Explorer;

pub fn wait_for_epoch(epoch_id: u64, mut explorer: Explorer) {
explorer.enable_logs();
while explorer
.status()
.unwrap()
.data
.unwrap()
.status
.latest_block
.date
.epoch
.id
.parse::<u64>()
.unwrap()
< epoch_id
{
std::thread::sleep(std::time::Duration::from_secs(1));
}
}

0 comments on commit 4fb7133

Please sign in to comment.