@@ -578,12 +578,20 @@ pub(in crate::bank) fn new_from_parent_next_epoch(
578578 new_bank_from_parent_with_bank_forks ( bank_forks, parent, & Pubkey :: default ( ) , slot)
579579}
580580
581- #[ test]
582- fn test_bank_update_vote_stake_rewards ( ) {
581+ fn test_bank_update_vote_stake_rewards ( is_alpenglow : bool ) {
583582 let thread_pool = ThreadPoolBuilder :: new ( ) . num_threads ( 1 ) . build ( ) . unwrap ( ) ;
584- check_bank_update_vote_stake_rewards ( |bank : & Bank | {
585- bank. _load_vote_and_stake_accounts ( & thread_pool, null_tracer ( ) )
586- } ) ;
583+ check_bank_update_vote_stake_rewards (
584+ |bank : & Bank | bank. _load_vote_and_stake_accounts ( & thread_pool, null_tracer ( ) ) ,
585+ is_alpenglow,
586+ ) ;
587+ }
588+
589+ #[ test]
590+ fn test_bank_update_vote_stake_rewards_tests ( ) {
591+ test_bank_update_vote_stake_rewards ( false ) ;
592+ //TODO(wen): rewards to Alpenglow vote accounts don't work until epoch_stakes calculation
593+ // is updated.
594+ // test_bank_update_vote_stake_rewards(true);
587595}
588596
589597impl Bank {
@@ -683,7 +691,7 @@ type StakeDelegations = Vec<(Pubkey, StakeAccount<Delegation>)>;
683691type StakeDelegationsMap = DashMap < Pubkey , StakeDelegations > ;
684692
685693#[ cfg( test) ]
686- fn check_bank_update_vote_stake_rewards < F > ( load_vote_and_stake_accounts : F )
694+ fn check_bank_update_vote_stake_rewards < F > ( load_vote_and_stake_accounts : F , is_alpenglow : bool )
687695where
688696 F : Fn ( & Bank ) -> StakeDelegationsMap ,
689697{
@@ -718,27 +726,39 @@ where
718726 ) ;
719727
720728 let ( ( vote_id, mut vote_account) , ( stake_id, stake_account) ) =
721- crate :: stakes:: tests:: create_staked_node_accounts ( 10_000 ) ;
729+ crate :: stakes:: tests:: create_staked_node_accounts ( 10_000 , is_alpenglow ) ;
722730 let starting_vote_and_stake_balance = 10_000 + 1 ;
723731
724732 // set up accounts
725733 bank0. store_account_and_update_capitalization ( & stake_id, & stake_account) ;
726734
727735 // generate some rewards
728- let mut vote_state = Some ( vote_state:: from ( & vote_account) . unwrap ( ) ) ;
729- for i in 0 ..MAX_LOCKOUT_HISTORY + 42 {
730- if let Some ( v) = vote_state. as_mut ( ) {
731- vote_state:: process_slot_vote_unchecked ( v, i as u64 )
736+ if is_alpenglow {
737+ let mut vote_state =
738+ * alpenglow_vote:: state:: VoteState :: deserialize ( vote_account. data ( ) ) . unwrap ( ) ;
739+ for _ in 0 ..MAX_LOCKOUT_HISTORY + 42 {
740+ let mut epoch_credits = * vote_state. epoch_credits ( ) ;
741+ epoch_credits. set_credits ( epoch_credits. credits ( ) + 16 ) ;
742+ vote_state. set_epoch_credits ( epoch_credits) ;
743+ vote_state. serialize_into ( vote_account. data_as_mut_slice ( ) ) ;
744+ bank0. store_account_and_update_capitalization ( & vote_id, & vote_account) ;
732745 }
733- let versioned = VoteStateVersions :: Current ( Box :: new ( vote_state. take ( ) . unwrap ( ) ) ) ;
734- vote_state:: to ( & versioned, & mut vote_account) . unwrap ( ) ;
735- bank0. store_account_and_update_capitalization ( & vote_id, & vote_account) ;
736- match versioned {
737- VoteStateVersions :: Current ( v) => {
738- vote_state = Some ( * v) ;
746+ } else {
747+ let mut vote_state = Some ( vote_state:: from ( & vote_account) . unwrap ( ) ) ;
748+ for i in 0 ..MAX_LOCKOUT_HISTORY + 42 {
749+ if let Some ( v) = vote_state. as_mut ( ) {
750+ vote_state:: process_slot_vote_unchecked ( v, i as u64 )
739751 }
740- _ => panic ! ( "Has to be of type Current" ) ,
741- } ;
752+ let versioned = VoteStateVersions :: Current ( Box :: new ( vote_state. take ( ) . unwrap ( ) ) ) ;
753+ vote_state:: to ( & versioned, & mut vote_account) . unwrap ( ) ;
754+ bank0. store_account_and_update_capitalization ( & vote_id, & vote_account) ;
755+ match versioned {
756+ VoteStateVersions :: Current ( v) => {
757+ vote_state = Some ( * v) ;
758+ }
759+ _ => panic ! ( "Has to be of type Current" ) ,
760+ } ;
761+ }
742762 }
743763 bank0. store_account_and_update_capitalization ( & vote_id, & vote_account) ;
744764 bank0. freeze ( ) ;
@@ -3512,8 +3532,7 @@ fn test_add_duplicate_static_program() {
35123532 ) ;
35133533}
35143534
3515- #[ test]
3516- fn test_add_instruction_processor_for_existing_unrelated_accounts ( ) {
3535+ fn test_add_instruction_processor_for_existing_unrelated_accounts ( is_alpenglow : bool ) {
35173536 for pass in 0 ..5 {
35183537 let mut bank = create_simple_test_bank ( 500 ) ;
35193538
@@ -3537,7 +3556,7 @@ fn test_add_instruction_processor_for_existing_unrelated_accounts() {
35373556 }
35383557
35393558 let ( ( vote_id, vote_account) , ( stake_id, stake_account) ) =
3540- crate :: stakes:: tests:: create_staked_node_accounts ( 1_0000 ) ;
3559+ crate :: stakes:: tests:: create_staked_node_accounts ( 1_0000 , is_alpenglow ) ;
35413560 bank. capitalization
35423561 . fetch_add ( vote_account. lamports ( ) + stake_account. lamports ( ) , Relaxed ) ;
35433562 bank. store_account ( & vote_id, & vote_account) ;
@@ -3617,6 +3636,12 @@ fn test_add_instruction_processor_for_existing_unrelated_accounts() {
36173636 }
36183637}
36193638
3639+ #[ test]
3640+ fn test_add_instruction_processor_for_existing_unrelated_accounts_tests ( ) {
3641+ test_add_instruction_processor_for_existing_unrelated_accounts ( false ) ;
3642+ test_add_instruction_processor_for_existing_unrelated_accounts ( true ) ;
3643+ }
3644+
36203645#[ allow( deprecated) ]
36213646#[ test]
36223647fn test_recent_blockhashes_sysvar ( ) {
0 commit comments