Skip to content

Commit

Permalink
initialize with new VoteState for tests (#33518)
Browse files Browse the repository at this point in the history
  • Loading branch information
AshwinSekar committed Oct 4, 2023
1 parent 5a95e56 commit d4941cc
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions programs/vote/src/vote_state/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1095,16 +1095,14 @@ pub fn do_process_vote_state_update(
// a. In many tests.
// b. In the genesis tool that initializes a cluster to create the bootstrap validator.
// c. In the ledger tool when creating bootstrap vote accounts.
// In all cases, initializing with the 1_14_11 version of VoteState is safest, as this version will in-place upgrade
// the first time it is altered by a vote transaction.
pub fn create_account_with_authorized(
node_pubkey: &Pubkey,
authorized_voter: &Pubkey,
authorized_withdrawer: &Pubkey,
commission: u8,
lamports: u64,
) -> AccountSharedData {
let mut vote_account = AccountSharedData::new(lamports, VoteState1_14_11::size_of(), &id());
let mut vote_account = AccountSharedData::new(lamports, VoteState::size_of(), &id());

let vote_state = VoteState::new(
&VoteInit {
Expand All @@ -1116,8 +1114,11 @@ pub fn create_account_with_authorized(
&Clock::default(),
);

let version1_14_11 = VoteStateVersions::V1_14_11(Box::new(VoteState1_14_11::from(vote_state)));
VoteState::serialize(&version1_14_11, vote_account.data_as_mut_slice()).unwrap();
VoteState::serialize(
&VoteStateVersions::Current(Box::new(vote_state)),
vote_account.data_as_mut_slice(),
)
.unwrap();

vote_account
}
Expand Down

0 comments on commit d4941cc

Please sign in to comment.