From 65c5fbdadf8f9c36bb6b0de5bfa2d2c96e2918dc Mon Sep 17 00:00:00 2001 From: Joe Date: Tue, 14 Nov 2023 13:13:29 +0000 Subject: [PATCH] token 2022: add support for additional signers in test init functions --- token/program-2022-test/tests/burn.rs | 38 ++- .../program-2022-test/tests/close_account.rs | 13 +- .../tests/confidential_transfer.rs | 274 ++++++++-------- .../tests/confidential_transfer_fee.rs | 300 ++++++++++-------- token/program-2022-test/tests/cpi_guard.rs | 5 +- .../tests/default_account_state.rs | 54 ++-- token/program-2022-test/tests/delegate.rs | 51 +-- token/program-2022-test/tests/freeze.rs | 5 +- .../program-2022-test/tests/group_pointer.rs | 2 + .../tests/initialize_mint.rs | 9 +- .../tests/interest_bearing_mint.rs | 44 ++- .../program-2022-test/tests/memo_transfer.rs | 4 +- .../tests/metadata_pointer.rs | 2 + .../tests/mint_close_authority.rs | 36 ++- .../tests/non_transferable.rs | 23 +- .../tests/permanent_delegate.rs | 36 ++- token/program-2022-test/tests/program_test.rs | 19 +- token/program-2022-test/tests/reallocate.rs | 21 +- .../tests/token_group_initialize.rs | 4 +- .../tests/token_group_update_authority.rs | 1 + .../tests/token_group_update_max_size.rs | 1 + .../tests/token_metadata_emit.rs | 1 + .../tests/token_metadata_initialize.rs | 4 +- .../tests/token_metadata_remove_key.rs | 1 + .../tests/token_metadata_update_authority.rs | 1 + .../tests/token_metadata_update_field.rs | 1 + token/program-2022-test/tests/transfer.rs | 53 ++-- token/program-2022-test/tests/transfer_fee.rs | 152 +++++---- .../program-2022-test/tests/transfer_hook.rs | 6 + 29 files changed, 686 insertions(+), 475 deletions(-) diff --git a/token/program-2022-test/tests/burn.rs b/token/program-2022-test/tests/burn.rs index df4ab148b2b..cd26b727aa2 100644 --- a/token/program-2022-test/tests/burn.rs +++ b/token/program-2022-test/tests/burn.rs @@ -87,7 +87,7 @@ 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; } @@ -95,12 +95,15 @@ async fn basic() { 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; @@ -149,7 +152,7 @@ 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; } @@ -157,12 +160,15 @@ async fn self_owned() { 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; @@ -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; } diff --git a/token/program-2022-test/tests/close_account.rs b/token/program-2022-test/tests/close_account.rs index d070b9d1134..bb747670d63 100644 --- a/token/program-2022-test/tests/close_account.rs +++ b/token/program-2022-test/tests/close_account.rs @@ -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(); @@ -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(); @@ -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; diff --git a/token/program-2022-test/tests/confidential_transfer.rs b/token/program-2022-test/tests/confidential_transfer.rs index a41d4893c69..e64ce7d7878 100644 --- a/token/program-2022-test/tests/confidential_transfer.rs +++ b/token/program-2022-test/tests/confidential_transfer.rs @@ -231,13 +231,14 @@ async fn confidential_transfer_configure_token_account() { let mut context = TestContext::new().await; context - .init_token_with_mint(vec![ - ExtensionInitializationParams::ConfidentialTransferMint { + .init_token_with_mint( + vec![ExtensionInitializationParams::ConfidentialTransferMint { authority: Some(authority.pubkey()), auto_approve_new_accounts, auditor_elgamal_pubkey: Some(auditor_elgamal_pubkey), - }, - ]) + }], + &[], + ) .await .unwrap(); @@ -315,13 +316,14 @@ async fn confidential_transfer_enable_disable_confidential_credits() { let mut context = TestContext::new().await; context - .init_token_with_mint(vec![ - ExtensionInitializationParams::ConfidentialTransferMint { + .init_token_with_mint( + vec![ExtensionInitializationParams::ConfidentialTransferMint { authority: Some(authority.pubkey()), auto_approve_new_accounts, auditor_elgamal_pubkey: Some(auditor_elgamal_pubkey), - }, - ]) + }], + &[], + ) .await .unwrap(); @@ -424,13 +426,14 @@ async fn confidential_transfer_enable_disable_non_confidential_credits() { let mut context = TestContext::new().await; context - .init_token_with_mint(vec![ - ExtensionInitializationParams::ConfidentialTransferMint { + .init_token_with_mint( + vec![ExtensionInitializationParams::ConfidentialTransferMint { authority: Some(authority.pubkey()), auto_approve_new_accounts, auditor_elgamal_pubkey: Some(auditor_elgamal_pubkey), - }, - ]) + }], + &[], + ) .await .unwrap(); @@ -533,13 +536,14 @@ async fn confidential_transfer_empty_account() { // newly created confidential transfer account should hold no balance and // therefore, immediately closable context - .init_token_with_mint(vec![ - ExtensionInitializationParams::ConfidentialTransferMint { + .init_token_with_mint( + vec![ExtensionInitializationParams::ConfidentialTransferMint { authority: Some(authority.pubkey()), auto_approve_new_accounts, auditor_elgamal_pubkey: Some(auditor_elgamal_pubkey), - }, - ]) + }], + &[], + ) .await .unwrap(); @@ -569,13 +573,14 @@ async fn confidential_transfer_deposit() { let mut context = TestContext::new().await; context - .init_token_with_mint(vec![ - ExtensionInitializationParams::ConfidentialTransferMint { + .init_token_with_mint( + vec![ExtensionInitializationParams::ConfidentialTransferMint { authority: Some(authority.pubkey()), auto_approve_new_accounts, auditor_elgamal_pubkey: Some(auditor_elgamal_pubkey), - }, - ]) + }], + &[], + ) .await .unwrap(); @@ -785,13 +790,14 @@ async fn confidential_transfer_withdraw() { let mut context = TestContext::new().await; context - .init_token_with_mint(vec![ - ExtensionInitializationParams::ConfidentialTransferMint { + .init_token_with_mint( + vec![ExtensionInitializationParams::ConfidentialTransferMint { authority: Some(authority.pubkey()), auto_approve_new_accounts, auditor_elgamal_pubkey: Some(auditor_elgamal_pubkey), - }, - ]) + }], + &[], + ) .await .unwrap(); @@ -933,13 +939,14 @@ async fn confidential_transfer_transfer() { let mut context = TestContext::new().await; context - .init_token_with_mint(vec![ - ExtensionInitializationParams::ConfidentialTransferMint { + .init_token_with_mint( + vec![ExtensionInitializationParams::ConfidentialTransferMint { authority: Some(authority.pubkey()), auto_approve_new_accounts, auditor_elgamal_pubkey: Some(auditor_elgamal_pubkey), - }, - ]) + }], + &[], + ) .await .unwrap(); @@ -1180,23 +1187,26 @@ async fn confidential_transfer_transfer_with_fee() { let mut context = TestContext::new().await; context - .init_token_with_mint(vec![ - ExtensionInitializationParams::TransferFeeConfig { - transfer_fee_config_authority: Some(transfer_fee_authority.pubkey()), - withdraw_withheld_authority: Some(withdraw_withheld_authority.pubkey()), - transfer_fee_basis_points: TEST_FEE_BASIS_POINTS, - maximum_fee: TEST_MAXIMUM_FEE, - }, - ExtensionInitializationParams::ConfidentialTransferMint { - authority: Some(confidential_transfer_authority.pubkey()), - auto_approve_new_accounts, - auditor_elgamal_pubkey: Some(auditor_elgamal_pubkey), - }, - ExtensionInitializationParams::ConfidentialTransferFeeConfig { - authority: Some(confidential_transfer_fee_authority.pubkey()), - withdraw_withheld_authority_elgamal_pubkey, - }, - ]) + .init_token_with_mint( + vec![ + ExtensionInitializationParams::TransferFeeConfig { + transfer_fee_config_authority: Some(transfer_fee_authority.pubkey()), + withdraw_withheld_authority: Some(withdraw_withheld_authority.pubkey()), + transfer_fee_basis_points: TEST_FEE_BASIS_POINTS, + maximum_fee: TEST_MAXIMUM_FEE, + }, + ExtensionInitializationParams::ConfidentialTransferMint { + authority: Some(confidential_transfer_authority.pubkey()), + auto_approve_new_accounts, + auditor_elgamal_pubkey: Some(auditor_elgamal_pubkey), + }, + ExtensionInitializationParams::ConfidentialTransferFeeConfig { + authority: Some(confidential_transfer_fee_authority.pubkey()), + withdraw_withheld_authority_elgamal_pubkey, + }, + ], + &[], + ) .await .unwrap(); @@ -1426,13 +1436,14 @@ async fn confidential_transfer_transfer_memo() { let mut context = TestContext::new().await; context - .init_token_with_mint(vec![ - ExtensionInitializationParams::ConfidentialTransferMint { + .init_token_with_mint( + vec![ExtensionInitializationParams::ConfidentialTransferMint { authority: Some(authority.pubkey()), auto_approve_new_accounts, auditor_elgamal_pubkey: Some(auditor_elgamal_pubkey), - }, - ]) + }], + &[], + ) .await .unwrap(); @@ -1549,23 +1560,26 @@ async fn confidential_transfer_transfer_with_fee_and_memo() { let mut context = TestContext::new().await; context - .init_token_with_mint(vec![ - ExtensionInitializationParams::TransferFeeConfig { - transfer_fee_config_authority: Some(transfer_fee_authority.pubkey()), - withdraw_withheld_authority: Some(withdraw_withheld_authority.pubkey()), - transfer_fee_basis_points: TEST_FEE_BASIS_POINTS, - maximum_fee: TEST_MAXIMUM_FEE, - }, - ExtensionInitializationParams::ConfidentialTransferMint { - authority: Some(confidential_transfer_authority.pubkey()), - auto_approve_new_accounts, - auditor_elgamal_pubkey: Some(auditor_elgamal_pubkey), - }, - ExtensionInitializationParams::ConfidentialTransferFeeConfig { - authority: Some(confidential_transfer_fee_authority.pubkey()), - withdraw_withheld_authority_elgamal_pubkey, - }, - ]) + .init_token_with_mint( + vec![ + ExtensionInitializationParams::TransferFeeConfig { + transfer_fee_config_authority: Some(transfer_fee_authority.pubkey()), + withdraw_withheld_authority: Some(withdraw_withheld_authority.pubkey()), + transfer_fee_basis_points: TEST_FEE_BASIS_POINTS, + maximum_fee: TEST_MAXIMUM_FEE, + }, + ExtensionInitializationParams::ConfidentialTransferMint { + authority: Some(confidential_transfer_authority.pubkey()), + auto_approve_new_accounts, + auditor_elgamal_pubkey: Some(auditor_elgamal_pubkey), + }, + ExtensionInitializationParams::ConfidentialTransferFeeConfig { + authority: Some(confidential_transfer_fee_authority.pubkey()), + withdraw_withheld_authority_elgamal_pubkey, + }, + ], + &[], + ) .await .unwrap(); @@ -1675,13 +1689,14 @@ async fn confidential_transfer_configure_token_account_with_proof_context() { let mut context = TestContext::new().await; context - .init_token_with_mint(vec![ - ExtensionInitializationParams::ConfidentialTransferMint { + .init_token_with_mint( + vec![ExtensionInitializationParams::ConfidentialTransferMint { authority: Some(authority.pubkey()), auto_approve_new_accounts, auditor_elgamal_pubkey: None, - }, - ]) + }], + &[], + ) .await .unwrap(); @@ -1858,13 +1873,14 @@ async fn confidential_transfer_empty_account_with_proof_context() { let mut context = TestContext::new().await; context - .init_token_with_mint(vec![ - ExtensionInitializationParams::ConfidentialTransferMint { + .init_token_with_mint( + vec![ExtensionInitializationParams::ConfidentialTransferMint { authority: Some(authority.pubkey()), auto_approve_new_accounts, auditor_elgamal_pubkey: None, - }, - ]) + }], + &[], + ) .await .unwrap(); @@ -1997,13 +2013,14 @@ async fn confidential_transfer_withdraw_with_proof_context() { let mut context = TestContext::new().await; context - .init_token_with_mint(vec![ - ExtensionInitializationParams::ConfidentialTransferMint { + .init_token_with_mint( + vec![ExtensionInitializationParams::ConfidentialTransferMint { authority: Some(authority.pubkey()), auto_approve_new_accounts, auditor_elgamal_pubkey: None, - }, - ]) + }], + &[], + ) .await .unwrap(); @@ -2171,13 +2188,14 @@ async fn confidential_transfer_transfer_with_proof_context() { let mut context = TestContext::new().await; context - .init_token_with_mint(vec![ - ExtensionInitializationParams::ConfidentialTransferMint { + .init_token_with_mint( + vec![ExtensionInitializationParams::ConfidentialTransferMint { authority: Some(authority.pubkey()), auto_approve_new_accounts, auditor_elgamal_pubkey: Some(auditor_elgamal_pubkey), - }, - ]) + }], + &[], + ) .await .unwrap(); @@ -2376,13 +2394,14 @@ async fn confidential_transfer_transfer_with_split_proof_context() { let mut context = TestContext::new().await; context - .init_token_with_mint(vec![ - ExtensionInitializationParams::ConfidentialTransferMint { + .init_token_with_mint( + vec![ExtensionInitializationParams::ConfidentialTransferMint { authority: Some(authority.pubkey()), auto_approve_new_accounts, auditor_elgamal_pubkey: Some(auditor_elgamal_pubkey), - }, - ]) + }], + &[], + ) .await .unwrap(); @@ -2562,13 +2581,14 @@ async fn confidential_transfer_transfer_with_split_proof_contexts_in_parallel() let mut context = TestContext::new().await; context - .init_token_with_mint(vec![ - ExtensionInitializationParams::ConfidentialTransferMint { + .init_token_with_mint( + vec![ExtensionInitializationParams::ConfidentialTransferMint { authority: Some(authority.pubkey()), auto_approve_new_accounts, auditor_elgamal_pubkey: Some(auditor_elgamal_pubkey), - }, - ]) + }], + &[], + ) .await .unwrap(); @@ -2685,23 +2705,26 @@ async fn confidential_transfer_transfer_with_fee_and_split_proof_context() { let mut context = TestContext::new().await; context - .init_token_with_mint(vec![ - ExtensionInitializationParams::TransferFeeConfig { - transfer_fee_config_authority: Some(transfer_fee_authority.pubkey()), - withdraw_withheld_authority: Some(withdraw_withheld_authority.pubkey()), - transfer_fee_basis_points: TEST_FEE_BASIS_POINTS, - maximum_fee: TEST_MAXIMUM_FEE, - }, - ExtensionInitializationParams::ConfidentialTransferMint { - authority: Some(confidential_transfer_authority.pubkey()), - auto_approve_new_accounts, - auditor_elgamal_pubkey: Some(auditor_elgamal_pubkey), - }, - ExtensionInitializationParams::ConfidentialTransferFeeConfig { - authority: Some(confidential_transfer_fee_authority.pubkey()), - withdraw_withheld_authority_elgamal_pubkey, - }, - ]) + .init_token_with_mint( + vec![ + ExtensionInitializationParams::TransferFeeConfig { + transfer_fee_config_authority: Some(transfer_fee_authority.pubkey()), + withdraw_withheld_authority: Some(withdraw_withheld_authority.pubkey()), + transfer_fee_basis_points: TEST_FEE_BASIS_POINTS, + maximum_fee: TEST_MAXIMUM_FEE, + }, + ExtensionInitializationParams::ConfidentialTransferMint { + authority: Some(confidential_transfer_authority.pubkey()), + auto_approve_new_accounts, + auditor_elgamal_pubkey: Some(auditor_elgamal_pubkey), + }, + ExtensionInitializationParams::ConfidentialTransferFeeConfig { + authority: Some(confidential_transfer_fee_authority.pubkey()), + withdraw_withheld_authority_elgamal_pubkey, + }, + ], + &[], + ) .await .unwrap(); @@ -2935,23 +2958,26 @@ async fn confidential_transfer_transfer_with_fee_and_split_proof_context_in_para let mut context = TestContext::new().await; context - .init_token_with_mint(vec![ - ExtensionInitializationParams::TransferFeeConfig { - transfer_fee_config_authority: Some(transfer_fee_authority.pubkey()), - withdraw_withheld_authority: Some(withdraw_withheld_authority.pubkey()), - transfer_fee_basis_points: TEST_FEE_BASIS_POINTS, - maximum_fee: TEST_MAXIMUM_FEE, - }, - ExtensionInitializationParams::ConfidentialTransferMint { - authority: Some(confidential_transfer_authority.pubkey()), - auto_approve_new_accounts, - auditor_elgamal_pubkey: Some(auditor_elgamal_pubkey), - }, - ExtensionInitializationParams::ConfidentialTransferFeeConfig { - authority: Some(confidential_transfer_fee_authority.pubkey()), - withdraw_withheld_authority_elgamal_pubkey, - }, - ]) + .init_token_with_mint( + vec![ + ExtensionInitializationParams::TransferFeeConfig { + transfer_fee_config_authority: Some(transfer_fee_authority.pubkey()), + withdraw_withheld_authority: Some(withdraw_withheld_authority.pubkey()), + transfer_fee_basis_points: TEST_FEE_BASIS_POINTS, + maximum_fee: TEST_MAXIMUM_FEE, + }, + ExtensionInitializationParams::ConfidentialTransferMint { + authority: Some(confidential_transfer_authority.pubkey()), + auto_approve_new_accounts, + auditor_elgamal_pubkey: Some(auditor_elgamal_pubkey), + }, + ExtensionInitializationParams::ConfidentialTransferFeeConfig { + authority: Some(confidential_transfer_fee_authority.pubkey()), + withdraw_withheld_authority_elgamal_pubkey, + }, + ], + &[], + ) .await .unwrap(); diff --git a/token/program-2022-test/tests/confidential_transfer_fee.rs b/token/program-2022-test/tests/confidential_transfer_fee.rs index f2eb4086eb7..27b3a56b8b0 100644 --- a/token/program-2022-test/tests/confidential_transfer_fee.rs +++ b/token/program-2022-test/tests/confidential_transfer_fee.rs @@ -222,19 +222,22 @@ async fn confidential_transfer_fee_config() { // Try invalid combinations of extensions let err = context - .init_token_with_mint(vec![ - ExtensionInitializationParams::TransferFeeConfig { - transfer_fee_config_authority: Some(transfer_fee_authority.pubkey()), - withdraw_withheld_authority: Some(withdraw_withheld_authority.pubkey()), - transfer_fee_basis_points: TEST_FEE_BASIS_POINTS, - maximum_fee: TEST_MAXIMUM_FEE, - }, - ExtensionInitializationParams::ConfidentialTransferMint { - authority: Some(confidential_transfer_authority.pubkey()), - auto_approve_new_accounts, - auditor_elgamal_pubkey: Some(auditor_elgamal_pubkey), - }, - ]) + .init_token_with_mint( + vec![ + ExtensionInitializationParams::TransferFeeConfig { + transfer_fee_config_authority: Some(transfer_fee_authority.pubkey()), + withdraw_withheld_authority: Some(withdraw_withheld_authority.pubkey()), + transfer_fee_basis_points: TEST_FEE_BASIS_POINTS, + maximum_fee: TEST_MAXIMUM_FEE, + }, + ExtensionInitializationParams::ConfidentialTransferMint { + authority: Some(confidential_transfer_authority.pubkey()), + auto_approve_new_accounts, + auditor_elgamal_pubkey: Some(auditor_elgamal_pubkey), + }, + ], + &[], + ) .await .unwrap_err(); @@ -249,17 +252,20 @@ async fn confidential_transfer_fee_config() { ); let err = context - .init_token_with_mint(vec![ - ExtensionInitializationParams::ConfidentialTransferMint { - authority: Some(confidential_transfer_authority.pubkey()), - auto_approve_new_accounts, - auditor_elgamal_pubkey: Some(auditor_elgamal_pubkey), - }, - ExtensionInitializationParams::ConfidentialTransferFeeConfig { - authority: Some(confidential_transfer_fee_authority.pubkey()), - withdraw_withheld_authority_elgamal_pubkey, - }, - ]) + .init_token_with_mint( + vec![ + ExtensionInitializationParams::ConfidentialTransferMint { + authority: Some(confidential_transfer_authority.pubkey()), + auto_approve_new_accounts, + auditor_elgamal_pubkey: Some(auditor_elgamal_pubkey), + }, + ExtensionInitializationParams::ConfidentialTransferFeeConfig { + authority: Some(confidential_transfer_fee_authority.pubkey()), + withdraw_withheld_authority_elgamal_pubkey, + }, + ], + &[], + ) .await .unwrap_err(); @@ -274,12 +280,15 @@ async fn confidential_transfer_fee_config() { ); let err = context - .init_token_with_mint(vec![ - ExtensionInitializationParams::ConfidentialTransferFeeConfig { - authority: Some(confidential_transfer_fee_authority.pubkey()), - withdraw_withheld_authority_elgamal_pubkey, - }, - ]) + .init_token_with_mint( + vec![ + ExtensionInitializationParams::ConfidentialTransferFeeConfig { + authority: Some(confidential_transfer_fee_authority.pubkey()), + withdraw_withheld_authority_elgamal_pubkey, + }, + ], + &[], + ) .await .unwrap_err(); @@ -294,23 +303,26 @@ async fn confidential_transfer_fee_config() { ); context - .init_token_with_mint(vec![ - ExtensionInitializationParams::TransferFeeConfig { - transfer_fee_config_authority: Some(transfer_fee_authority.pubkey()), - withdraw_withheld_authority: Some(withdraw_withheld_authority.pubkey()), - transfer_fee_basis_points: TEST_FEE_BASIS_POINTS, - maximum_fee: TEST_MAXIMUM_FEE, - }, - ExtensionInitializationParams::ConfidentialTransferMint { - authority: Some(confidential_transfer_authority.pubkey()), - auto_approve_new_accounts, - auditor_elgamal_pubkey: Some(auditor_elgamal_pubkey), - }, - ExtensionInitializationParams::ConfidentialTransferFeeConfig { - authority: Some(confidential_transfer_fee_authority.pubkey()), - withdraw_withheld_authority_elgamal_pubkey, - }, - ]) + .init_token_with_mint( + vec![ + ExtensionInitializationParams::TransferFeeConfig { + transfer_fee_config_authority: Some(transfer_fee_authority.pubkey()), + withdraw_withheld_authority: Some(withdraw_withheld_authority.pubkey()), + transfer_fee_basis_points: TEST_FEE_BASIS_POINTS, + maximum_fee: TEST_MAXIMUM_FEE, + }, + ExtensionInitializationParams::ConfidentialTransferMint { + authority: Some(confidential_transfer_authority.pubkey()), + auto_approve_new_accounts, + auditor_elgamal_pubkey: Some(auditor_elgamal_pubkey), + }, + ExtensionInitializationParams::ConfidentialTransferFeeConfig { + authority: Some(confidential_transfer_fee_authority.pubkey()), + withdraw_withheld_authority_elgamal_pubkey, + }, + ], + &[], + ) .await .unwrap(); } @@ -324,13 +336,14 @@ async fn confidential_transfer_initialize_and_update_mint() { let mut context = TestContext::new().await; context - .init_token_with_mint(vec![ - ExtensionInitializationParams::ConfidentialTransferMint { + .init_token_with_mint( + vec![ExtensionInitializationParams::ConfidentialTransferMint { authority: Some(authority.pubkey()), auto_approve_new_accounts, auditor_elgamal_pubkey: Some(auditor_elgamal_pubkey), - }, - ]) + }], + &[], + ) .await .unwrap(); @@ -472,23 +485,26 @@ async fn confidential_transfer_withdraw_withheld_tokens_from_mint() { let mut context = TestContext::new().await; context - .init_token_with_mint(vec![ - ExtensionInitializationParams::TransferFeeConfig { - transfer_fee_config_authority: Some(transfer_fee_authority.pubkey()), - withdraw_withheld_authority: Some(withdraw_withheld_authority.pubkey()), - transfer_fee_basis_points: TEST_FEE_BASIS_POINTS, - maximum_fee: TEST_MAXIMUM_FEE, - }, - ExtensionInitializationParams::ConfidentialTransferMint { - authority: Some(confidential_transfer_authority.pubkey()), - auto_approve_new_accounts, - auditor_elgamal_pubkey: Some(auditor_elgamal_pubkey), - }, - ExtensionInitializationParams::ConfidentialTransferFeeConfig { - authority: Some(confidential_transfer_fee_authority.pubkey()), - withdraw_withheld_authority_elgamal_pubkey, - }, - ]) + .init_token_with_mint( + vec![ + ExtensionInitializationParams::TransferFeeConfig { + transfer_fee_config_authority: Some(transfer_fee_authority.pubkey()), + withdraw_withheld_authority: Some(withdraw_withheld_authority.pubkey()), + transfer_fee_basis_points: TEST_FEE_BASIS_POINTS, + maximum_fee: TEST_MAXIMUM_FEE, + }, + ExtensionInitializationParams::ConfidentialTransferMint { + authority: Some(confidential_transfer_authority.pubkey()), + auto_approve_new_accounts, + auditor_elgamal_pubkey: Some(auditor_elgamal_pubkey), + }, + ExtensionInitializationParams::ConfidentialTransferFeeConfig { + authority: Some(confidential_transfer_fee_authority.pubkey()), + withdraw_withheld_authority_elgamal_pubkey, + }, + ], + &[], + ) .await .unwrap(); @@ -630,23 +646,26 @@ async fn confidential_transfer_withdraw_withheld_tokens_from_accounts() { let mut context = TestContext::new().await; context - .init_token_with_mint(vec![ - ExtensionInitializationParams::TransferFeeConfig { - transfer_fee_config_authority: Some(transfer_fee_authority.pubkey()), - withdraw_withheld_authority: Some(withdraw_withheld_authority.pubkey()), - transfer_fee_basis_points: TEST_FEE_BASIS_POINTS, - maximum_fee: TEST_MAXIMUM_FEE, - }, - ExtensionInitializationParams::ConfidentialTransferMint { - authority: Some(confidential_transfer_authority.pubkey()), - auto_approve_new_accounts, - auditor_elgamal_pubkey: Some(auditor_elgamal_pubkey), - }, - ExtensionInitializationParams::ConfidentialTransferFeeConfig { - authority: Some(confidential_transfer_fee_authority.pubkey()), - withdraw_withheld_authority_elgamal_pubkey, - }, - ]) + .init_token_with_mint( + vec![ + ExtensionInitializationParams::TransferFeeConfig { + transfer_fee_config_authority: Some(transfer_fee_authority.pubkey()), + withdraw_withheld_authority: Some(withdraw_withheld_authority.pubkey()), + transfer_fee_basis_points: TEST_FEE_BASIS_POINTS, + maximum_fee: TEST_MAXIMUM_FEE, + }, + ExtensionInitializationParams::ConfidentialTransferMint { + authority: Some(confidential_transfer_authority.pubkey()), + auto_approve_new_accounts, + auditor_elgamal_pubkey: Some(auditor_elgamal_pubkey), + }, + ExtensionInitializationParams::ConfidentialTransferFeeConfig { + authority: Some(confidential_transfer_fee_authority.pubkey()), + withdraw_withheld_authority_elgamal_pubkey, + }, + ], + &[], + ) .await .unwrap(); @@ -760,23 +779,26 @@ async fn confidential_transfer_withdraw_withheld_tokens_from_mint_with_proof_con let mut context = TestContext::new().await; context - .init_token_with_mint(vec![ - ExtensionInitializationParams::TransferFeeConfig { - transfer_fee_config_authority: Some(transfer_fee_authority.pubkey()), - withdraw_withheld_authority: Some(withdraw_withheld_authority.pubkey()), - transfer_fee_basis_points: TEST_FEE_BASIS_POINTS, - maximum_fee: TEST_MAXIMUM_FEE, - }, - ExtensionInitializationParams::ConfidentialTransferMint { - authority: Some(confidential_transfer_authority.pubkey()), - auto_approve_new_accounts, - auditor_elgamal_pubkey: Some(auditor_elgamal_pubkey), - }, - ExtensionInitializationParams::ConfidentialTransferFeeConfig { - authority: Some(confidential_transfer_fee_authority.pubkey()), - withdraw_withheld_authority_elgamal_pubkey, - }, - ]) + .init_token_with_mint( + vec![ + ExtensionInitializationParams::TransferFeeConfig { + transfer_fee_config_authority: Some(transfer_fee_authority.pubkey()), + withdraw_withheld_authority: Some(withdraw_withheld_authority.pubkey()), + transfer_fee_basis_points: TEST_FEE_BASIS_POINTS, + maximum_fee: TEST_MAXIMUM_FEE, + }, + ExtensionInitializationParams::ConfidentialTransferMint { + authority: Some(confidential_transfer_authority.pubkey()), + auto_approve_new_accounts, + auditor_elgamal_pubkey: Some(auditor_elgamal_pubkey), + }, + ExtensionInitializationParams::ConfidentialTransferFeeConfig { + authority: Some(confidential_transfer_fee_authority.pubkey()), + withdraw_withheld_authority_elgamal_pubkey, + }, + ], + &[], + ) .await .unwrap(); @@ -928,23 +950,26 @@ async fn confidential_transfer_withdraw_withheld_tokens_from_accounts_with_proof let mut context = TestContext::new().await; context - .init_token_with_mint(vec![ - ExtensionInitializationParams::TransferFeeConfig { - transfer_fee_config_authority: Some(transfer_fee_authority.pubkey()), - withdraw_withheld_authority: Some(withdraw_withheld_authority.pubkey()), - transfer_fee_basis_points: TEST_FEE_BASIS_POINTS, - maximum_fee: TEST_MAXIMUM_FEE, - }, - ExtensionInitializationParams::ConfidentialTransferMint { - authority: Some(confidential_transfer_authority.pubkey()), - auto_approve_new_accounts, - auditor_elgamal_pubkey: Some(auditor_elgamal_pubkey), - }, - ExtensionInitializationParams::ConfidentialTransferFeeConfig { - authority: Some(confidential_transfer_fee_authority.pubkey()), - withdraw_withheld_authority_elgamal_pubkey, - }, - ]) + .init_token_with_mint( + vec![ + ExtensionInitializationParams::TransferFeeConfig { + transfer_fee_config_authority: Some(transfer_fee_authority.pubkey()), + withdraw_withheld_authority: Some(withdraw_withheld_authority.pubkey()), + transfer_fee_basis_points: TEST_FEE_BASIS_POINTS, + maximum_fee: TEST_MAXIMUM_FEE, + }, + ExtensionInitializationParams::ConfidentialTransferMint { + authority: Some(confidential_transfer_authority.pubkey()), + auto_approve_new_accounts, + auditor_elgamal_pubkey: Some(auditor_elgamal_pubkey), + }, + ExtensionInitializationParams::ConfidentialTransferFeeConfig { + authority: Some(confidential_transfer_fee_authority.pubkey()), + withdraw_withheld_authority_elgamal_pubkey, + }, + ], + &[], + ) .await .unwrap(); @@ -1112,23 +1137,26 @@ async fn confidential_transfer_harvest_withheld_tokens_to_mint() { let mut context = TestContext::new().await; context - .init_token_with_mint(vec![ - ExtensionInitializationParams::TransferFeeConfig { - transfer_fee_config_authority: Some(transfer_fee_authority.pubkey()), - withdraw_withheld_authority: Some(withdraw_withheld_authority.pubkey()), - transfer_fee_basis_points: TEST_FEE_BASIS_POINTS, - maximum_fee: TEST_MAXIMUM_FEE, - }, - ExtensionInitializationParams::ConfidentialTransferMint { - authority: Some(confidential_transfer_authority.pubkey()), - auto_approve_new_accounts, - auditor_elgamal_pubkey: Some(auditor_elgamal_pubkey), - }, - ExtensionInitializationParams::ConfidentialTransferFeeConfig { - authority: Some(confidential_transfer_fee_authority.pubkey()), - withdraw_withheld_authority_elgamal_pubkey, - }, - ]) + .init_token_with_mint( + vec![ + ExtensionInitializationParams::TransferFeeConfig { + transfer_fee_config_authority: Some(transfer_fee_authority.pubkey()), + withdraw_withheld_authority: Some(withdraw_withheld_authority.pubkey()), + transfer_fee_basis_points: TEST_FEE_BASIS_POINTS, + maximum_fee: TEST_MAXIMUM_FEE, + }, + ExtensionInitializationParams::ConfidentialTransferMint { + authority: Some(confidential_transfer_authority.pubkey()), + auto_approve_new_accounts, + auditor_elgamal_pubkey: Some(auditor_elgamal_pubkey), + }, + ExtensionInitializationParams::ConfidentialTransferFeeConfig { + authority: Some(confidential_transfer_fee_authority.pubkey()), + withdraw_withheld_authority_elgamal_pubkey, + }, + ], + &[], + ) .await .unwrap(); diff --git a/token/program-2022-test/tests/cpi_guard.rs b/token/program-2022-test/tests/cpi_guard.rs index 518303aca17..e8b56dca8c7 100644 --- a/token/program-2022-test/tests/cpi_guard.rs +++ b/token/program-2022-test/tests/cpi_guard.rs @@ -59,7 +59,10 @@ async fn make_context() -> TestContext { token_context: None, }; - test_context.init_token_with_mint(vec![]).await.unwrap(); + test_context + .init_token_with_mint(vec![], &[]) + .await + .unwrap(); let token_context = test_context.token_context.as_ref().unwrap(); token_context diff --git a/token/program-2022-test/tests/default_account_state.rs b/token/program-2022-test/tests/default_account_state.rs index ebee881d9e9..317cdf4d870 100644 --- a/token/program-2022-test/tests/default_account_state.rs +++ b/token/program-2022-test/tests/default_account_state.rs @@ -23,9 +23,12 @@ async fn success_init_default_acct_state_frozen() { let default_account_state = AccountState::Frozen; let mut context = TestContext::new().await; context - .init_token_with_freezing_mint(vec![ExtensionInitializationParams::DefaultAccountState { - state: default_account_state, - }]) + .init_token_with_freezing_mint( + vec![ExtensionInitializationParams::DefaultAccountState { + state: default_account_state, + }], + &[], + ) .await .unwrap(); let TokenContext { @@ -60,9 +63,12 @@ async fn fail_init_no_authority_default_acct_state_frozen() { let default_account_state = AccountState::Frozen; let mut context = TestContext::new().await; let err = context - .init_token_with_mint(vec![ExtensionInitializationParams::DefaultAccountState { - state: default_account_state, - }]) + .init_token_with_mint( + vec![ExtensionInitializationParams::DefaultAccountState { + state: default_account_state, + }], + &[], + ) .await .unwrap_err(); @@ -82,9 +88,12 @@ async fn success_init_default_acct_state_initialized() { let default_account_state = AccountState::Initialized; let mut context = TestContext::new().await; context - .init_token_with_mint(vec![ExtensionInitializationParams::DefaultAccountState { - state: default_account_state, - }]) + .init_token_with_mint( + vec![ExtensionInitializationParams::DefaultAccountState { + state: default_account_state, + }], + &[], + ) .await .unwrap(); let TokenContext { @@ -115,9 +124,12 @@ async fn success_no_authority_init_default_acct_state_initialized() { let default_account_state = AccountState::Initialized; let mut context = TestContext::new().await; context - .init_token_with_freezing_mint(vec![ExtensionInitializationParams::DefaultAccountState { - state: default_account_state, - }]) + .init_token_with_freezing_mint( + vec![ExtensionInitializationParams::DefaultAccountState { + state: default_account_state, + }], + &[], + ) .await .unwrap(); let TokenContext { @@ -152,9 +164,12 @@ async fn fail_invalid_default_acct_state() { let default_account_state = AccountState::Uninitialized; let mut context = TestContext::new().await; let err = context - .init_token_with_freezing_mint(vec![ExtensionInitializationParams::DefaultAccountState { - state: default_account_state, - }]) + .init_token_with_freezing_mint( + vec![ExtensionInitializationParams::DefaultAccountState { + state: default_account_state, + }], + &[], + ) .await .unwrap_err(); assert_eq!( @@ -173,9 +188,12 @@ async fn end_to_end_default_account_state() { let default_account_state = AccountState::Frozen; let mut context = TestContext::new().await; context - .init_token_with_freezing_mint(vec![ExtensionInitializationParams::DefaultAccountState { - state: default_account_state, - }]) + .init_token_with_freezing_mint( + vec![ExtensionInitializationParams::DefaultAccountState { + state: default_account_state, + }], + &[], + ) .await .unwrap(); let TokenContext { diff --git a/token/program-2022-test/tests/delegate.rs b/token/program-2022-test/tests/delegate.rs index ee337cb0da3..d6d17e40df1 100644 --- a/token/program-2022-test/tests/delegate.rs +++ b/token/program-2022-test/tests/delegate.rs @@ -197,7 +197,7 @@ async fn run_basic( #[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, OwnerMode::External, @@ -210,7 +210,7 @@ async fn basic() { #[tokio::test] async fn basic_checked() { 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, OwnerMode::External, @@ -223,7 +223,7 @@ async fn basic_checked() { #[tokio::test] async fn basic_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_basic( context, OwnerMode::SelfOwned, @@ -237,12 +237,15 @@ async fn basic_self_owned() { 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( @@ -258,12 +261,15 @@ async fn basic_with_extension() { async fn basic_with_extension_checked() { 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( @@ -279,12 +285,15 @@ async fn basic_with_extension_checked() { async fn basic_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_basic( diff --git a/token/program-2022-test/tests/freeze.rs b/token/program-2022-test/tests/freeze.rs index f17b5ff3b90..49e822ab992 100644 --- a/token/program-2022-test/tests/freeze.rs +++ b/token/program-2022-test/tests/freeze.rs @@ -11,7 +11,10 @@ use { #[tokio::test] async fn basic() { let mut context = TestContext::new().await; - context.init_token_with_freezing_mint(vec![]).await.unwrap(); + context + .init_token_with_freezing_mint(vec![], &[]) + .await + .unwrap(); let TokenContext { freeze_authority, token, diff --git a/token/program-2022-test/tests/group_pointer.rs b/token/program-2022-test/tests/group_pointer.rs index 5dc6922919f..7c942bfb266 100644 --- a/token/program-2022-test/tests/group_pointer.rs +++ b/token/program-2022-test/tests/group_pointer.rs @@ -46,6 +46,7 @@ async fn setup(mint: Keypair, group_address: &Pubkey, authority: &Pubkey) -> Tes group_address: Some(*group_address), }], None, + &[], ) .await .unwrap(); @@ -97,6 +98,7 @@ async fn fail_init_all_none() { group_address: None, }], None, + &[], ) .await .unwrap_err(); diff --git a/token/program-2022-test/tests/initialize_mint.rs b/token/program-2022-test/tests/initialize_mint.rs index 898ecd4ea19..ffc6ab7e570 100644 --- a/token/program-2022-test/tests/initialize_mint.rs +++ b/token/program-2022-test/tests/initialize_mint.rs @@ -32,7 +32,7 @@ use { #[tokio::test] async fn success_base() { let mut context = TestContext::new().await; - context.init_token_with_mint(vec![]).await.unwrap(); + context.init_token_with_mint(vec![], &[]).await.unwrap(); let TokenContext { decimals, mint_authority, @@ -160,9 +160,10 @@ async fn success_extension_and_base() { let close_authority = Some(Pubkey::new_unique()); let mut context = TestContext::new().await; context - .init_token_with_mint(vec![ExtensionInitializationParams::MintCloseAuthority { - close_authority, - }]) + .init_token_with_mint( + vec![ExtensionInitializationParams::MintCloseAuthority { close_authority }], + &[], + ) .await .unwrap(); let TokenContext { diff --git a/token/program-2022-test/tests/interest_bearing_mint.rs b/token/program-2022-test/tests/interest_bearing_mint.rs index 5a2299bb1a5..cdbfc914e48 100644 --- a/token/program-2022-test/tests/interest_bearing_mint.rs +++ b/token/program-2022-test/tests/interest_bearing_mint.rs @@ -36,10 +36,13 @@ async fn success_initialize() { for (rate, rate_authority) in [(i16::MIN, None), (i16::MAX, Some(Pubkey::new_unique()))] { let mut context = TestContext::new().await; context - .init_token_with_mint(vec![ExtensionInitializationParams::InterestBearingConfig { - rate_authority, - rate, - }]) + .init_token_with_mint( + vec![ExtensionInitializationParams::InterestBearingConfig { + rate_authority, + rate, + }], + &[], + ) .await .unwrap(); let TokenContext { token, .. } = context.token_context.unwrap(); @@ -61,10 +64,13 @@ async fn update_rate() { let initial_rate = 500; let mut context = TestContext::new().await; context - .init_token_with_mint(vec![ExtensionInitializationParams::InterestBearingConfig { - rate_authority: Some(rate_authority.pubkey()), - rate: initial_rate, - }]) + .init_token_with_mint( + vec![ExtensionInitializationParams::InterestBearingConfig { + rate_authority: Some(rate_authority.pubkey()), + rate: initial_rate, + }], + &[], + ) .await .unwrap(); let TokenContext { token, .. } = context.token_context.take().unwrap(); @@ -153,10 +159,13 @@ async fn set_authority() { let initial_rate = 500; let mut context = TestContext::new().await; context - .init_token_with_mint(vec![ExtensionInitializationParams::InterestBearingConfig { - rate_authority: Some(rate_authority.pubkey()), - rate: initial_rate, - }]) + .init_token_with_mint( + vec![ExtensionInitializationParams::InterestBearingConfig { + rate_authority: Some(rate_authority.pubkey()), + rate: initial_rate, + }], + &[], + ) .await .unwrap(); let TokenContext { token, .. } = context.token_context.take().unwrap(); @@ -306,10 +315,13 @@ async fn amount_conversions() { }; let initial_rate = i16::MAX; context - .init_token_with_mint(vec![ExtensionInitializationParams::InterestBearingConfig { - rate_authority: Some(rate_authority.pubkey()), - rate: initial_rate, - }]) + .init_token_with_mint( + vec![ExtensionInitializationParams::InterestBearingConfig { + rate_authority: Some(rate_authority.pubkey()), + rate: initial_rate, + }], + &[], + ) .await .unwrap(); let TokenContext { token, .. } = context.token_context.take().unwrap(); diff --git a/token/program-2022-test/tests/memo_transfer.rs b/token/program-2022-test/tests/memo_transfer.rs index 23a3d7afbe3..d72625b4c1d 100644 --- a/token/program-2022-test/tests/memo_transfer.rs +++ b/token/program-2022-test/tests/memo_transfer.rs @@ -172,7 +172,7 @@ async fn test_memo_transfers( #[tokio::test] async fn require_memo_transfers_without_realloc() { let mut context = TestContext::new().await; - context.init_token_with_mint(vec![]).await.unwrap(); + context.init_token_with_mint(vec![], &[]).await.unwrap(); let token_context = context.token_context.unwrap(); // create token accounts @@ -199,7 +199,7 @@ async fn require_memo_transfers_without_realloc() { #[tokio::test] async fn require_memo_transfers_with_realloc() { let mut context = TestContext::new().await; - context.init_token_with_mint(vec![]).await.unwrap(); + context.init_token_with_mint(vec![], &[]).await.unwrap(); let token_context = context.token_context.unwrap(); // create token accounts diff --git a/token/program-2022-test/tests/metadata_pointer.rs b/token/program-2022-test/tests/metadata_pointer.rs index 32f61f2271c..adb7325c6de 100644 --- a/token/program-2022-test/tests/metadata_pointer.rs +++ b/token/program-2022-test/tests/metadata_pointer.rs @@ -46,6 +46,7 @@ async fn setup(mint: Keypair, metadata_address: &Pubkey, authority: &Pubkey) -> metadata_address: Some(*metadata_address), }], None, + &[], ) .await .unwrap(); @@ -97,6 +98,7 @@ async fn fail_init_all_none() { metadata_address: None, }], None, + &[], ) .await .unwrap_err(); diff --git a/token/program-2022-test/tests/mint_close_authority.rs b/token/program-2022-test/tests/mint_close_authority.rs index 1ea2bca1b2d..97b56937021 100644 --- a/token/program-2022-test/tests/mint_close_authority.rs +++ b/token/program-2022-test/tests/mint_close_authority.rs @@ -22,9 +22,10 @@ async fn success_init() { let close_authority = Some(Pubkey::new_unique()); let mut context = TestContext::new().await; context - .init_token_with_mint(vec![ExtensionInitializationParams::MintCloseAuthority { - close_authority, - }]) + .init_token_with_mint( + vec![ExtensionInitializationParams::MintCloseAuthority { close_authority }], + &[], + ) .await .unwrap(); let TokenContext { @@ -55,9 +56,12 @@ async fn set_authority() { let close_authority = Keypair::new(); let mut context = TestContext::new().await; 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.unwrap().token; @@ -166,9 +170,12 @@ async fn success_close() { let close_authority = Keypair::new(); let mut context = TestContext::new().await; 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.unwrap().token; @@ -191,7 +198,7 @@ async fn success_close() { async fn fail_without_extension() { let close_authority = Pubkey::new_unique(); let mut context = TestContext::new().await; - context.init_token_with_mint(vec![]).await.unwrap(); + context.init_token_with_mint(vec![], &[]).await.unwrap(); let TokenContext { mint_authority, token, @@ -240,9 +247,12 @@ async fn fail_close_with_supply() { let close_authority = Keypair::new(); let mut context = TestContext::new().await; 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 TokenContext { diff --git a/token/program-2022-test/tests/non_transferable.rs b/token/program-2022-test/tests/non_transferable.rs index aedb8023a65..e7cf989d756 100644 --- a/token/program-2022-test/tests/non_transferable.rs +++ b/token/program-2022-test/tests/non_transferable.rs @@ -20,7 +20,7 @@ async fn transfer() { let test_transfer_amount = 100; let mut context = TestContext::new().await; context - .init_token_with_mint(vec![ExtensionInitializationParams::NonTransferable]) + .init_token_with_mint(vec![ExtensionInitializationParams::NonTransferable], &[]) .await .unwrap(); @@ -166,15 +166,18 @@ async fn transfer_checked_with_fee() { let mut context = TestContext::new().await; context - .init_token_with_mint(vec![ - ExtensionInitializationParams::TransferFeeConfig { - transfer_fee_config_authority: transfer_fee_config_authority.pubkey().into(), - withdraw_withheld_authority: withdraw_withheld_authority.pubkey().into(), - transfer_fee_basis_points, - maximum_fee, - }, - ExtensionInitializationParams::NonTransferable, - ]) + .init_token_with_mint( + vec![ + ExtensionInitializationParams::TransferFeeConfig { + transfer_fee_config_authority: transfer_fee_config_authority.pubkey().into(), + withdraw_withheld_authority: withdraw_withheld_authority.pubkey().into(), + transfer_fee_basis_points, + maximum_fee, + }, + ExtensionInitializationParams::NonTransferable, + ], + &[], + ) .await .unwrap(); diff --git a/token/program-2022-test/tests/permanent_delegate.rs b/token/program-2022-test/tests/permanent_delegate.rs index 0543fadd0af..d7e5777d015 100644 --- a/token/program-2022-test/tests/permanent_delegate.rs +++ b/token/program-2022-test/tests/permanent_delegate.rs @@ -52,9 +52,10 @@ async fn success_init() { let delegate = Pubkey::new_unique(); let mut context = TestContext::new().await; context - .init_token_with_mint(vec![ExtensionInitializationParams::PermanentDelegate { - delegate, - }]) + .init_token_with_mint( + vec![ExtensionInitializationParams::PermanentDelegate { delegate }], + &[], + ) .await .unwrap(); let TokenContext { token, .. } = context.token_context.unwrap(); @@ -70,9 +71,12 @@ async fn set_authority() { let delegate = Keypair::new(); let mut context = TestContext::new().await; context - .init_token_with_mint(vec![ExtensionInitializationParams::PermanentDelegate { - delegate: delegate.pubkey(), - }]) + .init_token_with_mint( + vec![ExtensionInitializationParams::PermanentDelegate { + delegate: delegate.pubkey(), + }], + &[], + ) .await .unwrap(); let token_context = context.token_context.unwrap(); @@ -191,9 +195,12 @@ async fn success_transfer() { let delegate = Keypair::new(); let mut context = TestContext::new().await; context - .init_token_with_mint(vec![ExtensionInitializationParams::PermanentDelegate { - delegate: delegate.pubkey(), - }]) + .init_token_with_mint( + vec![ExtensionInitializationParams::PermanentDelegate { + delegate: delegate.pubkey(), + }], + &[], + ) .await .unwrap(); let token_context = context.token_context.unwrap(); @@ -225,9 +232,12 @@ async fn success_burn() { let delegate = Keypair::new(); let mut context = TestContext::new().await; context - .init_token_with_mint(vec![ExtensionInitializationParams::PermanentDelegate { - delegate: delegate.pubkey(), - }]) + .init_token_with_mint( + vec![ExtensionInitializationParams::PermanentDelegate { + delegate: delegate.pubkey(), + }], + &[], + ) .await .unwrap(); let token_context = context.token_context.unwrap(); @@ -252,7 +262,7 @@ async fn success_burn() { async fn fail_without_extension() { let delegate = Pubkey::new_unique(); let mut context = TestContext::new().await; - context.init_token_with_mint(vec![]).await.unwrap(); + context.init_token_with_mint(vec![], &[]).await.unwrap(); let token_context = context.token_context.unwrap(); // fail set diff --git a/token/program-2022-test/tests/program_test.rs b/token/program-2022-test/tests/program_test.rs index 1400285a0c0..6e17cb099ea 100644 --- a/token/program-2022-test/tests/program_test.rs +++ b/token/program-2022-test/tests/program_test.rs @@ -41,19 +41,26 @@ impl TestContext { pub async fn init_token_with_mint( &mut self, extension_init_params: Vec, + additional_signers: &[&Keypair], ) -> TokenResult<()> { - self.init_token_with_mint_and_freeze_authority(extension_init_params, None) - .await + self.init_token_with_mint_and_freeze_authority( + extension_init_params, + None, + additional_signers, + ) + .await } pub async fn init_token_with_freezing_mint( &mut self, extension_init_params: Vec, + additional_signers: &[&Keypair], ) -> TokenResult<()> { let freeze_authority = Keypair::new(); self.init_token_with_mint_and_freeze_authority( extension_init_params, Some(freeze_authority), + additional_signers, ) .await } @@ -62,12 +69,14 @@ impl TestContext { &mut self, extension_init_params: Vec, freeze_authority: Option, + additional_signers: &[&Keypair], ) -> TokenResult<()> { let mint_account = Keypair::new(); self.init_token_with_mint_keypair_and_freeze_authority( mint_account, extension_init_params, freeze_authority, + additional_signers, ) .await } @@ -77,6 +86,7 @@ impl TestContext { mint_account: Keypair, extension_init_params: Vec, freeze_authority: Option, + additional_signers: &[&Keypair], ) -> TokenResult<()> { let payer = keypair_clone(&self.context.lock().await.payer); let client: Arc> = @@ -109,12 +119,15 @@ impl TestContext { Arc::new(payer), ); + let mut signing_keypairs = vec![&mint_account]; + signing_keypairs.extend_from_slice(additional_signers); + token .create_mint( &mint_authority_pubkey, freeze_authority_pubkey.as_ref(), extension_init_params, - &[&mint_account], + &signing_keypairs, ) .await?; diff --git a/token/program-2022-test/tests/reallocate.rs b/token/program-2022-test/tests/reallocate.rs index 733dfd1aca0..86c1cf501ea 100644 --- a/token/program-2022-test/tests/reallocate.rs +++ b/token/program-2022-test/tests/reallocate.rs @@ -23,7 +23,7 @@ use { #[tokio::test] async fn reallocate() { let mut context = TestContext::new().await; - context.init_token_with_mint(vec![]).await.unwrap(); + context.init_token_with_mint(vec![], &[]).await.unwrap(); let TokenContext { token, alice, @@ -161,12 +161,19 @@ async fn reallocate() { async fn reallocate_without_current_extension_knowledge() { let mut context = TestContext::new().await; context - .init_token_with_mint(vec![ExtensionInitializationParams::TransferFeeConfig { - transfer_fee_config_authority: COption::Some(Pubkey::new_unique()).try_into().unwrap(), - withdraw_withheld_authority: COption::Some(Pubkey::new_unique()).try_into().unwrap(), - transfer_fee_basis_points: 250, - maximum_fee: 10_000_000, - }]) + .init_token_with_mint( + vec![ExtensionInitializationParams::TransferFeeConfig { + transfer_fee_config_authority: COption::Some(Pubkey::new_unique()) + .try_into() + .unwrap(), + withdraw_withheld_authority: COption::Some(Pubkey::new_unique()) + .try_into() + .unwrap(), + transfer_fee_basis_points: 250, + maximum_fee: 10_000_000, + }], + &[], + ) .await .unwrap(); let TokenContext { token, alice, .. } = context.token_context.unwrap(); diff --git a/token/program-2022-test/tests/token_group_initialize.rs b/token/program-2022-test/tests/token_group_initialize.rs index e9d1296c31f..087f7aa73a2 100644 --- a/token/program-2022-test/tests/token_group_initialize.rs +++ b/token/program-2022-test/tests/token_group_initialize.rs @@ -43,6 +43,7 @@ async fn setup(mint: Keypair, authority: &Pubkey) -> TestContext { group_address, }], None, + &[], ) .await .unwrap(); @@ -159,7 +160,7 @@ async fn fail_without_group_pointer() { token_context: None, }; context - .init_token_with_mint_keypair_and_freeze_authority(mint_keypair, vec![], None) + .init_token_with_mint_keypair_and_freeze_authority(mint_keypair, vec![], None, &[]) .await .unwrap(); context @@ -206,6 +207,7 @@ async fn fail_init_in_another_mint() { group_address: Some(second_mint), }], None, + &[], ) .await .unwrap(); diff --git a/token/program-2022-test/tests/token_group_update_authority.rs b/token/program-2022-test/tests/token_group_update_authority.rs index a6f047b2c2a..adb991fd237 100644 --- a/token/program-2022-test/tests/token_group_update_authority.rs +++ b/token/program-2022-test/tests/token_group_update_authority.rs @@ -49,6 +49,7 @@ async fn setup(mint: Keypair, authority: &Pubkey) -> TestContext { group_address, }], None, + &[], ) .await .unwrap(); diff --git a/token/program-2022-test/tests/token_group_update_max_size.rs b/token/program-2022-test/tests/token_group_update_max_size.rs index 46655de9908..a54bae1ced3 100644 --- a/token/program-2022-test/tests/token_group_update_max_size.rs +++ b/token/program-2022-test/tests/token_group_update_max_size.rs @@ -47,6 +47,7 @@ async fn setup(mint: Keypair, authority: &Pubkey) -> TestContext { group_address, }], None, + &[], ) .await .unwrap(); diff --git a/token/program-2022-test/tests/token_metadata_emit.rs b/token/program-2022-test/tests/token_metadata_emit.rs index ccf14c5214b..a48677f6173 100644 --- a/token/program-2022-test/tests/token_metadata_emit.rs +++ b/token/program-2022-test/tests/token_metadata_emit.rs @@ -45,6 +45,7 @@ async fn setup(mint: Keypair, authority: &Pubkey) -> TestContext { metadata_address, }], None, + &[], ) .await .unwrap(); diff --git a/token/program-2022-test/tests/token_metadata_initialize.rs b/token/program-2022-test/tests/token_metadata_initialize.rs index e6576d68f68..0a22ed8e2c5 100644 --- a/token/program-2022-test/tests/token_metadata_initialize.rs +++ b/token/program-2022-test/tests/token_metadata_initialize.rs @@ -43,6 +43,7 @@ async fn setup(mint: Keypair, authority: &Pubkey) -> TestContext { metadata_address, }], None, + &[], ) .await .unwrap(); @@ -172,7 +173,7 @@ async fn fail_without_metadata_pointer() { token_context: None, }; context - .init_token_with_mint_keypair_and_freeze_authority(mint_keypair, vec![], None) + .init_token_with_mint_keypair_and_freeze_authority(mint_keypair, vec![], None, &[]) .await .unwrap(); context @@ -221,6 +222,7 @@ async fn fail_init_in_another_mint() { metadata_address: Some(second_mint), }], None, + &[], ) .await .unwrap(); diff --git a/token/program-2022-test/tests/token_metadata_remove_key.rs b/token/program-2022-test/tests/token_metadata_remove_key.rs index 8640196df70..00aa4776dc4 100644 --- a/token/program-2022-test/tests/token_metadata_remove_key.rs +++ b/token/program-2022-test/tests/token_metadata_remove_key.rs @@ -50,6 +50,7 @@ async fn setup(mint: Keypair, authority: &Pubkey) -> TestContext { metadata_address, }], None, + &[], ) .await .unwrap(); diff --git a/token/program-2022-test/tests/token_metadata_update_authority.rs b/token/program-2022-test/tests/token_metadata_update_authority.rs index 1a22baf63ee..e68acbdd3fa 100644 --- a/token/program-2022-test/tests/token_metadata_update_authority.rs +++ b/token/program-2022-test/tests/token_metadata_update_authority.rs @@ -49,6 +49,7 @@ async fn setup(mint: Keypair, authority: &Pubkey) -> TestContext { metadata_address, }], None, + &[], ) .await .unwrap(); diff --git a/token/program-2022-test/tests/token_metadata_update_field.rs b/token/program-2022-test/tests/token_metadata_update_field.rs index 83417d376f4..8cda1668a6c 100644 --- a/token/program-2022-test/tests/token_metadata_update_field.rs +++ b/token/program-2022-test/tests/token_metadata_update_field.rs @@ -48,6 +48,7 @@ async fn setup(mint: Keypair, authority: &Pubkey) -> TestContext { metadata_address, }], None, + &[], ) .await .unwrap(); diff --git a/token/program-2022-test/tests/transfer.rs b/token/program-2022-test/tests/transfer.rs index 8c3a395fdf5..81eb602b7dc 100644 --- a/token/program-2022-test/tests/transfer.rs +++ b/token/program-2022-test/tests/transfer.rs @@ -107,7 +107,7 @@ async fn run_basic_transfers(context: TestContext, test_mode: TestMode) { #[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_transfers(context, TestMode::All).await; } @@ -115,12 +115,15 @@ async fn basic() { 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_000_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_000_000u64, + }], + &[], + ) .await .unwrap(); run_basic_transfers(context, TestMode::CheckedOnly).await; @@ -203,7 +206,7 @@ async fn run_self_transfers(context: TestContext, test_mode: TestMode) { #[tokio::test] async fn self_transfer() { let mut context = TestContext::new().await; - context.init_token_with_mint(vec![]).await.unwrap(); + context.init_token_with_mint(vec![], &[]).await.unwrap(); run_self_transfers(context, TestMode::All).await; } @@ -211,12 +214,15 @@ async fn self_transfer() { async fn self_transfer_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_000_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_000_000u64, + }], + &[], + ) .await .unwrap(); run_self_transfers(context, TestMode::CheckedOnly).await; @@ -286,7 +292,7 @@ async fn run_self_owned(context: TestContext, test_mode: TestMode) { #[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, TestMode::All).await; } @@ -294,12 +300,15 @@ async fn self_owned() { 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_000_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_000_000u64, + }], + &[], + ) .await .unwrap(); run_self_owned(context, TestMode::CheckedOnly).await; @@ -308,7 +317,7 @@ async fn self_owned_with_extension() { #[tokio::test] async fn transfer_with_fee_on_mint_without_fee_configured() { let mut context = TestContext::new().await; - context.init_token_with_mint(vec![]).await.unwrap(); + context.init_token_with_mint(vec![], &[]).await.unwrap(); let TokenContext { mint_authority, token, diff --git a/token/program-2022-test/tests/transfer_fee.rs b/token/program-2022-test/tests/transfer_fee.rs index 2249cac0337..8422df43592 100644 --- a/token/program-2022-test/tests/transfer_fee.rs +++ b/token/program-2022-test/tests/transfer_fee.rs @@ -102,12 +102,15 @@ async fn create_mint_with_accounts(alice_amount: u64) -> TokenWithAccounts { ); let maximum_fee = u64::from(transfer_fee_config.newer_transfer_fee.maximum_fee); context - .init_token_with_freezing_mint(vec![ExtensionInitializationParams::TransferFeeConfig { - transfer_fee_config_authority: transfer_fee_config_authority.pubkey().into(), - withdraw_withheld_authority: withdraw_withheld_authority.pubkey().into(), - transfer_fee_basis_points, - maximum_fee, - }]) + .init_token_with_freezing_mint( + vec![ExtensionInitializationParams::TransferFeeConfig { + transfer_fee_config_authority: transfer_fee_config_authority.pubkey().into(), + withdraw_withheld_authority: withdraw_withheld_authority.pubkey().into(), + transfer_fee_basis_points, + maximum_fee, + }], + &[], + ) .await .unwrap(); let TokenContext { @@ -166,12 +169,15 @@ async fn success_init() { } = test_transfer_fee_config(); let mut context = TestContext::new().await; context - .init_token_with_mint(vec![ExtensionInitializationParams::TransferFeeConfig { - transfer_fee_config_authority: transfer_fee_config_authority.into(), - withdraw_withheld_authority: withdraw_withheld_authority.into(), - transfer_fee_basis_points: newer_transfer_fee.transfer_fee_basis_points.into(), - maximum_fee: newer_transfer_fee.maximum_fee.into(), - }]) + .init_token_with_mint( + vec![ExtensionInitializationParams::TransferFeeConfig { + transfer_fee_config_authority: transfer_fee_config_authority.into(), + withdraw_withheld_authority: withdraw_withheld_authority.into(), + transfer_fee_basis_points: newer_transfer_fee.transfer_fee_basis_points.into(), + maximum_fee: newer_transfer_fee.maximum_fee.into(), + }], + &[], + ) .await .unwrap(); let TokenContext { @@ -212,12 +218,15 @@ async fn fail_init_default_pubkey_as_authority() { } = test_transfer_fee_config(); let mut context = TestContext::new().await; let err = context - .init_token_with_mint(vec![ExtensionInitializationParams::TransferFeeConfig { - transfer_fee_config_authority: transfer_fee_config_authority.into(), - withdraw_withheld_authority: Some(Pubkey::default()), - transfer_fee_basis_points: newer_transfer_fee.transfer_fee_basis_points.into(), - maximum_fee: newer_transfer_fee.maximum_fee.into(), - }]) + .init_token_with_mint( + vec![ExtensionInitializationParams::TransferFeeConfig { + transfer_fee_config_authority: transfer_fee_config_authority.into(), + withdraw_withheld_authority: Some(Pubkey::default()), + transfer_fee_basis_points: newer_transfer_fee.transfer_fee_basis_points.into(), + maximum_fee: newer_transfer_fee.maximum_fee.into(), + }], + &[], + ) .await .unwrap_err(); assert_eq!( @@ -238,12 +247,15 @@ async fn fail_init_fee_too_high() { } = test_transfer_fee_config(); let mut context = TestContext::new().await; let err = context - .init_token_with_mint(vec![ExtensionInitializationParams::TransferFeeConfig { - transfer_fee_config_authority: transfer_fee_config_authority.into(), - withdraw_withheld_authority: withdraw_withheld_authority.into(), - transfer_fee_basis_points: MAX_FEE_BASIS_POINTS + 1, - maximum_fee: newer_transfer_fee.maximum_fee.into(), - }]) + .init_token_with_mint( + vec![ExtensionInitializationParams::TransferFeeConfig { + transfer_fee_config_authority: transfer_fee_config_authority.into(), + withdraw_withheld_authority: withdraw_withheld_authority.into(), + transfer_fee_basis_points: MAX_FEE_BASIS_POINTS + 1, + maximum_fee: newer_transfer_fee.maximum_fee.into(), + }], + &[], + ) .await .unwrap_err(); assert_eq!( @@ -269,12 +281,15 @@ async fn set_fee() { } = test_transfer_fee_config_with_keypairs(); let mut context = TestContext::new().await; context - .init_token_with_mint(vec![ExtensionInitializationParams::TransferFeeConfig { - transfer_fee_config_authority: transfer_fee_config_authority.pubkey().into(), - withdraw_withheld_authority: withdraw_withheld_authority.pubkey().into(), - transfer_fee_basis_points: newer_transfer_fee.transfer_fee_basis_points.into(), - maximum_fee: newer_transfer_fee.maximum_fee.into(), - }]) + .init_token_with_mint( + vec![ExtensionInitializationParams::TransferFeeConfig { + transfer_fee_config_authority: transfer_fee_config_authority.pubkey().into(), + withdraw_withheld_authority: withdraw_withheld_authority.pubkey().into(), + transfer_fee_basis_points: newer_transfer_fee.transfer_fee_basis_points.into(), + maximum_fee: newer_transfer_fee.maximum_fee.into(), + }], + &[], + ) .await .unwrap(); @@ -451,7 +466,7 @@ async fn set_fee() { #[tokio::test] async fn fail_unsupported_mint() { let mut context = TestContext::new().await; - context.init_token_with_mint(vec![]).await.unwrap(); + context.init_token_with_mint(vec![], &[]).await.unwrap(); let TokenContext { mint_authority, token, @@ -515,12 +530,15 @@ async fn set_transfer_fee_config_authority() { } = test_transfer_fee_config_with_keypairs(); let mut context = TestContext::new().await; context - .init_token_with_mint(vec![ExtensionInitializationParams::TransferFeeConfig { - transfer_fee_config_authority: transfer_fee_config_authority.pubkey().into(), - withdraw_withheld_authority: withdraw_withheld_authority.pubkey().into(), - transfer_fee_basis_points: newer_transfer_fee.transfer_fee_basis_points.into(), - maximum_fee: newer_transfer_fee.maximum_fee.into(), - }]) + .init_token_with_mint( + vec![ExtensionInitializationParams::TransferFeeConfig { + transfer_fee_config_authority: transfer_fee_config_authority.pubkey().into(), + withdraw_withheld_authority: withdraw_withheld_authority.pubkey().into(), + transfer_fee_basis_points: newer_transfer_fee.transfer_fee_basis_points.into(), + maximum_fee: newer_transfer_fee.maximum_fee.into(), + }], + &[], + ) .await .unwrap(); let token = context.token_context.unwrap().token; @@ -670,12 +688,15 @@ async fn set_withdraw_withheld_authority() { } = test_transfer_fee_config_with_keypairs(); let mut context = TestContext::new().await; context - .init_token_with_mint(vec![ExtensionInitializationParams::TransferFeeConfig { - transfer_fee_config_authority: transfer_fee_config_authority.pubkey().into(), - withdraw_withheld_authority: withdraw_withheld_authority.pubkey().into(), - transfer_fee_basis_points: newer_transfer_fee.transfer_fee_basis_points.into(), - maximum_fee: newer_transfer_fee.maximum_fee.into(), - }]) + .init_token_with_mint( + vec![ExtensionInitializationParams::TransferFeeConfig { + transfer_fee_config_authority: transfer_fee_config_authority.pubkey().into(), + withdraw_withheld_authority: withdraw_withheld_authority.pubkey().into(), + transfer_fee_basis_points: newer_transfer_fee.transfer_fee_basis_points.into(), + maximum_fee: newer_transfer_fee.maximum_fee.into(), + }], + &[], + ) .await .unwrap(); let token = context.token_context.unwrap().token; @@ -1236,12 +1257,15 @@ async fn harvest_withheld_tokens_to_mint() { create_and_transfer_to_account(&token, &alice_account, &alice, &alice.pubkey(), amount) .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: TEST_FEE_BASIS_POINTS, - maximum_fee: TEST_MAXIMUM_FEE, - }]) + .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: TEST_FEE_BASIS_POINTS, + maximum_fee: TEST_MAXIMUM_FEE, + }], + &[], + ) .await .unwrap(); let TokenContext { token, .. } = context.token_context.take().unwrap(); @@ -1489,12 +1513,15 @@ async fn withdraw_withheld_tokens_from_mint() { // fail on new mint with mint mismatch context - .init_token_with_mint(vec![ExtensionInitializationParams::TransferFeeConfig { - transfer_fee_config_authority: Some(Pubkey::new_unique()), - withdraw_withheld_authority: Some(withdraw_withheld_authority.pubkey()), - transfer_fee_basis_points: TEST_FEE_BASIS_POINTS, - maximum_fee: TEST_MAXIMUM_FEE, - }]) + .init_token_with_mint( + vec![ExtensionInitializationParams::TransferFeeConfig { + transfer_fee_config_authority: Some(Pubkey::new_unique()), + withdraw_withheld_authority: Some(withdraw_withheld_authority.pubkey()), + transfer_fee_basis_points: TEST_FEE_BASIS_POINTS, + maximum_fee: TEST_MAXIMUM_FEE, + }], + &[], + ) .await .unwrap(); let TokenContext { token, .. } = context.token_context.take().unwrap(); @@ -1607,12 +1634,15 @@ async fn withdraw_withheld_tokens_from_accounts() { create_and_transfer_to_account(&token, &alice_account, &alice, &alice.pubkey(), amount) .await; context - .init_token_with_mint(vec![ExtensionInitializationParams::TransferFeeConfig { - transfer_fee_config_authority: Some(Pubkey::new_unique()), - withdraw_withheld_authority: Some(withdraw_withheld_authority.pubkey()), - transfer_fee_basis_points: TEST_FEE_BASIS_POINTS, - maximum_fee: TEST_MAXIMUM_FEE, - }]) + .init_token_with_mint( + vec![ExtensionInitializationParams::TransferFeeConfig { + transfer_fee_config_authority: Some(Pubkey::new_unique()), + withdraw_withheld_authority: Some(withdraw_withheld_authority.pubkey()), + transfer_fee_basis_points: TEST_FEE_BASIS_POINTS, + maximum_fee: TEST_MAXIMUM_FEE, + }], + &[], + ) .await .unwrap(); let TokenContext { token, .. } = context.token_context.take().unwrap(); diff --git a/token/program-2022-test/tests/transfer_hook.rs b/token/program-2022-test/tests/transfer_hook.rs index 4727f97c091..5248ebf3f49 100644 --- a/token/program-2022-test/tests/transfer_hook.rs +++ b/token/program-2022-test/tests/transfer_hook.rs @@ -219,6 +219,7 @@ async fn setup(mint: Keypair, program_id: &Pubkey, authority: &Pubkey) -> TestCo program_id: Some(*program_id), }], None, + &[], ) .await .unwrap(); @@ -267,6 +268,7 @@ async fn fail_init_all_none() { program_id: None, }], None, + &[], ) .await .unwrap_err(); @@ -519,6 +521,7 @@ async fn fail_transfer_hook_program() { program_id: Some(program_id), }], None, + &[], ) .await .unwrap(); @@ -604,6 +607,7 @@ async fn success_downgrade_writable_and_signer_accounts() { program_id: Some(program_id), }], None, + &[], ) .await .unwrap(); @@ -661,6 +665,7 @@ async fn success_transfers_using_onchain_helper() { program_id: Some(program_id), }], None, + &[], ) .await .unwrap(); @@ -681,6 +686,7 @@ async fn success_transfers_using_onchain_helper() { program_id: Some(program_id), }], None, + &[], ) .await .unwrap();