diff --git a/core/src/cluster_tests.rs b/core/src/cluster_tests.rs index 8ad0ca716d..389d9a18f3 100644 --- a/core/src/cluster_tests.rs +++ b/core/src/cluster_tests.rs @@ -119,21 +119,21 @@ pub fn verify_ledger_ticks(ledger_path: &str, ticks_per_slot: usize) { } pub fn sleep_n_epochs( - num_epochs: u64, + num_epochs: f64, config: &PohServiceConfig, ticks_per_slot: u64, slots_per_epoch: u64, ) { let num_ticks_per_second = { match config { - PohServiceConfig::Sleep(d) => (1000 / d.as_millis()) as u64, + PohServiceConfig::Sleep(d) => (1000 / d.as_millis()) as f64, _ => panic!("Unsuppported tick config for testing"), } }; - let num_ticks_to_sleep = num_epochs * ticks_per_slot * slots_per_epoch; + let num_ticks_to_sleep = num_epochs * ticks_per_slot as f64 * slots_per_epoch as f64; sleep(Duration::from_secs( - (num_ticks_to_sleep + num_ticks_per_second - 1) / num_ticks_per_second, + ((num_ticks_to_sleep + num_ticks_per_second - 1.0) / num_ticks_per_second) as u64, )); } diff --git a/tests/local_cluster.rs b/tests/local_cluster.rs index bf5cdeaf69..75079b85f9 100644 --- a/tests/local_cluster.rs +++ b/tests/local_cluster.rs @@ -111,7 +111,7 @@ fn test_two_unbalanced_stakes() { num_slots_per_epoch, ); cluster_tests::sleep_n_epochs( - 10, + 10.0, &fullnode_config.tick_config, num_ticks_per_slot, num_slots_per_epoch, @@ -154,14 +154,14 @@ fn test_restart_node() { ); let nodes = cluster.get_node_ids(); cluster_tests::sleep_n_epochs( - 1, + 1.0, &fullnode_config.tick_config, timing::DEFAULT_TICKS_PER_SLOT, slots_per_epoch, ); cluster.restart_node(nodes[0]); cluster_tests::sleep_n_epochs( - 1, + 0.5, &fullnode_config.tick_config, timing::DEFAULT_TICKS_PER_SLOT, slots_per_epoch,