@@ -6,8 +6,8 @@ use crate::{
6
6
option:: COption ,
7
7
} ;
8
8
use solana_sdk:: {
9
- account_info:: AccountInfo , entrypoint:: ProgramResult , info, program_error :: ProgramError ,
10
- account_info :: next_account_info , pubkey:: Pubkey ,
9
+ account_info:: next_account_info , account_info :: AccountInfo , entrypoint:: ProgramResult , info,
10
+ program_error :: ProgramError , pubkey:: Pubkey ,
11
11
} ;
12
12
use std:: mem:: size_of;
13
13
@@ -425,8 +425,8 @@ impl State {
425
425
let mut source_data = source_account_info. data . borrow_mut ( ) ;
426
426
let source_account: & mut Account = Self :: unpack ( & mut source_data) ?;
427
427
428
- if !source_account. is_native && source_account . amount != 0 {
429
- return Err ( TokenError :: NonNativeHasBalance . into ( ) ) ;
428
+ if !source_account. is_native {
429
+ return Err ( TokenError :: NonNativeNotSupported . into ( ) ) ;
430
430
}
431
431
432
432
Self :: validate_owner (
@@ -2053,19 +2053,12 @@ mod tests {
2053
2053
)
2054
2054
) ;
2055
2055
2056
- // initialize and mint to account
2056
+ // initialize non-native account
2057
2057
do_process_instruction (
2058
2058
initialize_account ( & program_id, & account_key, & mint_key, & owner_key) . unwrap ( ) ,
2059
2059
vec ! [ & mut account_account, & mut mint_account, & mut owner_account] ,
2060
2060
)
2061
2061
. unwrap ( ) ;
2062
- do_process_instruction (
2063
- initialize_mint ( & program_id, & mint_key, Some ( & account_key) , None , 42 , 2 ) . unwrap ( ) ,
2064
- vec ! [ & mut mint_account, & mut account_account, & mut owner_account] ,
2065
- )
2066
- . unwrap ( ) ;
2067
- let account: & mut Account = State :: unpack ( & mut account_account. data ) . unwrap ( ) ;
2068
- assert_eq ! ( account. amount, 42 ) ;
2069
2062
2070
2063
// initialize native account
2071
2064
do_process_instruction (
@@ -2083,9 +2076,9 @@ mod tests {
2083
2076
assert ! ( account. is_native) ;
2084
2077
assert_eq ! ( account. amount, 2 ) ;
2085
2078
2086
- // close account with balance
2079
+ // close non-native account
2087
2080
assert_eq ! (
2088
- Err ( TokenError :: NonNativeHasBalance . into( ) ) ,
2081
+ Err ( TokenError :: NonNativeNotSupported . into( ) ) ,
2089
2082
do_process_instruction(
2090
2083
close_account( & program_id, & account_key, & account3_key, & owner_key, & [ ] ) . unwrap( ) ,
2091
2084
vec![
@@ -2095,41 +2088,7 @@ mod tests {
2095
2088
] ,
2096
2089
)
2097
2090
) ;
2098
-
2099
- // empty account
2100
- do_process_instruction (
2101
- burn ( & program_id, & account_key, & owner_key, & [ ] , 42 ) . unwrap ( ) ,
2102
- vec ! [ & mut account_account, & mut owner_account] ,
2103
- )
2104
- . unwrap ( ) ;
2105
-
2106
- // wrong owner
2107
- assert_eq ! (
2108
- Err ( TokenError :: OwnerMismatch . into( ) ) ,
2109
- do_process_instruction(
2110
- close_account( & program_id, & account_key, & account3_key, & owner2_key, & [ ] ) . unwrap( ) ,
2111
- vec![
2112
- & mut account_account,
2113
- & mut account3_account,
2114
- & mut owner2_account,
2115
- ] ,
2116
- )
2117
- ) ;
2118
-
2119
- // close account
2120
- do_process_instruction (
2121
- close_account ( & program_id, & account_key, & account3_key, & owner_key, & [ ] ) . unwrap ( ) ,
2122
- vec ! [
2123
- & mut account_account,
2124
- & mut account3_account,
2125
- & mut owner_account,
2126
- ] ,
2127
- )
2128
- . unwrap ( ) ;
2129
- let account: & mut Account = State :: unpack_unchecked ( & mut account_account. data ) . unwrap ( ) ;
2130
- assert_eq ! ( account_account. lamports, 0 ) ;
2131
- assert_eq ! ( account. amount, 0 ) ;
2132
- assert_eq ! ( account3_account. lamports, 44 ) ;
2091
+ assert_eq ! ( account_account. lamports, 42 ) ;
2133
2092
2134
2093
// close native account
2135
2094
do_process_instruction (
@@ -2143,9 +2102,8 @@ mod tests {
2143
2102
. unwrap ( ) ;
2144
2103
let account: & mut Account = State :: unpack_unchecked ( & mut account2_account. data ) . unwrap ( ) ;
2145
2104
assert ! ( account. is_native) ;
2146
- assert_eq ! ( account_account. lamports, 0 ) ;
2147
2105
assert_eq ! ( account. amount, 0 ) ;
2148
- assert_eq ! ( account3_account. lamports, 46 ) ;
2106
+ assert_eq ! ( account3_account. lamports, 4 ) ;
2149
2107
}
2150
2108
2151
2109
#[ test]
0 commit comments