Skip to content

Commit 7889290

Browse files
committed
cleanup
1 parent c5d0080 commit 7889290

11 files changed

Lines changed: 164 additions & 169 deletions

File tree

program-tests/compressed-token-test/tests/mint/edge_cases.rs

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ use light_program_test::{LightProgramTest, ProgramTestConfig};
1212
use light_test_utils::{
1313
assert_mint_action::assert_mint_action, mint_assert::assert_compressed_mint_account, Rpc,
1414
};
15-
use light_token_client::actions::create_mint;
15+
use light_token_client::{
16+
actions::create_mint,
17+
instructions::mint_action::{MintActionType, MintToRecipient},
18+
};
1619
use serial_test::serial;
1720
use solana_sdk::{signature::Keypair, signer::Signer};
1821

@@ -169,65 +172,66 @@ async fn functional_all_in_one_instruction() {
169172
// Build all actions for a single instruction
170173
let actions = vec![
171174
// 1. MintToCompressed - mint to compressed account
172-
light_compressed_token_sdk::instructions::mint_action::MintActionType::MintTo {
173-
recipients: vec![light_compressed_token_sdk::instructions::mint_action::MintToRecipient {
175+
MintActionType::MintTo {
176+
recipients: vec![MintToRecipient {
174177
recipient: Keypair::new().pubkey(),
175178
amount: 1000u64,
176179
}],
177180
token_account_version: 2,
178181
},
179182
// 2. MintToCToken - mint to decompressed account
180-
light_compressed_token_sdk::instructions::mint_action::MintActionType::MintToCToken {
183+
MintActionType::MintToCToken {
181184
account: light_compressed_token_sdk::instructions::derive_ctoken_ata(
182185
&recipient.pubkey(),
183186
&spl_mint_pda,
184-
).0,
187+
)
188+
.0,
185189
amount: 2000u64,
186190
},
187191
// 3. UpdateMintAuthority
188-
light_compressed_token_sdk::instructions::mint_action::MintActionType::UpdateMintAuthority {
192+
MintActionType::UpdateMintAuthority {
189193
new_authority: Some(new_mint_authority.pubkey()),
190194
},
191195
// 4. UpdateFreezeAuthority
192-
light_compressed_token_sdk::instructions::mint_action::MintActionType::UpdateFreezeAuthority {
196+
MintActionType::UpdateFreezeAuthority {
193197
new_authority: Some(new_freeze_authority.pubkey()),
194198
},
195199
// 5. UpdateMetadataField - update the name
196-
light_compressed_token_sdk::instructions::mint_action::MintActionType::UpdateMetadataField {
200+
MintActionType::UpdateMetadataField {
197201
extension_index: 0,
198202
field_type: 0, // Name field
199203
key: vec![],
200204
value: "Updated Token Name".as_bytes().to_vec(),
201205
},
202206
// 6. UpdateMetadataField - update the symbol
203-
light_compressed_token_sdk::instructions::mint_action::MintActionType::UpdateMetadataField {
207+
MintActionType::UpdateMetadataField {
204208
extension_index: 0,
205209
field_type: 1, // Symbol field
206210
key: vec![],
207211
value: "UPDATED".as_bytes().to_vec(),
208212
},
209213
// 7. UpdateMetadataField - update the URI
210-
light_compressed_token_sdk::instructions::mint_action::MintActionType::UpdateMetadataField {
214+
MintActionType::UpdateMetadataField {
211215
extension_index: 0,
212216
field_type: 2, // URI field
213217
key: vec![],
214218
value: "https://updated.example.com/token.json".as_bytes().to_vec(),
215219
},
216220
// 8. UpdateMetadataField - update the first additional metadata field
217-
light_compressed_token_sdk::instructions::mint_action::MintActionType::UpdateMetadataField {
221+
MintActionType::UpdateMetadataField {
218222
extension_index: 0,
219223
field_type: 3, // Custom key field
220224
key: vec![1, 2, 3, 4],
221225
value: "updated_value".as_bytes().to_vec(),
222226
},
223227
// 9. RemoveMetadataKey - remove the second additional metadata key
224-
light_compressed_token_sdk::instructions::mint_action::MintActionType::RemoveMetadataKey {
228+
MintActionType::RemoveMetadataKey {
225229
extension_index: 0,
226230
key: vec![4, 5, 6, 7],
227231
idempotent: 0,
228232
},
229233
// 10. UpdateMetadataAuthority
230-
light_compressed_token_sdk::instructions::mint_action::MintActionType::UpdateMetadataAuthority {
234+
MintActionType::UpdateMetadataAuthority {
231235
extension_index: 0,
232236
new_authority: new_metadata_authority.pubkey(),
233237
},

program-tests/compressed-token-test/tests/mint/failing.rs

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ use light_program_test::{utils::assert::assert_rpc_error, LightProgramTest, Prog
1010
use light_test_utils::{
1111
assert_mint_action::assert_mint_action, mint_assert::assert_compressed_mint_account, Rpc,
1212
};
13-
use light_token_client::actions::create_mint;
13+
use light_token_client::{
14+
actions::create_mint,
15+
instructions::mint_action::{MintActionType, MintToRecipient},
16+
};
1417
use serial_test::serial;
1518
use solana_sdk::{
1619
instruction::AccountMeta, signature::Keypair, signer::Signer, transaction::Transaction,
@@ -234,17 +237,13 @@ async fn functional_and_failing_tests() {
234237
&mut rpc,
235238
compressed_mint_address,
236239
pre_compressed_mint,
237-
vec![
238-
light_compressed_token_sdk::instructions::mint_action::MintActionType::MintTo {
239-
recipients: vec![
240-
light_compressed_token_sdk::instructions::mint_action::MintToRecipient {
241-
recipient,
242-
amount: 1000u64,
243-
},
244-
],
245-
token_account_version: light_ctoken_types::state::TokenDataVersion::V2 as u8,
246-
},
247-
],
240+
vec![MintActionType::MintTo {
241+
recipients: vec![MintToRecipient {
242+
recipient,
243+
amount: 1000u64,
244+
}],
245+
token_account_version: light_ctoken_types::state::TokenDataVersion::V2 as u8,
246+
}],
248247
)
249248
.await;
250249
}
@@ -312,7 +311,7 @@ async fn functional_and_failing_tests() {
312311
&mut rpc,
313312
compressed_mint_address,
314313
pre_compressed_mint,
315-
vec![light_compressed_token_sdk::instructions::mint_action::MintActionType::UpdateMintAuthority {
314+
vec![MintActionType::UpdateMintAuthority {
316315
new_authority: Some(new_mint_authority.pubkey()),
317316
}],
318317
)
@@ -385,7 +384,7 @@ async fn functional_and_failing_tests() {
385384
&mut rpc,
386385
compressed_mint_address,
387386
pre_compressed_mint,
388-
vec![light_compressed_token_sdk::instructions::mint_action::MintActionType::UpdateFreezeAuthority {
387+
vec![MintActionType::UpdateFreezeAuthority {
389388
new_authority: Some(new_freeze_authority.pubkey()),
390389
}],
391390
)
@@ -498,7 +497,7 @@ async fn functional_and_failing_tests() {
498497
&mut rpc,
499498
compressed_mint_address,
500499
pre_compressed_mint,
501-
vec![light_compressed_token_sdk::instructions::mint_action::MintActionType::MintToCToken {
500+
vec![MintActionType::MintToCToken {
502501
account: recipient_ata,
503502
amount: 2000u64,
504503
}],
@@ -515,7 +514,7 @@ async fn functional_and_failing_tests() {
515514
mint_seed: mint_seed.pubkey(),
516515
authority: invalid_metadata_authority.pubkey(), // Invalid authority
517516
payer: payer.pubkey(),
518-
actions: vec![light_compressed_token_sdk::instructions::mint_action::MintActionType::UpdateMetadataField {
517+
actions: vec![MintActionType::UpdateMetadataField {
519518
extension_index: 0,
520519
field_type: 0, // 0 = Name field
521520
key: vec![], // Empty for Name field
@@ -551,7 +550,7 @@ async fn functional_and_failing_tests() {
551550
)
552551
.unwrap();
553552

554-
let actions = vec![light_compressed_token_sdk::instructions::mint_action::MintActionType::UpdateMetadataField {
553+
let actions = vec![MintActionType::UpdateMetadataField {
555554
extension_index: 0,
556555
field_type: 0, // 0 = Name field
557556
key: vec![], // Empty for Name field
@@ -598,7 +597,7 @@ async fn functional_and_failing_tests() {
598597
mint_seed: mint_seed.pubkey(),
599598
authority: invalid_metadata_authority.pubkey(), // Invalid authority
600599
payer: payer.pubkey(),
601-
actions: vec![light_compressed_token_sdk::instructions::mint_action::MintActionType::UpdateMetadataAuthority {
600+
actions: vec![MintActionType::UpdateMetadataAuthority {
602601
extension_index: 0,
603602
new_authority: Keypair::new().pubkey(),
604603
}],
@@ -632,7 +631,7 @@ async fn functional_and_failing_tests() {
632631
)
633632
.unwrap();
634633

635-
let actions = vec![light_compressed_token_sdk::instructions::mint_action::MintActionType::UpdateMetadataAuthority {
634+
let actions = vec![MintActionType::UpdateMetadataAuthority {
636635
extension_index: 0,
637636
new_authority: new_metadata_authority.pubkey(),
638637
}];
@@ -677,10 +676,10 @@ async fn functional_and_failing_tests() {
677676
mint_seed: mint_seed.pubkey(),
678677
authority: invalid_metadata_authority.pubkey(), // Invalid authority
679678
payer: payer.pubkey(),
680-
actions: vec![light_compressed_token_sdk::instructions::mint_action::MintActionType::RemoveMetadataKey {
679+
actions: vec![MintActionType::RemoveMetadataKey {
681680
extension_index: 0,
682-
key: vec![1,2,3,4], // The key we added in additional_metadata
683-
idempotent: 0, // 0 = false
681+
key: vec![1, 2, 3, 4], // The key we added in additional_metadata
682+
idempotent: 0, // 0 = false
684683
}],
685684
new_mint: None,
686685
},
@@ -712,10 +711,10 @@ async fn functional_and_failing_tests() {
712711
)
713712
.unwrap();
714713

715-
let actions = vec![light_compressed_token_sdk::instructions::mint_action::MintActionType::RemoveMetadataKey {
714+
let actions = vec![MintActionType::RemoveMetadataKey {
716715
extension_index: 0,
717-
key: vec![1,2,3,4], // The key we added in additional_metadata
718-
idempotent: 0, // 0 = false
716+
key: vec![1, 2, 3, 4], // The key we added in additional_metadata
717+
idempotent: 0, // 0 = false
719718
}];
720719

721720
let result = light_token_client::actions::mint_action(
@@ -765,10 +764,10 @@ async fn functional_and_failing_tests() {
765764
)
766765
.unwrap();
767766

768-
let actions = vec![light_compressed_token_sdk::instructions::mint_action::MintActionType::RemoveMetadataKey {
767+
let actions = vec![MintActionType::RemoveMetadataKey {
769768
extension_index: 0,
770-
key: vec![1,2,3,4], // Same key, already removed
771-
idempotent: 1, // 1 = true (won't error if key doesn't exist)
769+
key: vec![1, 2, 3, 4], // Same key, already removed
770+
idempotent: 1, // 1 = true (won't error if key doesn't exist)
772771
}];
773772

774773
let result = light_token_client::actions::mint_action(

0 commit comments

Comments
 (0)