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

Commit 773d3a3

Browse files
committed
cut metadata
1 parent fc35055 commit 773d3a3

File tree

5 files changed

+25
-142
lines changed

5 files changed

+25
-142
lines changed

token-group/example/tests/initialize_collection.rs

+2-23
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
mod setup;
44

55
use {
6-
setup::{setup_mint_and_metadata, setup_program_test},
6+
setup::{setup_mint, setup_program_test},
77
solana_program::{instruction::InstructionError, pubkey::Pubkey, system_instruction},
88
solana_program_test::tokio,
99
solana_sdk::{
@@ -13,7 +13,6 @@ use {
1313
},
1414
spl_token_client::token::Token,
1515
spl_token_group_interface::{instruction::initialize_group, state::Group},
16-
spl_token_metadata_interface::state::TokenMetadata,
1716
spl_type_length_value::{
1817
error::TlvError,
1918
state::{TlvState, TlvStateBorrowed},
@@ -26,17 +25,7 @@ async fn test_initialize_collection() {
2625
let collection = Keypair::new();
2726
let collection_mint = Keypair::new();
2827
let collection_mint_authority = Keypair::new();
29-
let collection_metadata = Keypair::new();
30-
let collection_metadata_update_authority = Keypair::new();
3128

32-
let collection_metadata_state = TokenMetadata {
33-
update_authority: None.try_into().unwrap(),
34-
mint: collection_mint.pubkey(),
35-
name: "The Coolest Collection".to_string(),
36-
symbol: "COOL".to_string(),
37-
uri: "https://cool.com".to_string(),
38-
additional_metadata: vec![],
39-
};
4029
let collection_group_state = Group {
4130
update_authority: None.try_into().unwrap(),
4231
size: 0.into(),
@@ -52,17 +41,7 @@ async fn test_initialize_collection() {
5241
Some(0),
5342
payer.clone(),
5443
);
55-
56-
setup_mint_and_metadata(
57-
&token_client,
58-
&collection_mint,
59-
&collection_mint_authority,
60-
&collection_metadata.pubkey(),
61-
&collection_metadata_update_authority.pubkey(),
62-
&collection_metadata_state,
63-
payer,
64-
)
65-
.await;
44+
setup_mint(&token_client, &collection_mint, &collection_mint_authority).await;
6645

6746
let mut context = context.lock().await;
6847

token-group/example/tests/initialize_collection_member.rs

+13-30
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
mod setup;
44

55
use {
6-
setup::{setup_mint_and_metadata, setup_program_test},
6+
setup::{setup_mint, setup_program_test},
77
solana_program::{instruction::InstructionError, pubkey::Pubkey, system_instruction},
88
solana_program_test::tokio,
99
solana_sdk::{
@@ -16,7 +16,6 @@ use {
1616
instruction::{initialize_group, initialize_member},
1717
state::{Group, Member},
1818
},
19-
spl_token_metadata_interface::state::TokenMetadata,
2019
spl_type_length_value::state::{TlvState, TlvStateBorrowed},
2120
};
2221

@@ -26,20 +25,11 @@ async fn test_initialize_collection_member() {
2625
let collection = Keypair::new();
2726
let collection_mint = Keypair::new();
2827
let collection_mint_authority = Keypair::new();
29-
let collection_metadata = Keypair::new();
3028
let collection_update_authority = Keypair::new();
3129
let member = Keypair::new();
3230
let member_mint = Keypair::new();
3331
let member_mint_authority = Keypair::new();
3432

35-
let collection_metadata_state = TokenMetadata {
36-
update_authority: None.try_into().unwrap(),
37-
mint: collection_mint.pubkey(),
38-
name: "The Coolest Collection".to_string(),
39-
symbol: "COOL".to_string(),
40-
uri: "https://cool.com".to_string(),
41-
additional_metadata: vec![],
42-
};
4333
let collection_group_state = Group {
4434
update_authority: Some(collection_update_authority.pubkey())
4535
.try_into()
@@ -50,7 +40,7 @@ async fn test_initialize_collection_member() {
5040

5141
let (context, client, payer) = setup_program_test(&program_id).await;
5242

53-
setup_mint_and_metadata(
43+
setup_mint(
5444
&Token::new(
5545
client.clone(),
5646
&spl_token_2022::id(),
@@ -60,27 +50,20 @@ async fn test_initialize_collection_member() {
6050
),
6151
&collection_mint,
6252
&collection_mint_authority,
63-
&collection_metadata.pubkey(),
64-
&collection_update_authority.pubkey(),
65-
&collection_metadata_state,
66-
payer.clone(),
6753
)
6854
.await;
69-
Token::new(
70-
client,
71-
&spl_token_2022::id(),
72-
&member_mint.pubkey(),
73-
Some(0),
74-
payer.clone(),
75-
)
76-
.create_mint(
77-
&member_mint_authority.pubkey(),
78-
None,
79-
vec![],
80-
&[&member_mint],
55+
setup_mint(
56+
&Token::new(
57+
client.clone(),
58+
&spl_token_2022::id(),
59+
&member_mint.pubkey(),
60+
Some(0),
61+
payer.clone(),
62+
),
63+
&member_mint,
64+
&member_mint_authority,
8165
)
82-
.await
83-
.unwrap();
66+
.await;
8467

8568
let mut context = context.lock().await;
8669

token-group/example/tests/setup.rs

+4-24
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@ use {
88
ProgramBanksClient, ProgramBanksClientProcessTransaction, ProgramClient,
99
SendTransaction, SimulateTransaction,
1010
},
11-
token::{ExtensionInitializationParams, Token},
11+
token::Token,
1212
},
13-
spl_token_metadata_interface::state::TokenMetadata,
1413
std::sync::Arc,
1514
};
1615

@@ -44,38 +43,19 @@ pub async fn setup_program_test(
4443
(context, client, payer)
4544
}
4645

47-
/// Set up a Token-2022 mint and metadata
48-
pub async fn setup_mint_and_metadata<T: SendTransaction + SimulateTransaction>(
46+
/// Set up a Token-2022 mint
47+
pub async fn setup_mint<T: SendTransaction + SimulateTransaction>(
4948
token_client: &Token<T>,
5049
mint_keypair: &Keypair,
5150
mint_authority_keypair: &Keypair,
52-
metadata_pubkey: &Pubkey,
53-
metadata_update_authority_pubkey: &Pubkey,
54-
token_metadata: &TokenMetadata,
55-
payer: Arc<Keypair>,
5651
) {
5752
token_client
5853
.create_mint(
5954
&mint_authority_keypair.pubkey(),
6055
None,
61-
vec![ExtensionInitializationParams::MetadataPointer {
62-
authority: Some(*metadata_update_authority_pubkey),
63-
metadata_address: Some(*metadata_pubkey),
64-
}],
56+
vec![],
6557
&[mint_keypair],
6658
)
6759
.await
6860
.unwrap();
69-
token_client
70-
.token_metadata_initialize_with_rent_transfer(
71-
&payer.pubkey(),
72-
metadata_update_authority_pubkey,
73-
&mint_authority_keypair.pubkey(),
74-
token_metadata.name.clone(),
75-
token_metadata.symbol.clone(),
76-
token_metadata.uri.clone(),
77-
&[&payer, mint_authority_keypair],
78-
)
79-
.await
80-
.unwrap();
8161
}

token-group/example/tests/update_collection_authority.rs

+2-22
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
mod setup;
44

55
use {
6-
setup::{setup_mint_and_metadata, setup_program_test},
6+
setup::{setup_mint, setup_program_test},
77
solana_program::{instruction::InstructionError, pubkey::Pubkey, system_instruction},
88
solana_program_test::tokio,
99
solana_sdk::{
@@ -17,7 +17,6 @@ use {
1717
instruction::{initialize_group, update_group_authority},
1818
state::Group,
1919
},
20-
spl_token_metadata_interface::state::TokenMetadata,
2120
spl_type_length_value::state::{TlvState, TlvStateBorrowed},
2221
};
2322

@@ -27,17 +26,8 @@ async fn test_update_collection_authority() {
2726
let collection = Keypair::new();
2827
let collection_mint = Keypair::new();
2928
let collection_mint_authority = Keypair::new();
30-
let collection_metadata = Keypair::new();
3129
let collection_update_authority = Keypair::new();
3230

33-
let collection_metadata_state = TokenMetadata {
34-
update_authority: None.try_into().unwrap(),
35-
mint: collection_mint.pubkey(),
36-
name: "The Coolest Collection".to_string(),
37-
symbol: "COOL".to_string(),
38-
uri: "https://cool.com".to_string(),
39-
additional_metadata: vec![],
40-
};
4131
let collection_group_state = Group {
4232
update_authority: Some(collection_update_authority.pubkey())
4333
.try_into()
@@ -55,17 +45,7 @@ async fn test_update_collection_authority() {
5545
Some(0),
5646
payer.clone(),
5747
);
58-
59-
setup_mint_and_metadata(
60-
&token_client,
61-
&collection_mint,
62-
&collection_mint_authority,
63-
&collection_metadata.pubkey(),
64-
&collection_update_authority.pubkey(),
65-
&collection_metadata_state,
66-
payer,
67-
)
68-
.await;
48+
setup_mint(&token_client, &collection_mint, &collection_mint_authority).await;
6949

7050
let mut context = context.lock().await;
7151

token-group/example/tests/update_collection_max_size.rs

+4-43
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
mod setup;
44

55
use {
6-
setup::{setup_mint_and_metadata, setup_program_test},
6+
setup::{setup_mint, setup_program_test},
77
solana_program::{instruction::InstructionError, pubkey::Pubkey, system_instruction},
88
solana_program_test::tokio,
99
solana_sdk::{
@@ -18,7 +18,6 @@ use {
1818
instruction::{initialize_group, update_group_max_size},
1919
state::Group,
2020
},
21-
spl_token_metadata_interface::state::TokenMetadata,
2221
spl_type_length_value::state::{TlvState, TlvStateBorrowed, TlvStateMut},
2322
};
2423

@@ -28,17 +27,8 @@ async fn test_update_collection_max_size() {
2827
let collection = Keypair::new();
2928
let collection_mint = Keypair::new();
3029
let collection_mint_authority = Keypair::new();
31-
let collection_metadata = Keypair::new();
3230
let collection_update_authority = Keypair::new();
3331

34-
let collection_metadata_state = TokenMetadata {
35-
update_authority: None.try_into().unwrap(),
36-
mint: collection_mint.pubkey(),
37-
name: "The Coolest Collection".to_string(),
38-
symbol: "COOL".to_string(),
39-
uri: "https://cool.com".to_string(),
40-
additional_metadata: vec![],
41-
};
4232
let collection_group_state = Group {
4333
update_authority: Some(collection_update_authority.pubkey())
4434
.try_into()
@@ -56,17 +46,7 @@ async fn test_update_collection_max_size() {
5646
Some(0),
5747
payer.clone(),
5848
);
59-
60-
setup_mint_and_metadata(
61-
&token_client,
62-
&collection_mint,
63-
&collection_mint_authority,
64-
&collection_metadata.pubkey(),
65-
&collection_update_authority.pubkey(),
66-
&collection_metadata_state,
67-
payer,
68-
)
69-
.await;
49+
setup_mint(&token_client, &collection_mint, &collection_mint_authority).await;
7050

7151
let mut context = context.lock().await;
7252

@@ -227,17 +207,8 @@ async fn test_update_collection_max_size_fail_immutable_group() {
227207
let collection = Keypair::new();
228208
let collection_mint = Keypair::new();
229209
let collection_mint_authority = Keypair::new();
230-
let collection_metadata = Keypair::new();
231210
let collection_update_authority = Keypair::new();
232211

233-
let collection_metadata_state = TokenMetadata {
234-
update_authority: None.try_into().unwrap(),
235-
mint: collection_mint.pubkey(),
236-
name: "The Coolest Collection".to_string(),
237-
symbol: "COOL".to_string(),
238-
uri: "https://cool.com".to_string(),
239-
additional_metadata: vec![],
240-
};
241212
let collection_group_state = Group {
242213
update_authority: Some(collection_update_authority.pubkey())
243214
.try_into()
@@ -255,17 +226,7 @@ async fn test_update_collection_max_size_fail_immutable_group() {
255226
Some(0),
256227
payer.clone(),
257228
);
258-
259-
setup_mint_and_metadata(
260-
&token_client,
261-
&collection_mint,
262-
&collection_mint_authority,
263-
&collection_metadata.pubkey(),
264-
&collection_update_authority.pubkey(),
265-
&collection_metadata_state,
266-
payer,
267-
)
268-
.await;
229+
setup_mint(&token_client, &collection_mint, &collection_mint_authority).await;
269230

270231
let mut context = context.lock().await;
271232

@@ -287,7 +248,7 @@ async fn test_update_collection_max_size_fail_immutable_group() {
287248
&collection.pubkey(),
288249
&collection_mint.pubkey(),
289250
&collection_mint_authority.pubkey(),
290-
None.try_into().unwrap(),
251+
None,
291252
collection_group_state.max_size.into(),
292253
),
293254
],

0 commit comments

Comments
 (0)