39
39
} ;
40
40
41
41
const TEST_MAXIMUM_FEE : u64 = 10_000_000 ;
42
- const TEST_FEE_BASIS_POINTS : u16 = 250 ;
42
+ const TEST_FEE_BASIS_POINTS : u16 = 100 ;
43
43
44
44
/// Test program to fail transfer hook, conforms to transfer-hook-interface
45
45
pub fn process_instruction_fail (
@@ -144,6 +144,58 @@ pub fn process_instruction_swap(
144
144
Ok ( ( ) )
145
145
}
146
146
147
+ // Test program to transfer two types of tokens with transfer hooks at once with
148
+ // fees
149
+ pub fn process_instruction_swap_with_fee (
150
+ _program_id : & Pubkey ,
151
+ accounts : & [ AccountInfo ] ,
152
+ _input : & [ u8 ] ,
153
+ ) -> ProgramResult {
154
+ let account_info_iter = & mut accounts. iter ( ) ;
155
+
156
+ let source_a_account_info = next_account_info ( account_info_iter) ?;
157
+ let mint_a_info = next_account_info ( account_info_iter) ?;
158
+ let destination_a_account_info = next_account_info ( account_info_iter) ?;
159
+ let authority_a_info = next_account_info ( account_info_iter) ?;
160
+ let token_program_a_info = next_account_info ( account_info_iter) ?;
161
+
162
+ let source_b_account_info = next_account_info ( account_info_iter) ?;
163
+ let mint_b_info = next_account_info ( account_info_iter) ?;
164
+ let destination_b_account_info = next_account_info ( account_info_iter) ?;
165
+ let authority_b_info = next_account_info ( account_info_iter) ?;
166
+ let token_program_b_info = next_account_info ( account_info_iter) ?;
167
+
168
+ let remaining_accounts = account_info_iter. as_slice ( ) ;
169
+
170
+ onchain:: invoke_transfer_checked_with_fee (
171
+ token_program_a_info. key ,
172
+ source_a_account_info. clone ( ) ,
173
+ mint_a_info. clone ( ) ,
174
+ destination_a_account_info. clone ( ) ,
175
+ authority_a_info. clone ( ) ,
176
+ remaining_accounts,
177
+ 1_000_000_000 ,
178
+ 9 ,
179
+ 10_000_000 ,
180
+ & [ ] ,
181
+ ) ?;
182
+
183
+ onchain:: invoke_transfer_checked_with_fee (
184
+ token_program_b_info. key ,
185
+ source_b_account_info. clone ( ) ,
186
+ mint_b_info. clone ( ) ,
187
+ destination_b_account_info. clone ( ) ,
188
+ authority_b_info. clone ( ) ,
189
+ remaining_accounts,
190
+ 1_000_000_000 ,
191
+ 9 ,
192
+ 10_000_000 ,
193
+ & [ ] ,
194
+ ) ?;
195
+
196
+ Ok ( ( ) )
197
+ }
198
+
147
199
async fn setup_accounts (
148
200
token_context : & TokenContext ,
149
201
alice_account : Keypair ,
@@ -973,7 +1025,7 @@ async fn success_transfers_with_fee_using_onchain_helper() {
973
1025
let mint_a = mint_a_keypair. pubkey ( ) ;
974
1026
let mint_b_keypair = Keypair :: new ( ) ;
975
1027
let mint_b = mint_b_keypair. pubkey ( ) ;
976
- let amount = 10 ;
1028
+ let amount = 10_000_000_000 ;
977
1029
978
1030
let transfer_fee_config_authority = Keypair :: new ( ) ;
979
1031
let withdraw_withheld_authority = Keypair :: new ( ) ;
@@ -985,7 +1037,7 @@ async fn success_transfers_with_fee_using_onchain_helper() {
985
1037
program_test. add_program (
986
1038
"my_swap" ,
987
1039
swap_program_id,
988
- processor ! ( process_instruction_swap ) ,
1040
+ processor ! ( process_instruction_swap_with_fee ) ,
989
1041
) ;
990
1042
add_validation_account ( & mut program_test, & mint_a, & program_id) ;
991
1043
add_validation_account ( & mut program_test, & mint_b, & program_id) ;
0 commit comments