@@ -135,6 +135,7 @@ async fn main() {
135135 async_trial!( metadata, test_validator, payer) ,
136136 async_trial!( group, test_validator, payer) ,
137137 async_trial!( confidential_transfer_with_fee, test_validator, payer) ,
138+ async_trial!( compute_budget, test_validator, payer) ,
138139 // GC messes with every other test, so have it on its own test validator
139140 async_trial!( gc, gc_test_validator, gc_payer) ,
140141 ] ;
@@ -199,6 +200,8 @@ fn test_config_with_default_signer<'a>(
199200 multisigner_pubkeys : vec ! [ ] ,
200201 program_id : * program_id,
201202 restrict_to_program_id : true ,
203+ compute_unit_price : None ,
204+ compute_unit_limit : None ,
202205 }
203206}
204207
@@ -226,6 +229,8 @@ fn test_config_without_default_signer<'a>(
226229 multisigner_pubkeys : vec ! [ ] ,
227230 program_id : * program_id,
228231 restrict_to_program_id : true ,
232+ compute_unit_price : None ,
233+ compute_unit_limit : None ,
229234 }
230235}
231236
@@ -380,6 +385,38 @@ async fn mint_tokens(
380385 . await
381386}
382387
388+ async fn run_transfer_test ( config : & Config < ' _ > , payer : & Keypair ) {
389+ let token = create_token ( config, payer) . await ;
390+ let source = create_associated_account ( config, payer, & token, & payer. pubkey ( ) ) . await ;
391+ let destination = create_auxiliary_account ( config, payer, token) . await ;
392+ let ui_amount = 100.0 ;
393+ mint_tokens ( config, payer, token, ui_amount, source)
394+ . await
395+ . unwrap ( ) ;
396+ let result = process_test_command (
397+ config,
398+ payer,
399+ & [
400+ "spl-token" ,
401+ CommandName :: Transfer . into ( ) ,
402+ & token. to_string ( ) ,
403+ "10" ,
404+ & destination. to_string ( ) ,
405+ ] ,
406+ )
407+ . await ;
408+ result. unwrap ( ) ;
409+
410+ let account = config. rpc_client . get_account ( & source) . await . unwrap ( ) ;
411+ let token_account = StateWithExtensionsOwned :: < Account > :: unpack ( account. data ) . unwrap ( ) ;
412+ let amount = spl_token:: ui_amount_to_amount ( 90.0 , TEST_DECIMALS ) ;
413+ assert_eq ! ( token_account. base. amount, amount) ;
414+ let account = config. rpc_client . get_account ( & destination) . await . unwrap ( ) ;
415+ let token_account = StateWithExtensionsOwned :: < Account > :: unpack ( account. data ) . unwrap ( ) ;
416+ let amount = spl_token:: ui_amount_to_amount ( 10.0 , TEST_DECIMALS ) ;
417+ assert_eq ! ( token_account. base. amount, amount) ;
418+ }
419+
383420async fn process_test_command < I , T > ( config : & Config < ' _ > , payer : & Keypair , args : I ) -> CommandResult
384421where
385422 I : IntoIterator < Item = T > ,
@@ -855,35 +892,7 @@ async fn wrapped_sol(test_validator: &TestValidator, payer: &Keypair) {
855892async fn transfer ( test_validator : & TestValidator , payer : & Keypair ) {
856893 for program_id in VALID_TOKEN_PROGRAM_IDS . iter ( ) {
857894 let config = test_config_with_default_signer ( test_validator, payer, program_id) ;
858- let token = create_token ( & config, payer) . await ;
859- let source = create_associated_account ( & config, payer, & token, & payer. pubkey ( ) ) . await ;
860- let destination = create_auxiliary_account ( & config, payer, token) . await ;
861- let ui_amount = 100.0 ;
862- mint_tokens ( & config, payer, token, ui_amount, source)
863- . await
864- . unwrap ( ) ;
865- let result = process_test_command (
866- & config,
867- payer,
868- & [
869- "spl-token" ,
870- CommandName :: Transfer . into ( ) ,
871- & token. to_string ( ) ,
872- "10" ,
873- & destination. to_string ( ) ,
874- ] ,
875- )
876- . await ;
877- result. unwrap ( ) ;
878-
879- let account = config. rpc_client . get_account ( & source) . await . unwrap ( ) ;
880- let token_account = StateWithExtensionsOwned :: < Account > :: unpack ( account. data ) . unwrap ( ) ;
881- let amount = spl_token:: ui_amount_to_amount ( 90.0 , TEST_DECIMALS ) ;
882- assert_eq ! ( token_account. base. amount, amount) ;
883- let account = config. rpc_client . get_account ( & destination) . await . unwrap ( ) ;
884- let token_account = StateWithExtensionsOwned :: < Account > :: unpack ( account. data ) . unwrap ( ) ;
885- let amount = spl_token:: ui_amount_to_amount ( 10.0 , TEST_DECIMALS ) ;
886- assert_eq ! ( token_account. base. amount, amount) ;
895+ run_transfer_test ( & config, payer) . await ;
887896 }
888897}
889898
@@ -4010,3 +4019,12 @@ async fn group(test_validator: &TestValidator, payer: &Keypair) {
40104019 let extension = mint_state. get_extension :: < TokenGroup > ( ) . unwrap ( ) ;
40114020 assert_eq ! ( extension. update_authority, Some ( mint) . try_into( ) . unwrap( ) ) ;
40124021}
4022+
4023+ async fn compute_budget ( test_validator : & TestValidator , payer : & Keypair ) {
4024+ for program_id in VALID_TOKEN_PROGRAM_IDS . iter ( ) {
4025+ let mut config = test_config_with_default_signer ( test_validator, payer, program_id) ;
4026+ config. compute_unit_price = Some ( 42 ) ;
4027+ config. compute_unit_limit = Some ( 30_000 ) ;
4028+ run_transfer_test ( & config, payer) . await ;
4029+ }
4030+ }
0 commit comments