@@ -7037,25 +7037,24 @@ fn test_program_replacement() {
70377037
70387038 // Setup original program account
70397039 let old_address = Pubkey :: new_unique ( ) ;
7040- let new_address = Pubkey :: new_unique ( ) ;
7041- bank. store_account_and_update_capitalization (
7042- & old_address,
7043- & AccountSharedData :: from ( Account {
7044- lamports : 100 ,
7045- ..Account :: default ( )
7046- } ) ,
7047- ) ;
7048- assert_eq ! ( bank. get_balance( & old_address) , 100 ) ;
7040+ let old_lamports = 100 ;
7041+ let old_data_size = 1_111 ;
7042+ let old_program_account =
7043+ AccountSharedData :: new ( old_lamports, old_data_size, & Pubkey :: new_unique ( ) ) ;
7044+ bank. store_account_and_update_capitalization ( & old_address, & old_program_account) ;
7045+ assert_eq ! ( bank. get_balance( & old_address) , old_lamports) ;
70497046
70507047 // Setup new program account
7051- let new_program_account = AccountSharedData :: from ( Account {
7052- lamports : 123 ,
7053- ..Account :: default ( )
7054- } ) ;
7048+ let new_address = Pubkey :: new_unique ( ) ;
7049+ let new_lamports = old_lamports + 23 ;
7050+ let new_data_size = old_data_size + 444 ;
7051+ let new_program_account =
7052+ AccountSharedData :: new ( new_lamports, new_data_size, & Pubkey :: new_unique ( ) ) ;
70557053 bank. store_account_and_update_capitalization ( & new_address, & new_program_account) ;
7056- assert_eq ! ( bank. get_balance( & new_address) , 123 ) ;
7054+ assert_eq ! ( bank. get_balance( & new_address) , new_lamports ) ;
70577055
70587056 let original_capitalization = bank. capitalization ( ) ;
7057+ let original_accounts_data_size = bank. load_accounts_data_size ( ) ;
70597058
70607059 bank. replace_program_account ( & old_address, & new_address, "bank-apply_program_replacement" ) ;
70617060
@@ -7066,7 +7065,16 @@ fn test_program_replacement() {
70667065 assert_eq ! ( bank. get_account( & old_address) , Some ( new_program_account) ) ;
70677066
70687067 // Lamports in the old token account were burnt
7069- assert_eq ! ( bank. capitalization( ) , original_capitalization - 100 ) ;
7068+ assert_eq ! (
7069+ bank. capitalization( ) ,
7070+ original_capitalization - old_lamports
7071+ ) ;
7072+
7073+ // Old program account was removed from accounts data size
7074+ assert_eq ! (
7075+ bank. load_accounts_data_size( ) ,
7076+ original_accounts_data_size - old_data_size as u64 ,
7077+ ) ;
70707078}
70717079
70727080fn min_rent_exempt_balance_for_sysvars ( bank : & Bank , sysvar_ids : & [ Pubkey ] ) -> u64 {
0 commit comments