diff --git a/token-group/example/tests/initialize_collection.rs b/token-group/example/tests/initialize_collection.rs index 4ac742bfedf..f8095b2d4ca 100644 --- a/token-group/example/tests/initialize_collection.rs +++ b/token-group/example/tests/initialize_collection.rs @@ -3,7 +3,7 @@ mod setup; use { - setup::{setup_mint_and_metadata, setup_program_test}, + setup::{setup_mint, setup_program_test}, solana_program::{instruction::InstructionError, pubkey::Pubkey, system_instruction}, solana_program_test::tokio, solana_sdk::{ @@ -13,7 +13,6 @@ use { }, spl_token_client::token::Token, spl_token_group_interface::{instruction::initialize_group, state::Group}, - spl_token_metadata_interface::state::TokenMetadata, spl_type_length_value::{ error::TlvError, state::{TlvState, TlvStateBorrowed}, @@ -26,17 +25,7 @@ async fn test_initialize_collection() { let collection = Keypair::new(); let collection_mint = Keypair::new(); let collection_mint_authority = Keypair::new(); - let collection_metadata = Keypair::new(); - let collection_metadata_update_authority = Keypair::new(); - let collection_metadata_state = TokenMetadata { - update_authority: None.try_into().unwrap(), - mint: collection_mint.pubkey(), - name: "The Coolest Collection".to_string(), - symbol: "COOL".to_string(), - uri: "https://cool.com".to_string(), - additional_metadata: vec![], - }; let collection_group_state = Group { update_authority: None.try_into().unwrap(), size: 0.into(), @@ -52,17 +41,7 @@ async fn test_initialize_collection() { Some(0), payer.clone(), ); - - setup_mint_and_metadata( - &token_client, - &collection_mint, - &collection_mint_authority, - &collection_metadata.pubkey(), - &collection_metadata_update_authority.pubkey(), - &collection_metadata_state, - payer, - ) - .await; + setup_mint(&token_client, &collection_mint, &collection_mint_authority).await; let mut context = context.lock().await; diff --git a/token-group/example/tests/initialize_collection_member.rs b/token-group/example/tests/initialize_collection_member.rs index 15a8c3fceb8..f172c9a42b1 100644 --- a/token-group/example/tests/initialize_collection_member.rs +++ b/token-group/example/tests/initialize_collection_member.rs @@ -3,7 +3,7 @@ mod setup; use { - setup::{setup_mint_and_metadata, setup_program_test}, + setup::{setup_mint, setup_program_test}, solana_program::{instruction::InstructionError, pubkey::Pubkey, system_instruction}, solana_program_test::tokio, solana_sdk::{ @@ -16,7 +16,6 @@ use { instruction::{initialize_group, initialize_member}, state::{Group, Member}, }, - spl_token_metadata_interface::state::TokenMetadata, spl_type_length_value::state::{TlvState, TlvStateBorrowed}, }; @@ -26,20 +25,11 @@ async fn test_initialize_collection_member() { let collection = Keypair::new(); let collection_mint = Keypair::new(); let collection_mint_authority = Keypair::new(); - let collection_metadata = Keypair::new(); let collection_update_authority = Keypair::new(); let member = Keypair::new(); let member_mint = Keypair::new(); let member_mint_authority = Keypair::new(); - let collection_metadata_state = TokenMetadata { - update_authority: None.try_into().unwrap(), - mint: collection_mint.pubkey(), - name: "The Coolest Collection".to_string(), - symbol: "COOL".to_string(), - uri: "https://cool.com".to_string(), - additional_metadata: vec![], - }; let collection_group_state = Group { update_authority: Some(collection_update_authority.pubkey()) .try_into() @@ -50,7 +40,7 @@ async fn test_initialize_collection_member() { let (context, client, payer) = setup_program_test(&program_id).await; - setup_mint_and_metadata( + setup_mint( &Token::new( client.clone(), &spl_token_2022::id(), @@ -60,27 +50,20 @@ async fn test_initialize_collection_member() { ), &collection_mint, &collection_mint_authority, - &collection_metadata.pubkey(), - &collection_update_authority.pubkey(), - &collection_metadata_state, - payer.clone(), ) .await; - Token::new( - client, - &spl_token_2022::id(), - &member_mint.pubkey(), - Some(0), - payer.clone(), - ) - .create_mint( - &member_mint_authority.pubkey(), - None, - vec![], - &[&member_mint], + setup_mint( + &Token::new( + client.clone(), + &spl_token_2022::id(), + &member_mint.pubkey(), + Some(0), + payer.clone(), + ), + &member_mint, + &member_mint_authority, ) - .await - .unwrap(); + .await; let mut context = context.lock().await; diff --git a/token-group/example/tests/setup.rs b/token-group/example/tests/setup.rs index 93206f11462..14cb091830c 100644 --- a/token-group/example/tests/setup.rs +++ b/token-group/example/tests/setup.rs @@ -8,9 +8,8 @@ use { ProgramBanksClient, ProgramBanksClientProcessTransaction, ProgramClient, SendTransaction, SimulateTransaction, }, - token::{ExtensionInitializationParams, Token}, + token::Token, }, - spl_token_metadata_interface::state::TokenMetadata, std::sync::Arc, }; @@ -44,38 +43,19 @@ pub async fn setup_program_test( (context, client, payer) } -/// Set up a Token-2022 mint and metadata -pub async fn setup_mint_and_metadata( +/// Set up a Token-2022 mint +pub async fn setup_mint( token_client: &Token, mint_keypair: &Keypair, mint_authority_keypair: &Keypair, - metadata_pubkey: &Pubkey, - metadata_update_authority_pubkey: &Pubkey, - token_metadata: &TokenMetadata, - payer: Arc, ) { token_client .create_mint( &mint_authority_keypair.pubkey(), None, - vec![ExtensionInitializationParams::MetadataPointer { - authority: Some(*metadata_update_authority_pubkey), - metadata_address: Some(*metadata_pubkey), - }], + vec![], &[mint_keypair], ) .await .unwrap(); - token_client - .token_metadata_initialize_with_rent_transfer( - &payer.pubkey(), - metadata_update_authority_pubkey, - &mint_authority_keypair.pubkey(), - token_metadata.name.clone(), - token_metadata.symbol.clone(), - token_metadata.uri.clone(), - &[&payer, mint_authority_keypair], - ) - .await - .unwrap(); } diff --git a/token-group/example/tests/update_collection_authority.rs b/token-group/example/tests/update_collection_authority.rs index 089f9b765ec..9311ee45291 100644 --- a/token-group/example/tests/update_collection_authority.rs +++ b/token-group/example/tests/update_collection_authority.rs @@ -3,7 +3,7 @@ mod setup; use { - setup::{setup_mint_and_metadata, setup_program_test}, + setup::{setup_mint, setup_program_test}, solana_program::{instruction::InstructionError, pubkey::Pubkey, system_instruction}, solana_program_test::tokio, solana_sdk::{ @@ -17,7 +17,6 @@ use { instruction::{initialize_group, update_group_authority}, state::Group, }, - spl_token_metadata_interface::state::TokenMetadata, spl_type_length_value::state::{TlvState, TlvStateBorrowed}, }; @@ -27,17 +26,8 @@ async fn test_update_collection_authority() { let collection = Keypair::new(); let collection_mint = Keypair::new(); let collection_mint_authority = Keypair::new(); - let collection_metadata = Keypair::new(); let collection_update_authority = Keypair::new(); - let collection_metadata_state = TokenMetadata { - update_authority: None.try_into().unwrap(), - mint: collection_mint.pubkey(), - name: "The Coolest Collection".to_string(), - symbol: "COOL".to_string(), - uri: "https://cool.com".to_string(), - additional_metadata: vec![], - }; let collection_group_state = Group { update_authority: Some(collection_update_authority.pubkey()) .try_into() @@ -55,17 +45,7 @@ async fn test_update_collection_authority() { Some(0), payer.clone(), ); - - setup_mint_and_metadata( - &token_client, - &collection_mint, - &collection_mint_authority, - &collection_metadata.pubkey(), - &collection_update_authority.pubkey(), - &collection_metadata_state, - payer, - ) - .await; + setup_mint(&token_client, &collection_mint, &collection_mint_authority).await; let mut context = context.lock().await; diff --git a/token-group/example/tests/update_collection_max_size.rs b/token-group/example/tests/update_collection_max_size.rs index 3790fe81bad..a99ca531d78 100644 --- a/token-group/example/tests/update_collection_max_size.rs +++ b/token-group/example/tests/update_collection_max_size.rs @@ -3,7 +3,7 @@ mod setup; use { - setup::{setup_mint_and_metadata, setup_program_test}, + setup::{setup_mint, setup_program_test}, solana_program::{instruction::InstructionError, pubkey::Pubkey, system_instruction}, solana_program_test::tokio, solana_sdk::{ @@ -18,7 +18,6 @@ use { instruction::{initialize_group, update_group_max_size}, state::Group, }, - spl_token_metadata_interface::state::TokenMetadata, spl_type_length_value::state::{TlvState, TlvStateBorrowed, TlvStateMut}, }; @@ -28,17 +27,8 @@ async fn test_update_collection_max_size() { let collection = Keypair::new(); let collection_mint = Keypair::new(); let collection_mint_authority = Keypair::new(); - let collection_metadata = Keypair::new(); let collection_update_authority = Keypair::new(); - let collection_metadata_state = TokenMetadata { - update_authority: None.try_into().unwrap(), - mint: collection_mint.pubkey(), - name: "The Coolest Collection".to_string(), - symbol: "COOL".to_string(), - uri: "https://cool.com".to_string(), - additional_metadata: vec![], - }; let collection_group_state = Group { update_authority: Some(collection_update_authority.pubkey()) .try_into() @@ -56,17 +46,7 @@ async fn test_update_collection_max_size() { Some(0), payer.clone(), ); - - setup_mint_and_metadata( - &token_client, - &collection_mint, - &collection_mint_authority, - &collection_metadata.pubkey(), - &collection_update_authority.pubkey(), - &collection_metadata_state, - payer, - ) - .await; + setup_mint(&token_client, &collection_mint, &collection_mint_authority).await; let mut context = context.lock().await; @@ -227,17 +207,8 @@ async fn test_update_collection_max_size_fail_immutable_group() { let collection = Keypair::new(); let collection_mint = Keypair::new(); let collection_mint_authority = Keypair::new(); - let collection_metadata = Keypair::new(); let collection_update_authority = Keypair::new(); - let collection_metadata_state = TokenMetadata { - update_authority: None.try_into().unwrap(), - mint: collection_mint.pubkey(), - name: "The Coolest Collection".to_string(), - symbol: "COOL".to_string(), - uri: "https://cool.com".to_string(), - additional_metadata: vec![], - }; let collection_group_state = Group { update_authority: Some(collection_update_authority.pubkey()) .try_into() @@ -255,17 +226,7 @@ async fn test_update_collection_max_size_fail_immutable_group() { Some(0), payer.clone(), ); - - setup_mint_and_metadata( - &token_client, - &collection_mint, - &collection_mint_authority, - &collection_metadata.pubkey(), - &collection_update_authority.pubkey(), - &collection_metadata_state, - payer, - ) - .await; + setup_mint(&token_client, &collection_mint, &collection_mint_authority).await; let mut context = context.lock().await; @@ -287,7 +248,7 @@ async fn test_update_collection_max_size_fail_immutable_group() { &collection.pubkey(), &collection_mint.pubkey(), &collection_mint_authority.pubkey(), - None.try_into().unwrap(), + None, collection_group_state.max_size.into(), ), ],