fix single node testnet, remove bootstrap vote (#5534)

This commit is contained in:
Rob Walker
2019-08-15 18:58:46 -07:00
committed by GitHub
parent 4ee212ae4c
commit 94f1132fb6
7 changed files with 34 additions and 58 deletions

View File

@ -417,18 +417,16 @@ where
}
// utility function, used by Bank, tests, genesis
pub fn create_stake_account(
voter_pubkey: &Pubkey,
vote_state: &VoteState,
lamports: u64,
) -> Account {
pub fn create_account(voter_pubkey: &Pubkey, vote_account: &Account, lamports: u64) -> Account {
let mut stake_account = Account::new(lamports, std::mem::size_of::<StakeState>(), &id());
let vote_state = VoteState::from(vote_account).expect("vote_state");
stake_account
.set_state(&StakeState::Stake(Stake::new_bootstrap(
lamports,
voter_pubkey,
vote_state,
&vote_state,
)))
.expect("set_state");

View File

@ -380,25 +380,6 @@ pub fn create_account(
vote_account
}
// utility function, used by solana-genesis, tests
pub fn create_bootstrap_leader_account(
vote_pubkey: &Pubkey,
node_pubkey: &Pubkey,
commission: u8,
vote_lamports: u64,
) -> (Account, VoteState) {
// Construct a vote account for the bootstrap_leader such that the leader_scheduler
// will be forced to select it as the leader for height 0
let mut vote_account = create_account(&vote_pubkey, &node_pubkey, commission, vote_lamports);
let mut vote_state: VoteState = vote_account.state().unwrap();
// TODO: get a hash for slot 0?
vote_state.process_slot_vote_unchecked(0);
vote_account.set_state(&vote_state).unwrap();
(vote_account, vote_state)
}
#[cfg(test)]
mod tests {
use super::*;
@ -469,16 +450,6 @@ mod tests {
)
}
#[test]
fn test_vote_create_bootstrap_leader_account() {
let vote_pubkey = Pubkey::new_rand();
let (_vote_account, vote_state) =
vote_state::create_bootstrap_leader_account(&vote_pubkey, &Pubkey::new_rand(), 0, 100);
assert_eq!(vote_state.votes.len(), 1);
assert_eq!(vote_state.votes[0], Lockout::new(&Vote::default()));
}
#[test]
fn test_vote_serialize() {
let mut buffer: Vec<u8> = vec![0; VoteState::size_of()];