Skip to content

Commit

Permalink
Adding back ignores and fixing tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
blockiosaurus committed Oct 30, 2024
1 parent 9162da0 commit 94fe436
Showing 1 changed file with 79 additions and 2 deletions.
81 changes: 79 additions & 2 deletions programs/token-metadata/program/tests/resize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ mod resize {
]
)]
#[tokio::test]
// #[ignore]
#[ignore]
// Used for local QA testing and requires a keypair so excluded from CI.
async fn resize_with_resize_authority(
spl_token_program: Pubkey,
Expand Down Expand Up @@ -444,7 +444,7 @@ mod resize {
]
)]
#[tokio::test]
// #[ignore]
#[ignore]
// Used for local QA testing and requires a keypair so excluded from CI.
async fn cannot_resize_with_resize_authority_and_wrong_destination(
spl_token_program: Pubkey,
Expand Down Expand Up @@ -915,4 +915,81 @@ mod resize {

assert_custom_error!(result, MetadataError::InvalidOwner);
}

#[test_case::test_matrix(
[spl_token::id(), spl_token_2022::id()],
[
TokenStandard::Fungible,
TokenStandard::FungibleAsset,
]
)]
#[tokio::test]
async fn cannot_resize_fungible_as_update_authority(
spl_token_program: Pubkey,
token_standard: TokenStandard,
) {
// Create NFTs and then collect the fees from the metadata accounts.
let mut context = program_test().start_with_context().await;
let mut fungible = DigitalAsset::new();
fungible
.create_and_mint(
&mut context,
token_standard,
None,
None,
1,
spl_token_program,
)
.await
.unwrap();

let context_payer = Keypair::from_bytes(&context.payer.to_bytes()).unwrap();
let update_authority = Keypair::new();
context.warp_to_slot(10).unwrap();

fungible
.update(
&mut context,
context_payer,
UpdateArgs::V1 {
new_update_authority: Some(update_authority.pubkey()),
data: None,
primary_sale_happened: None,
is_mutable: None,
collection: CollectionToggle::None,
collection_details: CollectionDetailsToggle::None,
uses: UsesToggle::None,
rule_set: RuleSetToggle::None,
authorization_data: None,
},
)
.await
.unwrap();

let tx = Transaction::new_signed_with_payer(
&[ResizeBuilder::new()
.metadata(fungible.metadata)
.edition(find_master_edition_account(&fungible.mint.pubkey()).0)
.mint(fungible.mint.pubkey())
.payer(context.payer.pubkey())
.authority(update_authority.pubkey())
.token(fungible.token.unwrap())
.system_program(solana_program::system_program::ID)
.build()
.unwrap()
.instruction()],
Some(&context.payer.pubkey()),
&[&context.payer, &update_authority],
context.last_blockhash,
);

assert_before_metadata(&mut context, fungible.metadata).await;
let result = context
.banks_client
.process_transaction(tx)
.await
.unwrap_err();

assert_custom_error!(result, MetadataError::UpdateAuthorityIncorrect);
}
}

0 comments on commit 94fe436

Please sign in to comment.