Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.

Commit bda540d

Browse files
committed
Added test and short version
1 parent 0e31092 commit bda540d

File tree

3 files changed

+49
-7
lines changed

3 files changed

+49
-7
lines changed

token/cli/src/clap_app.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -656,12 +656,6 @@ pub fn app<'a, 'b>(
656656
[default: randomly generated keypair]"
657657
),
658658
)
659-
.arg(
660-
Arg::with_name("program_2022")
661-
.value_name("TOKEN_22_PROGRAM_ID")
662-
.short("token22")
663-
.long("TokenProgram22")
664-
.help("Use token extension program token 2022 program id: TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"))
665659
.arg(
666660
Arg::with_name("mint_authority")
667661
.long("mint-authority")
@@ -699,6 +693,13 @@ pub fn app<'a, 'b>(
699693
"Enable the mint authority to close this mint"
700694
),
701695
)
696+
.arg(
697+
Arg::with_name("token_program_2022")
698+
.value_name("token-program-2022")
699+
.short("2")
700+
.long("token-program-2022")
701+
.takes_value(false)
702+
.help("Use token extension program token 2022 with program id: TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"))
702703
.arg(
703704
Arg::with_name("interest_rate")
704705
.long("interest-rate")

token/cli/src/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ impl<'a> Config<'a> {
261261

262262
let default_program_id = spl_token::id();
263263
let (program_id, restrict_to_program_id) =
264-
if matches.is_present("program_2022") {
264+
if matches.is_present("token_program_2022") {
265265
(spl_token_2022::id(), true)
266266
} else if let Some(program_id) = value_of(matches, "program_id") {
267267
(program_id, true)

token/cli/tests/command.rs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ async fn main() {
9292
// maybe come up with a way to do this through a some macro tag on the function?
9393
let tests = vec![
9494
async_trial!(create_token_default, test_validator, payer),
95+
async_trial!(create_token_2022, test_validator, payer),
9596
async_trial!(create_token_interest_bearing, test_validator, payer),
9697
async_trial!(set_interest_rate, test_validator, payer),
9798
async_trial!(supply, test_validator, payer),
@@ -495,6 +496,46 @@ async fn create_token_default(test_validator: &TestValidator, payer: &Keypair) {
495496
}
496497
}
497498

499+
500+
async fn create_token_2022(test_validator: &TestValidator, payer: &Keypair) {
501+
let config = test_config_with_default_signer(test_validator, payer, &spl_token_2022::id());
502+
let mut wallet_manager = None;
503+
let mut bulk_signers: Vec<Arc<dyn Signer>> = Vec::new();
504+
let mut multisigner_ids = Vec::new();
505+
506+
let args = &[
507+
"spl-token",
508+
CommandName::CreateToken.into(),
509+
"--token-program-2022"
510+
];
511+
512+
let default_decimals = format!("{}", spl_token_2022::native_mint::DECIMALS);
513+
let minimum_signers_help = minimum_signers_help_string();
514+
let multisig_member_help = multisig_member_help_string();
515+
516+
let app_matches = app(
517+
&default_decimals,
518+
&minimum_signers_help,
519+
&multisig_member_help,
520+
)
521+
.get_matches_from(args);
522+
523+
let (_sub_command, sub_matches) = app_matches.subcommand();
524+
let matches = sub_matches.unwrap();
525+
526+
let config = Config::new_with_clients_and_ws_url(
527+
matches,
528+
&mut wallet_manager,
529+
&mut bulk_signers,
530+
&mut multisigner_ids,
531+
config.rpc_client.clone(),
532+
config.program_client.clone(),
533+
config.websocket_url.clone(),
534+
).await;
535+
536+
assert_eq!(config.program_id, spl_token_2022::ID);
537+
}
538+
498539
async fn create_token_interest_bearing(test_validator: &TestValidator, payer: &Keypair) {
499540
let config = test_config_with_default_signer(test_validator, payer, &spl_token_2022::id());
500541
let rate_bps: i16 = 100;

0 commit comments

Comments
 (0)