Skip to content

Commit

Permalink
token 2022: add support for additional signers in test init functions
Browse files Browse the repository at this point in the history
  • Loading branch information
buffalojoec committed Nov 14, 2023
1 parent 7fcf604 commit 65c5fbd
Show file tree
Hide file tree
Showing 29 changed files with 686 additions and 475 deletions.
38 changes: 22 additions & 16 deletions token/program-2022-test/tests/burn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,20 +87,23 @@ async fn run_basic(context: TestContext) {
#[tokio::test]
async fn basic() {
let mut context = TestContext::new().await;
context.init_token_with_mint(vec![]).await.unwrap();
context.init_token_with_mint(vec![], &[]).await.unwrap();
run_basic(context).await;
}

#[tokio::test]
async fn basic_with_extension() {
let mut context = TestContext::new().await;
context
.init_token_with_mint(vec![ExtensionInitializationParams::TransferFeeConfig {
transfer_fee_config_authority: Some(Pubkey::new_unique()),
withdraw_withheld_authority: Some(Pubkey::new_unique()),
transfer_fee_basis_points: 100u16,
maximum_fee: 1_000u64,
}])
.init_token_with_mint(
vec![ExtensionInitializationParams::TransferFeeConfig {
transfer_fee_config_authority: Some(Pubkey::new_unique()),
withdraw_withheld_authority: Some(Pubkey::new_unique()),
transfer_fee_basis_points: 100u16,
maximum_fee: 1_000u64,
}],
&[],
)
.await
.unwrap();
run_basic(context).await;
Expand Down Expand Up @@ -149,20 +152,23 @@ async fn run_self_owned(context: TestContext) {
#[tokio::test]
async fn self_owned() {
let mut context = TestContext::new().await;
context.init_token_with_mint(vec![]).await.unwrap();
context.init_token_with_mint(vec![], &[]).await.unwrap();
run_self_owned(context).await;
}

#[tokio::test]
async fn self_owned_with_extension() {
let mut context = TestContext::new().await;
context
.init_token_with_mint(vec![ExtensionInitializationParams::TransferFeeConfig {
transfer_fee_config_authority: Some(Pubkey::new_unique()),
withdraw_withheld_authority: Some(Pubkey::new_unique()),
transfer_fee_basis_points: 100u16,
maximum_fee: 1_000u64,
}])
.init_token_with_mint(
vec![ExtensionInitializationParams::TransferFeeConfig {
transfer_fee_config_authority: Some(Pubkey::new_unique()),
withdraw_withheld_authority: Some(Pubkey::new_unique()),
transfer_fee_basis_points: 100u16,
maximum_fee: 1_000u64,
}],
&[],
)
.await
.unwrap();
run_self_owned(context).await;
Expand Down Expand Up @@ -288,13 +294,13 @@ async fn run_burn_and_close_system_or_incinerator(context: TestContext, non_owne
#[tokio::test]
async fn burn_and_close_incinerator_tokens() {
let mut context = TestContext::new().await;
context.init_token_with_mint(vec![]).await.unwrap();
context.init_token_with_mint(vec![], &[]).await.unwrap();
run_burn_and_close_system_or_incinerator(context, &solana_program::incinerator::id()).await;
}

#[tokio::test]
async fn burn_and_close_system_tokens() {
let mut context = TestContext::new().await;
context.init_token_with_mint(vec![]).await.unwrap();
context.init_token_with_mint(vec![], &[]).await.unwrap();
run_burn_and_close_system_or_incinerator(context, &solana_program::system_program::id()).await;
}
13 changes: 8 additions & 5 deletions token/program-2022-test/tests/close_account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use {
async fn success_init_after_close_account() {
let mut context = TestContext::new().await;
let payer = Keypair::from_bytes(&context.context.lock().await.payer.to_bytes()).unwrap();
context.init_token_with_mint(vec![]).await.unwrap();
context.init_token_with_mint(vec![], &[]).await.unwrap();
let token = context.token_context.take().unwrap().token;
let token_program_id = spl_token_2022::id();
let owner = Keypair::new();
Expand Down Expand Up @@ -67,7 +67,7 @@ async fn success_init_after_close_account() {
async fn fail_init_after_close_account() {
let mut context = TestContext::new().await;
let payer = Keypair::from_bytes(&context.context.lock().await.payer.to_bytes()).unwrap();
context.init_token_with_mint(vec![]).await.unwrap();
context.init_token_with_mint(vec![], &[]).await.unwrap();
let token = context.token_context.take().unwrap().token;
let token_program_id = spl_token_2022::id();
let owner = Keypair::new();
Expand Down Expand Up @@ -119,9 +119,12 @@ async fn fail_init_after_close_mint() {
let mut context = TestContext::new().await;
let payer = Keypair::from_bytes(&context.context.lock().await.payer.to_bytes()).unwrap();
context
.init_token_with_mint(vec![ExtensionInitializationParams::MintCloseAuthority {
close_authority: Some(close_authority.pubkey()),
}])
.init_token_with_mint(
vec![ExtensionInitializationParams::MintCloseAuthority {
close_authority: Some(close_authority.pubkey()),
}],
&[],
)
.await
.unwrap();
let token = context.token_context.take().unwrap().token;
Expand Down
Loading

0 comments on commit 65c5fbd

Please sign in to comment.