diff --git a/src/active_stakers.rs b/src/active_stakers.rs index 72a257efb7..400e2cae7a 100644 --- a/src/active_stakers.rs +++ b/src/active_stakers.rs @@ -65,3 +65,37 @@ impl ActiveStakers { LeaderSchedule::new(self.pubkeys()) } } + +pub mod tests { + use solana_runtime::bank::Bank; + use solana_sdk::hash::Hash; + use solana_sdk::signature::{Keypair, KeypairUtil}; + use solana_sdk::vote_transaction::VoteTransaction; + + pub fn new_vote_account( + from_keypair: &Keypair, + voting_keypair: &T, + bank: &Bank, + num_tokens: u64, + last_id: Hash, + ) { + let tx = VoteTransaction::new_account( + from_keypair, + voting_keypair.pubkey(), + last_id, + num_tokens, + 0, + ); + bank.process_transaction(&tx).unwrap(); + } + + pub fn push_vote( + voting_keypair: &T, + bank: &Bank, + tick_height: u64, + last_id: Hash, + ) { + let new_vote_tx = VoteTransaction::new_vote(voting_keypair, tick_height, last_id, 0); + bank.process_transaction(&new_vote_tx).unwrap(); + } +} diff --git a/src/leader_confirmation_service.rs b/src/leader_confirmation_service.rs index 921821ba7d..30b70c9bb4 100644 --- a/src/leader_confirmation_service.rs +++ b/src/leader_confirmation_service.rs @@ -133,7 +133,7 @@ impl Service for LeaderConfirmationService { #[cfg(test)] pub mod tests { use super::*; - use crate::leader_scheduler::tests::new_vote_account; + use crate::active_stakers::tests::new_vote_account; use crate::voting_keypair::VotingKeypair; use bincode::serialize; use solana_sdk::genesis_block::GenesisBlock; diff --git a/src/leader_scheduler.rs b/src/leader_scheduler.rs index 092658045e..41756d5a24 100644 --- a/src/leader_scheduler.rs +++ b/src/leader_scheduler.rs @@ -428,6 +428,7 @@ pub fn make_active_set_entries( #[cfg(test)] pub mod tests { use super::*; + use crate::active_stakers::tests::{new_vote_account, push_vote}; use hashbrown::HashSet; use solana_sdk::genesis_block::{GenesisBlock, BOOTSTRAP_LEADER_TOKENS}; use std::hash::Hash as StdHash; @@ -441,28 +442,6 @@ pub mod tests { HashSet::from_iter(slice.iter().cloned()) } - pub fn new_vote_account( - from_keypair: &Keypair, - voting_keypair: &VotingKeypair, - bank: &Bank, - num_tokens: u64, - last_id: Hash, - ) { - let tx = VoteTransaction::new_account( - from_keypair, - voting_keypair.pubkey(), - last_id, - num_tokens, - 0, - ); - bank.process_transaction(&tx).unwrap(); - } - - fn push_vote(voting_keypair: &VotingKeypair, bank: &Bank, tick_height: u64, last_id: Hash) { - let new_vote_tx = VoteTransaction::new_vote(voting_keypair, tick_height, last_id, 0); - bank.process_transaction(&new_vote_tx).unwrap(); - } - fn run_scheduler_test(num_validators: usize, ticks_per_slot: u64, ticks_per_epoch: u64) { info!( "run_scheduler_test({}, {}, {})",