4848 } ,
4949 spl_token_group_interface:: state:: { TokenGroup , TokenGroupMember } ,
5050 spl_token_metadata_interface:: state:: TokenMetadata ,
51- std:: { ffi:: OsString , path:: PathBuf , str:: FromStr , sync:: Arc } ,
51+ std:: {
52+ ffi:: { OsStr , OsString } ,
53+ path:: PathBuf ,
54+ str:: FromStr ,
55+ sync:: Arc ,
56+ } ,
5257 tempfile:: NamedTempFile ,
5358} ;
5459
@@ -441,7 +446,7 @@ where
441446 process_command ( & sub_command, matches, config, wallet_manager, bulk_signers) . await
442447}
443448
444- async fn exec_test_cmd ( config : & Config < ' _ > , args : & [ & str ] ) -> CommandResult {
449+ async fn exec_test_cmd < T : AsRef < OsStr > > ( config : & Config < ' _ > , args : & [ T ] ) -> CommandResult {
445450 let default_decimals = format ! ( "{}" , spl_token_2022:: native_mint:: DECIMALS ) ;
446451 let minimum_signers_help = minimum_signers_help_string ( ) ;
447452 let multisig_member_help = multisig_member_help_string ( ) ;
@@ -2974,7 +2979,11 @@ async fn multisig_transfer(test_validator: &TestValidator, payer: &Keypair) {
29742979 }
29752980}
29762981
2977- async fn offline_multisig_transfer_with_nonce ( test_validator : & TestValidator , payer : & Keypair ) {
2982+ async fn do_offline_multisig_transfer (
2983+ test_validator : & TestValidator ,
2984+ payer : & Keypair ,
2985+ compute_unit_price : Option < u64 > ,
2986+ ) {
29782987 let m = 2 ;
29792988 let n = 3u8 ;
29802989
@@ -3036,40 +3045,42 @@ async fn offline_multisig_transfer_with_nonce(test_validator: &TestValidator, pa
30363045 let program_client: Arc < dyn ProgramClient < ProgramRpcClientSendTransaction > > = Arc :: new (
30373046 ProgramOfflineClient :: new ( blockhash, ProgramRpcClientSendTransaction ) ,
30383047 ) ;
3048+ let mut args = vec ! [
3049+ "spl-token" . to_string( ) ,
3050+ CommandName :: Transfer . as_ref( ) . to_string( ) ,
3051+ token. to_string( ) ,
3052+ "10" . to_string( ) ,
3053+ destination. to_string( ) ,
3054+ "--blockhash" . to_string( ) ,
3055+ blockhash. to_string( ) ,
3056+ "--nonce" . to_string( ) ,
3057+ nonce. to_string( ) ,
3058+ "--nonce-authority" . to_string( ) ,
3059+ payer. pubkey( ) . to_string( ) ,
3060+ "--sign-only" . to_string( ) ,
3061+ "--mint-decimals" . to_string( ) ,
3062+ format!( "{}" , TEST_DECIMALS ) ,
3063+ "--multisig-signer" . to_string( ) ,
3064+ multisig_paths[ 1 ] . path( ) . to_str( ) . unwrap( ) . to_string( ) ,
3065+ "--multisig-signer" . to_string( ) ,
3066+ multisig_members[ 2 ] . to_string( ) ,
3067+ "--from" . to_string( ) ,
3068+ source. to_string( ) ,
3069+ "--owner" . to_string( ) ,
3070+ multisig_pubkey. to_string( ) ,
3071+ "--fee-payer" . to_string( ) ,
3072+ payer. pubkey( ) . to_string( ) ,
3073+ "--program-id" . to_string( ) ,
3074+ program_id. to_string( ) ,
3075+ ] ;
3076+ if let Some ( compute_unit_price) = compute_unit_price {
3077+ args. push ( "--with-compute-unit-price" . to_string ( ) ) ;
3078+ args. push ( compute_unit_price. to_string ( ) ) ;
3079+ args. push ( "--with-compute-unit-limit" . to_string ( ) ) ;
3080+ args. push ( 10_000 . to_string ( ) ) ;
3081+ }
30393082 config. program_client = program_client;
3040- let result = exec_test_cmd (
3041- & config,
3042- & [
3043- "spl-token" ,
3044- CommandName :: Transfer . into ( ) ,
3045- & token. to_string ( ) ,
3046- "10" ,
3047- & destination. to_string ( ) ,
3048- "--blockhash" ,
3049- & blockhash. to_string ( ) ,
3050- "--nonce" ,
3051- & nonce. to_string ( ) ,
3052- "--nonce-authority" ,
3053- & payer. pubkey ( ) . to_string ( ) ,
3054- "--sign-only" ,
3055- "--mint-decimals" ,
3056- & format ! ( "{}" , TEST_DECIMALS ) ,
3057- "--multisig-signer" ,
3058- multisig_paths[ 1 ] . path ( ) . to_str ( ) . unwrap ( ) ,
3059- "--multisig-signer" ,
3060- & multisig_members[ 2 ] . to_string ( ) ,
3061- "--from" ,
3062- & source. to_string ( ) ,
3063- "--owner" ,
3064- & multisig_pubkey. to_string ( ) ,
3065- "--fee-payer" ,
3066- & payer. pubkey ( ) . to_string ( ) ,
3067- "--program-id" ,
3068- & program_id. to_string ( ) ,
3069- ] ,
3070- )
3071- . await
3072- . unwrap ( ) ;
3083+ let result = exec_test_cmd ( & config, & args) . await . unwrap ( ) ;
30733084 // the provided signer has a signature, denoted by the pubkey followed
30743085 // by "=" and the signature
30753086 let member_prefix = format ! ( "{}=" , multisig_members[ 1 ] ) ;
@@ -3096,40 +3107,42 @@ async fn offline_multisig_transfer_with_nonce(test_validator: &TestValidator, pa
30963107 ProgramRpcClient :: new ( config. rpc_client . clone ( ) , ProgramRpcClientSendTransaction ) ,
30973108 ) ;
30983109 config. program_client = program_client;
3099- exec_test_cmd (
3100- & config,
3101- & [
3102- "spl-token" ,
3103- CommandName :: Transfer . into ( ) ,
3104- & token. to_string ( ) ,
3105- "10" ,
3106- & destination. to_string ( ) ,
3107- "--blockhash" ,
3108- & blockhash. to_string ( ) ,
3109- "--nonce" ,
3110- & nonce. to_string ( ) ,
3111- "--nonce-authority" ,
3112- & fee_payer_keypair_file. path ( ) . to_str ( ) . unwrap ( ) ,
3113- "--mint-decimals" ,
3114- & format ! ( "{}" , TEST_DECIMALS ) ,
3115- "--multisig-signer" ,
3116- & multisig_members[ 1 ] . to_string ( ) ,
3117- "--multisig-signer" ,
3118- multisig_paths[ 2 ] . path ( ) . to_str ( ) . unwrap ( ) ,
3119- "--from" ,
3120- & source. to_string ( ) ,
3121- "--owner" ,
3122- & multisig_pubkey. to_string ( ) ,
3123- "--fee-payer" ,
3124- & fee_payer_keypair_file. path ( ) . to_str ( ) . unwrap ( ) ,
3125- "--program-id" ,
3126- & program_id. to_string ( ) ,
3127- "--signer" ,
3128- signer,
3129- ] ,
3130- )
3131- . await
3132- . unwrap ( ) ;
3110+ let mut args = vec ! [
3111+ "spl-token" . to_string( ) ,
3112+ CommandName :: Transfer . as_ref( ) . to_string( ) ,
3113+ token. to_string( ) ,
3114+ "10" . to_string( ) ,
3115+ destination. to_string( ) ,
3116+ "--blockhash" . to_string( ) ,
3117+ blockhash. to_string( ) ,
3118+ "--nonce" . to_string( ) ,
3119+ nonce. to_string( ) ,
3120+ "--nonce-authority" . to_string( ) ,
3121+ fee_payer_keypair_file. path( ) . to_str( ) . unwrap( ) . to_string( ) ,
3122+ "--mint-decimals" . to_string( ) ,
3123+ format!( "{}" , TEST_DECIMALS ) ,
3124+ "--multisig-signer" . to_string( ) ,
3125+ multisig_members[ 1 ] . to_string( ) ,
3126+ "--multisig-signer" . to_string( ) ,
3127+ multisig_paths[ 2 ] . path( ) . to_str( ) . unwrap( ) . to_string( ) ,
3128+ "--from" . to_string( ) ,
3129+ source. to_string( ) ,
3130+ "--owner" . to_string( ) ,
3131+ multisig_pubkey. to_string( ) ,
3132+ "--fee-payer" . to_string( ) ,
3133+ fee_payer_keypair_file. path( ) . to_str( ) . unwrap( ) . to_string( ) ,
3134+ "--program-id" . to_string( ) ,
3135+ program_id. to_string( ) ,
3136+ "--signer" . to_string( ) ,
3137+ signer. to_string( ) ,
3138+ ] ;
3139+ if let Some ( compute_unit_price) = compute_unit_price {
3140+ args. push ( "--with-compute-unit-price" . to_string ( ) ) ;
3141+ args. push ( compute_unit_price. to_string ( ) ) ;
3142+ args. push ( "--with-compute-unit-limit" . to_string ( ) ) ;
3143+ args. push ( 10_000 . to_string ( ) ) ;
3144+ }
3145+ exec_test_cmd ( & config, & args) . await . unwrap ( ) ;
31333146
31343147 let account = config. rpc_client . get_account ( & source) . await . unwrap ( ) ;
31353148 let token_account = StateWithExtensionsOwned :: < Account > :: unpack ( account. data ) . unwrap ( ) ;
@@ -3142,6 +3155,11 @@ async fn offline_multisig_transfer_with_nonce(test_validator: &TestValidator, pa
31423155 }
31433156}
31443157
3158+ async fn offline_multisig_transfer_with_nonce ( test_validator : & TestValidator , payer : & Keypair ) {
3159+ do_offline_multisig_transfer ( test_validator, payer, None ) . await ;
3160+ do_offline_multisig_transfer ( test_validator, payer, Some ( 10 ) ) . await ;
3161+ }
3162+
31453163async fn withdraw_excess_lamports_from_multisig ( test_validator : & TestValidator , payer : & Keypair ) {
31463164 let m = 3 ;
31473165 let n = 5u8 ;
0 commit comments