@@ -370,6 +370,10 @@ impl Processor {
370370
371371 account. delegate = COption :: None ;
372372 account. delegated_amount = 0 ;
373+
374+ if account. is_native ( ) {
375+ account. close_authority = COption :: None ;
376+ }
373377 }
374378 AuthorityType :: CloseAccount => {
375379 let authority = account. close_authority . unwrap_or ( account. owner ) ;
@@ -5066,6 +5070,9 @@ mod tests {
50665070 let mut account3_account = SolanaAccount :: new ( account_minimum_balance ( ) , 0 , & program_id) ;
50675071 let owner_key = Pubkey :: new_unique ( ) ;
50685072 let mut owner_account = SolanaAccount :: default ( ) ;
5073+ let owner2_key = Pubkey :: new_unique ( ) ;
5074+ let mut owner2_account = SolanaAccount :: default ( ) ;
5075+ let owner3_key = Pubkey :: new_unique ( ) ;
50695076 let mut rent_sysvar = rent_sysvar ( ) ;
50705077
50715078 // initialize native account
@@ -5205,13 +5212,49 @@ mod tests {
52055212 assert ! ( account. is_native( ) ) ;
52065213 assert_eq ! ( account. amount, 40 ) ;
52075214
5215+ // set close authority
5216+ do_process_instruction (
5217+ set_authority (
5218+ & program_id,
5219+ & account_key,
5220+ Some ( & owner3_key) ,
5221+ AuthorityType :: CloseAccount ,
5222+ & owner_key,
5223+ & [ ] ,
5224+ )
5225+ . unwrap ( ) ,
5226+ vec ! [ & mut account_account, & mut owner_account] ,
5227+ )
5228+ . unwrap ( ) ;
5229+ let account = Account :: unpack_unchecked ( & account_account. data ) . unwrap ( ) ;
5230+ assert_eq ! ( account. close_authority, COption :: Some ( owner3_key) ) ;
5231+
5232+ // set new account owner
5233+ do_process_instruction (
5234+ set_authority (
5235+ & program_id,
5236+ & account_key,
5237+ Some ( & owner2_key) ,
5238+ AuthorityType :: AccountOwner ,
5239+ & owner_key,
5240+ & [ ] ,
5241+ )
5242+ . unwrap ( ) ,
5243+ vec ! [ & mut account_account, & mut owner_account] ,
5244+ )
5245+ . unwrap ( ) ;
5246+
5247+ // close authority cleared
5248+ let account = Account :: unpack_unchecked ( & account_account. data ) . unwrap ( ) ;
5249+ assert_eq ! ( account. close_authority, COption :: None ) ;
5250+
52085251 // close native account
52095252 do_process_instruction (
5210- close_account ( & program_id, & account_key, & account3_key, & owner_key , & [ ] ) . unwrap ( ) ,
5253+ close_account ( & program_id, & account_key, & account3_key, & owner2_key , & [ ] ) . unwrap ( ) ,
52115254 vec ! [
52125255 & mut account_account,
52135256 & mut account3_account,
5214- & mut owner_account ,
5257+ & mut owner2_account ,
52155258 ] ,
52165259 )
52175260 . unwrap ( ) ;
0 commit comments