token-client: clean up useless temp vecs

This commit is contained in:
hanako mumei 2022-10-06 18:32:53 -07:00 committed by hana
parent a5a565b56c
commit 51f5e93e4e
14 changed files with 129 additions and 204 deletions

View File

@ -542,7 +542,7 @@ where
)?, )?,
]; ];
self.process_ixs(&instructions, &vec![account]).await self.process_ixs(&instructions, &[account]).await
} }
/// Get the address for the associated token account. /// Get the address for the associated token account.
@ -616,7 +616,7 @@ where
owner, owner,
)?); )?);
self.process_ixs(&instructions, &vec![account]).await self.process_ixs(&instructions, &[account]).await
} }
/// Retrieve a raw account /// Retrieve a raw account

View File

@ -159,7 +159,7 @@ async fn set_authority() {
&alice_vault, &alice_vault,
&mint_authority.pubkey(), &mint_authority.pubkey(),
1, 1,
&vec![&mint_authority], &[&mint_authority],
) )
.await .await
.expect("failed to mint token"); .expect("failed to mint token");
@ -188,7 +188,7 @@ async fn set_authority() {
&alice_vault, &alice_vault,
&mint_authority.pubkey(), &mint_authority.pubkey(),
2, 2,
&vec![&mint_authority] &[&mint_authority]
) )
.await .await
.is_err()); .is_err());
@ -240,7 +240,7 @@ async fn mint_to() {
&alice_vault, &alice_vault,
&mint_authority.pubkey(), &mint_authority.pubkey(),
mint_amount, mint_amount,
&vec![&mint_authority], &[&mint_authority],
) )
.await .await
.expect("failed to mint token"); .expect("failed to mint token");
@ -287,7 +287,7 @@ async fn transfer() {
&alice_vault, &alice_vault,
&mint_authority.pubkey(), &mint_authority.pubkey(),
mint_amount, mint_amount,
&vec![&mint_authority], &[&mint_authority],
) )
.await .await
.expect("failed to mint token"); .expect("failed to mint token");
@ -299,7 +299,7 @@ async fn transfer() {
&bob_vault, &bob_vault,
&alice.pubkey(), &alice.pubkey(),
transfer_amount, transfer_amount,
&vec![&alice], &[&alice],
) )
.await .await
.expect("failed to transfer"); .expect("failed to transfer");

View File

@ -36,26 +36,26 @@ async fn run_basic(context: TestContext) {
&alice_account, &alice_account,
&mint_authority.pubkey(), &mint_authority.pubkey(),
amount, amount,
&vec![&mint_authority], &[&mint_authority],
) )
.await .await
.unwrap(); .unwrap();
// unchecked is ok // unchecked is ok
token_unchecked token_unchecked
.burn(&alice_account, &alice.pubkey(), 1, &vec![&alice]) .burn(&alice_account, &alice.pubkey(), 1, &[&alice])
.await .await
.unwrap(); .unwrap();
// checked is ok // checked is ok
token token
.burn(&alice_account, &alice.pubkey(), 1, &vec![&alice]) .burn(&alice_account, &alice.pubkey(), 1, &[&alice])
.await .await
.unwrap(); .unwrap();
// burn too much is not ok // burn too much is not ok
let error = token let error = token
.burn(&alice_account, &alice.pubkey(), amount, &vec![&alice]) .burn(&alice_account, &alice.pubkey(), amount, &[&alice])
.await .await
.unwrap_err(); .unwrap_err();
assert_eq!( assert_eq!(
@ -70,7 +70,7 @@ async fn run_basic(context: TestContext) {
// wrong signer // wrong signer
let error = token let error = token
.burn(&alice_account, &bob.pubkey(), 1, &vec![&bob]) .burn(&alice_account, &bob.pubkey(), 1, &[&bob])
.await .await
.unwrap_err(); .unwrap_err();
assert_eq!( assert_eq!(
@ -128,20 +128,20 @@ async fn run_self_owned(context: TestContext) {
&alice_account, &alice_account,
&mint_authority.pubkey(), &mint_authority.pubkey(),
amount, amount,
&vec![&mint_authority], &[&mint_authority],
) )
.await .await
.unwrap(); .unwrap();
// unchecked is ok // unchecked is ok
token_unchecked token_unchecked
.burn(&alice_account, &alice.pubkey(), 1, &vec![&alice]) .burn(&alice_account, &alice.pubkey(), 1, &[&alice])
.await .await
.unwrap(); .unwrap();
// checked is ok // checked is ok
token token
.burn(&alice_account, &alice.pubkey(), 1, &vec![&alice]) .burn(&alice_account, &alice.pubkey(), 1, &[&alice])
.await .await
.unwrap(); .unwrap();
} }
@ -189,7 +189,7 @@ async fn run_burn_and_close_system_or_incinerator(context: TestContext, non_owne
&alice_account, &alice_account,
&mint_authority.pubkey(), &mint_authority.pubkey(),
1, 1,
&vec![&mint_authority], &[&mint_authority],
) )
.await .await
.unwrap(); .unwrap();
@ -207,7 +207,7 @@ async fn run_burn_and_close_system_or_incinerator(context: TestContext, non_owne
&non_owner_account, &non_owner_account,
&alice.pubkey(), &alice.pubkey(),
1, 1,
&vec![&alice], &[&alice],
) )
.await .await
.unwrap(); .unwrap();
@ -235,7 +235,7 @@ async fn run_burn_and_close_system_or_incinerator(context: TestContext, non_owne
// but anyone can burn it // but anyone can burn it
token token
.burn(&non_owner_account, &carlos.pubkey(), 1, &vec![&carlos]) .burn(&non_owner_account, &carlos.pubkey(), 1, &[&carlos])
.await .await
.unwrap(); .unwrap();

View File

@ -182,7 +182,7 @@ impl ConfidentialTokenAccountMeta {
&meta.token_account, &meta.token_account,
&mint_authority.pubkey(), &mint_authority.pubkey(),
amount, amount,
&vec![mint_authority], &[mint_authority],
) )
.await .await
.unwrap(); .unwrap();
@ -494,7 +494,7 @@ async fn ct_deposit() {
&alice_meta.token_account, &alice_meta.token_account,
&mint_authority.pubkey(), &mint_authority.pubkey(),
65537, 65537,
&vec![&mint_authority], &[&mint_authority],
) )
.await .await
.unwrap(); .unwrap();

View File

@ -200,7 +200,7 @@ async fn end_to_end_default_account_state() {
.set_default_account_state( .set_default_account_state(
&mint_authority.pubkey(), &mint_authority.pubkey(),
&AccountState::Uninitialized, &AccountState::Uninitialized,
&vec![&mint_authority], &[&mint_authority],
) )
.await .await
.unwrap_err(); .unwrap_err();
@ -218,7 +218,7 @@ async fn end_to_end_default_account_state() {
.set_default_account_state( .set_default_account_state(
&freeze_authority.pubkey(), &freeze_authority.pubkey(),
&AccountState::Initialized, &AccountState::Initialized,
&vec![&freeze_authority], &[&freeze_authority],
) )
.await .await
.unwrap(); .unwrap();
@ -256,7 +256,7 @@ async fn end_to_end_default_account_state() {
.set_default_account_state( .set_default_account_state(
&mint_authority.pubkey(), &mint_authority.pubkey(),
&AccountState::Frozen, &AccountState::Frozen,
&vec![&mint_authority], &[&mint_authority],
) )
.await .await
.unwrap_err(); .unwrap_err();
@ -274,7 +274,7 @@ async fn end_to_end_default_account_state() {
.set_default_account_state( .set_default_account_state(
&new_authority.pubkey(), &new_authority.pubkey(),
&AccountState::Frozen, &AccountState::Frozen,
&vec![&new_authority], &[&new_authority],
) )
.await .await
.unwrap(); .unwrap();
@ -300,7 +300,7 @@ async fn end_to_end_default_account_state() {
.set_default_account_state( .set_default_account_state(
&new_authority.pubkey(), &new_authority.pubkey(),
&AccountState::Initialized, &AccountState::Initialized,
&vec![&new_authority], &[&new_authority],
) )
.await .await
.unwrap_err(); .unwrap_err();

View File

@ -76,7 +76,7 @@ async fn run_basic(
&alice_account, &alice_account,
&mint_authority.pubkey(), &mint_authority.pubkey(),
amount, amount,
&vec![&mint_authority], &[&mint_authority],
) )
.await .await
.unwrap(); .unwrap();
@ -90,7 +90,7 @@ async fn run_basic(
&bob.pubkey(), &bob.pubkey(),
&alice.pubkey(), &alice.pubkey(),
delegated_amount, delegated_amount,
&vec![&alice], &[&alice],
) )
.await .await
.unwrap(), .unwrap(),
@ -100,7 +100,7 @@ async fn run_basic(
&bob.pubkey(), &bob.pubkey(),
&alice.pubkey(), &alice.pubkey(),
delegated_amount, delegated_amount,
&vec![&alice], &[&alice],
) )
.await .await
.unwrap(), .unwrap(),
@ -113,7 +113,7 @@ async fn run_basic(
&bob_account, &bob_account,
&bob.pubkey(), &bob.pubkey(),
delegated_amount.checked_add(1).unwrap(), delegated_amount.checked_add(1).unwrap(),
&vec![&bob], &[&bob],
) )
.await .await
.unwrap_err(); .unwrap_err();
@ -130,23 +130,23 @@ async fn run_basic(
// transfer is ok // transfer is ok
if transfer_mode == TransferMode::All { if transfer_mode == TransferMode::All {
token_unchecked token_unchecked
.transfer(&alice_account, &bob_account, &bob.pubkey(), 1, &vec![&bob]) .transfer(&alice_account, &bob_account, &bob.pubkey(), 1, &[&bob])
.await .await
.unwrap(); .unwrap();
} }
token token
.transfer(&alice_account, &bob_account, &bob.pubkey(), 1, &vec![&bob]) .transfer(&alice_account, &bob_account, &bob.pubkey(), 1, &[&bob])
.await .await
.unwrap(); .unwrap();
// burn is ok // burn is ok
token_unchecked token_unchecked
.burn(&alice_account, &bob.pubkey(), 1, &vec![&bob]) .burn(&alice_account, &bob.pubkey(), 1, &[&bob])
.await .await
.unwrap(); .unwrap();
token token
.burn(&alice_account, &bob.pubkey(), 1, &vec![&bob]) .burn(&alice_account, &bob.pubkey(), 1, &[&bob])
.await .await
.unwrap(); .unwrap();
@ -158,7 +158,7 @@ async fn run_basic(
&bob_account, &bob_account,
&keypair.pubkey(), &keypair.pubkey(),
1, 1,
&vec![keypair], &[keypair],
) )
.await .await
.unwrap_err(); .unwrap_err();
@ -174,13 +174,13 @@ async fn run_basic(
// revoke // revoke
token token
.revoke(&alice_account, &alice.pubkey(), &vec![&alice]) .revoke(&alice_account, &alice.pubkey(), &[&alice])
.await .await
.unwrap(); .unwrap();
// now fails // now fails
let error = token let error = token
.transfer(&alice_account, &bob_account, &bob.pubkey(), 2, &vec![&bob]) .transfer(&alice_account, &bob_account, &bob.pubkey(), 2, &[&bob])
.await .await
.unwrap_err(); .unwrap_err();
assert_eq!( assert_eq!(

View File

@ -30,22 +30,14 @@ async fn basic() {
assert_eq!(state.base.state, AccountState::Initialized); assert_eq!(state.base.state, AccountState::Initialized);
token token
.freeze( .freeze(&account, &freeze_authority.pubkey(), &[&freeze_authority])
&account,
&freeze_authority.pubkey(),
&vec![&freeze_authority],
)
.await .await
.unwrap(); .unwrap();
let state = token.get_account_info(&account).await.unwrap(); let state = token.get_account_info(&account).await.unwrap();
assert_eq!(state.base.state, AccountState::Frozen); assert_eq!(state.base.state, AccountState::Frozen);
token token
.thaw( .thaw(&account, &freeze_authority.pubkey(), &[&freeze_authority])
&account,
&freeze_authority.pubkey(),
&vec![&freeze_authority],
)
.await .await
.unwrap(); .unwrap();
let state = token.get_account_info(&account).await.unwrap(); let state = token.get_account_info(&account).await.unwrap();

View File

@ -94,11 +94,7 @@ async fn update_rate() {
// correct // correct
let middle_rate = 1_000; let middle_rate = 1_000;
token token
.update_interest_rate( .update_interest_rate(&rate_authority.pubkey(), middle_rate, &[&rate_authority])
&rate_authority.pubkey(),
middle_rate,
&vec![&rate_authority],
)
.await .await
.unwrap(); .unwrap();
let state = token.get_mint_info().await.unwrap(); let state = token.get_mint_info().await.unwrap();
@ -122,7 +118,7 @@ async fn update_rate() {
// update again, pre_update_average_rate is between the two previous // update again, pre_update_average_rate is between the two previous
let new_rate = 2_000; let new_rate = 2_000;
token token
.update_interest_rate(&rate_authority.pubkey(), new_rate, &vec![&rate_authority]) .update_interest_rate(&rate_authority.pubkey(), new_rate, &[&rate_authority])
.await .await
.unwrap(); .unwrap();
let state = token.get_mint_info().await.unwrap(); let state = token.get_mint_info().await.unwrap();
@ -137,7 +133,7 @@ async fn update_rate() {
// wrong signer // wrong signer
let wrong_signer = Keypair::new(); let wrong_signer = Keypair::new();
let err = token let err = token
.update_interest_rate(&wrong_signer.pubkey(), 0, &vec![&wrong_signer]) .update_interest_rate(&wrong_signer.pubkey(), 0, &[&wrong_signer])
.await .await
.unwrap_err(); .unwrap_err();
assert_eq!( assert_eq!(
@ -184,11 +180,11 @@ async fn set_authority() {
Some(new_rate_authority.pubkey()).try_into().unwrap(), Some(new_rate_authority.pubkey()).try_into().unwrap(),
); );
token token
.update_interest_rate(&new_rate_authority.pubkey(), 10, &vec![&new_rate_authority]) .update_interest_rate(&new_rate_authority.pubkey(), 10, &[&new_rate_authority])
.await .await
.unwrap(); .unwrap();
let err = token let err = token
.update_interest_rate(&rate_authority.pubkey(), 100, &vec![&rate_authority]) .update_interest_rate(&rate_authority.pubkey(), 100, &[&rate_authority])
.await .await
.unwrap_err(); .unwrap_err();
assert_eq!( assert_eq!(
@ -218,7 +214,7 @@ async fn set_authority() {
// now all fail // now all fail
let err = token let err = token
.update_interest_rate(&new_rate_authority.pubkey(), 50, &vec![&new_rate_authority]) .update_interest_rate(&new_rate_authority.pubkey(), 50, &[&new_rate_authority])
.await .await
.unwrap_err(); .unwrap_err();
assert_eq!( assert_eq!(
@ -231,7 +227,7 @@ async fn set_authority() {
))) )))
); );
let err = token let err = token
.update_interest_rate(&rate_authority.pubkey(), 5, &vec![&rate_authority]) .update_interest_rate(&rate_authority.pubkey(), 5, &[&rate_authority])
.await .await
.unwrap_err(); .unwrap_err();
assert_eq!( assert_eq!(

View File

@ -43,14 +43,14 @@ async fn test_memo_transfers(
&alice_account, &alice_account,
&mint_authority.pubkey(), &mint_authority.pubkey(),
4242, 4242,
&vec![&mint_authority], &[&mint_authority],
) )
.await .await
.unwrap(); .unwrap();
// require memo transfers into bob_account // require memo transfers into bob_account
token token
.enable_required_transfer_memos(&bob_account, &bob.pubkey(), &vec![&bob]) .enable_required_transfer_memos(&bob_account, &bob.pubkey(), &[&bob])
.await .await
.unwrap(); .unwrap();
@ -60,13 +60,7 @@ async fn test_memo_transfers(
// attempt to transfer from alice to bob without memo // attempt to transfer from alice to bob without memo
let err = token let err = token
.transfer( .transfer(&alice_account, &bob_account, &alice.pubkey(), 10, &[&alice])
&alice_account,
&bob_account,
&alice.pubkey(),
10,
&vec![&alice],
)
.await .await
.unwrap_err(); .unwrap_err();
assert_eq!( assert_eq!(
@ -129,13 +123,7 @@ async fn test_memo_transfers(
// transfer with memo // transfer with memo
token token
.with_memo("🦖", vec![alice.pubkey()]) .with_memo("🦖", vec![alice.pubkey()])
.transfer( .transfer(&alice_account, &bob_account, &alice.pubkey(), 10, &[&alice])
&alice_account,
&bob_account,
&alice.pubkey(),
10,
&vec![&alice],
)
.await .await
.unwrap(); .unwrap();
let bob_state = token.get_account_info(&bob_account).await.unwrap(); let bob_state = token.get_account_info(&bob_account).await.unwrap();
@ -170,19 +158,13 @@ async fn test_memo_transfers(
// stop requiring memo transfers into bob_account // stop requiring memo transfers into bob_account
token token
.disable_required_transfer_memos(&bob_account, &bob.pubkey(), &vec![&bob]) .disable_required_transfer_memos(&bob_account, &bob.pubkey(), &[&bob])
.await .await
.unwrap(); .unwrap();
// transfer from alice to bob without memo // transfer from alice to bob without memo
token token
.transfer( .transfer(&alice_account, &bob_account, &alice.pubkey(), 12, &[&alice])
&alice_account,
&bob_account,
&alice.pubkey(),
12,
&vec![&alice],
)
.await .await
.unwrap(); .unwrap();
let bob_state = token.get_account_info(&bob_account).await.unwrap(); let bob_state = token.get_account_info(&bob_account).await.unwrap();
@ -241,7 +223,7 @@ async fn require_memo_transfers_with_realloc() {
&token_context.bob.pubkey(), &token_context.bob.pubkey(),
&token_context.bob.pubkey(), &token_context.bob.pubkey(),
&[ExtensionType::MemoTransfer], &[ExtensionType::MemoTransfer],
&vec![&token_context.bob], &[&token_context.bob],
) )
.await .await
.unwrap(); .unwrap();

View File

@ -258,12 +258,7 @@ async fn fail_close_with_supply() {
.unwrap(); .unwrap();
let account = account.pubkey(); let account = account.pubkey();
token token
.mint_to( .mint_to(&account, &mint_authority.pubkey(), 1, &[&mint_authority])
&account,
&mint_authority.pubkey(),
1,
&vec![&mint_authority],
)
.await .await
.unwrap(); .unwrap();

View File

@ -55,7 +55,7 @@ async fn transfer_checked() {
&alice_account, &alice_account,
&mint_authority.pubkey(), &mint_authority.pubkey(),
test_transfer_amount, test_transfer_amount,
&vec![&mint_authority], &[&mint_authority],
) )
.await .await
.unwrap_err(); .unwrap_err();
@ -76,7 +76,7 @@ async fn transfer_checked() {
&bob_account, &bob_account,
&mint_authority.pubkey(), &mint_authority.pubkey(),
test_transfer_amount, test_transfer_amount,
&vec![&mint_authority], &[&mint_authority],
) )
.await .await
.unwrap(); .unwrap();
@ -88,7 +88,7 @@ async fn transfer_checked() {
&bob_account, &bob_account,
&bob.pubkey(), &bob.pubkey(),
test_transfer_amount, test_transfer_amount,
&vec![&bob], &[&bob],
) )
.await .await
.unwrap_err(); .unwrap_err();
@ -110,7 +110,7 @@ async fn transfer_checked() {
&alice_account, &alice_account,
&bob.pubkey(), &bob.pubkey(),
test_transfer_amount, test_transfer_amount,
&vec![&bob], &[&bob],
) )
.await .await
.unwrap_err(); .unwrap_err();
@ -189,7 +189,7 @@ async fn transfer_checked_with_fee() {
&alice_account, &alice_account,
&mint_authority.pubkey(), &mint_authority.pubkey(),
test_transfer_amount, test_transfer_amount,
&vec![&mint_authority], &[&mint_authority],
) )
.await .await
.unwrap(); .unwrap();
@ -201,7 +201,7 @@ async fn transfer_checked_with_fee() {
&alice_account, &alice_account,
&alice.pubkey(), &alice.pubkey(),
test_transfer_amount, test_transfer_amount,
&vec![&alice], &[&alice],
) )
.await .await
.unwrap_err(); .unwrap_err();
@ -223,7 +223,7 @@ async fn transfer_checked_with_fee() {
&bob_account, &bob_account,
&alice.pubkey(), &alice.pubkey(),
test_transfer_amount, test_transfer_amount,
&vec![&alice], &[&alice],
) )
.await .await
.unwrap_err(); .unwrap_err();
@ -247,7 +247,7 @@ async fn transfer_checked_with_fee() {
&alice.pubkey(), &alice.pubkey(),
test_transfer_amount, test_transfer_amount,
fee, fee,
&vec![&alice], &[&alice],
) )
.await .await
.unwrap_err(); .unwrap_err();
@ -271,7 +271,7 @@ async fn transfer_checked_with_fee() {
&alice.pubkey(), &alice.pubkey(),
test_transfer_amount, test_transfer_amount,
fee, fee,
&vec![&alice], &[&alice],
) )
.await .await
.unwrap_err(); .unwrap_err();

View File

@ -30,7 +30,7 @@ async fn reallocate() {
token.get_address(), token.get_address(),
&mint_authority.pubkey(), &mint_authority.pubkey(),
&[ExtensionType::ImmutableOwner], &[ExtensionType::ImmutableOwner],
&vec![&mint_authority], &[&mint_authority],
) )
.await .await
.unwrap_err(); .unwrap_err();
@ -55,7 +55,7 @@ async fn reallocate() {
&alice_account, &alice_account,
&alice.pubkey(), &alice.pubkey(),
&[ExtensionType::MintCloseAuthority], &[ExtensionType::MintCloseAuthority],
&vec![&alice], &[&alice],
) )
.await .await
.unwrap_err(); .unwrap_err();
@ -75,7 +75,7 @@ async fn reallocate() {
&alice_account, &alice_account,
&mint_authority.pubkey(), &mint_authority.pubkey(),
&[ExtensionType::ImmutableOwner], &[ExtensionType::ImmutableOwner],
&vec![&mint_authority], &[&mint_authority],
) )
.await .await
.unwrap_err(); .unwrap_err();
@ -95,7 +95,7 @@ async fn reallocate() {
&alice_account, &alice_account,
&alice.pubkey(), &alice.pubkey(),
&[ExtensionType::ImmutableOwner], &[ExtensionType::ImmutableOwner],
&vec![&alice], &[&alice],
) )
.await .await
.unwrap(); .unwrap();
@ -112,7 +112,7 @@ async fn reallocate() {
&alice_account, &alice_account,
&alice.pubkey(), &alice.pubkey(),
&[ExtensionType::ImmutableOwner], &[ExtensionType::ImmutableOwner],
&vec![&alice], &[&alice],
) )
.await .await
.unwrap(); .unwrap();
@ -133,7 +133,7 @@ async fn reallocate() {
ExtensionType::TransferFeeAmount, ExtensionType::TransferFeeAmount,
ExtensionType::TransferFeeAmount, ExtensionType::TransferFeeAmount,
], ],
&vec![&alice], &[&alice],
) )
.await .await
.unwrap(); .unwrap();
@ -175,7 +175,7 @@ async fn reallocate_without_current_extension_knowledge() {
&alice_account, &alice_account,
&alice.pubkey(), &alice.pubkey(),
&[ExtensionType::ImmutableOwner], &[ExtensionType::ImmutableOwner],
&vec![&alice], &[&alice],
) )
.await .await
.unwrap(); .unwrap();

View File

@ -48,7 +48,7 @@ async fn run_basic_transfers(context: TestContext, test_mode: TestMode) {
&alice_account, &alice_account,
&mint_authority.pubkey(), &mint_authority.pubkey(),
amount, amount,
&vec![&mint_authority], &[&mint_authority],
) )
.await .await
.unwrap(); .unwrap();
@ -56,26 +56,14 @@ async fn run_basic_transfers(context: TestContext, test_mode: TestMode) {
if test_mode == TestMode::All { if test_mode == TestMode::All {
// unchecked is ok // unchecked is ok
token_unchecked token_unchecked
.transfer( .transfer(&alice_account, &bob_account, &alice.pubkey(), 1, &[&alice])
&alice_account,
&bob_account,
&alice.pubkey(),
1,
&vec![&alice],
)
.await .await
.unwrap(); .unwrap();
} }
// checked is ok // checked is ok
token token
.transfer( .transfer(&alice_account, &bob_account, &alice.pubkey(), 1, &[&alice])
&alice_account,
&bob_account,
&alice.pubkey(),
1,
&vec![&alice],
)
.await .await
.unwrap(); .unwrap();
@ -86,7 +74,7 @@ async fn run_basic_transfers(context: TestContext, test_mode: TestMode) {
&bob_account, &bob_account,
&alice.pubkey(), &alice.pubkey(),
amount, amount,
&vec![&alice], &[&alice],
) )
.await .await
.unwrap_err(); .unwrap_err();
@ -102,7 +90,7 @@ async fn run_basic_transfers(context: TestContext, test_mode: TestMode) {
// wrong signer // wrong signer
let error = token let error = token
.transfer(&alice_account, &bob_account, &bob.pubkey(), 1, &vec![&bob]) .transfer(&alice_account, &bob_account, &bob.pubkey(), 1, &[&bob])
.await .await
.unwrap_err(); .unwrap_err();
assert_eq!( assert_eq!(
@ -161,7 +149,7 @@ async fn run_self_transfers(context: TestContext, test_mode: TestMode) {
&alice_account, &alice_account,
&mint_authority.pubkey(), &mint_authority.pubkey(),
amount, amount,
&vec![&mint_authority], &[&mint_authority],
) )
.await .await
.unwrap(); .unwrap();
@ -173,7 +161,7 @@ async fn run_self_transfers(context: TestContext, test_mode: TestMode) {
&alice_account, &alice_account,
&alice.pubkey(), &alice.pubkey(),
1, 1,
&vec![&alice], &[&alice],
) )
.await .await
.unwrap(); .unwrap();
@ -184,7 +172,7 @@ async fn run_self_transfers(context: TestContext, test_mode: TestMode) {
&alice_account, &alice_account,
&alice.pubkey(), &alice.pubkey(),
1, 1,
&vec![&alice], &[&alice],
) )
.await .await
.unwrap(); .unwrap();
@ -197,7 +185,7 @@ async fn run_self_transfers(context: TestContext, test_mode: TestMode) {
&alice_account, &alice_account,
&alice.pubkey(), &alice.pubkey(),
amount.checked_add(1).unwrap(), amount.checked_add(1).unwrap(),
&vec![&alice], &[&alice],
) )
.await .await
.unwrap_err(); .unwrap_err();
@ -263,7 +251,7 @@ async fn run_self_owned(context: TestContext, test_mode: TestMode) {
&alice_account, &alice_account,
&mint_authority.pubkey(), &mint_authority.pubkey(),
amount, amount,
&vec![&mint_authority], &[&mint_authority],
) )
.await .await
.unwrap(); .unwrap();
@ -271,26 +259,14 @@ async fn run_self_owned(context: TestContext, test_mode: TestMode) {
if test_mode == TestMode::All { if test_mode == TestMode::All {
// unchecked is ok // unchecked is ok
token_unchecked token_unchecked
.transfer( .transfer(&alice_account, &bob_account, &alice.pubkey(), 1, &[&alice])
&alice_account,
&bob_account,
&alice.pubkey(),
1,
&vec![&alice],
)
.await .await
.unwrap(); .unwrap();
} }
// checked is ok // checked is ok
token token
.transfer( .transfer(&alice_account, &bob_account, &alice.pubkey(), 1, &[&alice])
&alice_account,
&bob_account,
&alice.pubkey(),
1,
&vec![&alice],
)
.await .await
.unwrap(); .unwrap();
@ -301,7 +277,7 @@ async fn run_self_owned(context: TestContext, test_mode: TestMode) {
&alice_account, &alice_account,
&alice.pubkey(), &alice.pubkey(),
1, 1,
&vec![&alice], &[&alice],
) )
.await .await
.unwrap(); .unwrap();
@ -361,7 +337,7 @@ async fn transfer_with_fee_on_mint_without_fee_configured() {
&alice_account, &alice_account,
&mint_authority.pubkey(), &mint_authority.pubkey(),
amount, amount,
&vec![&mint_authority], &[&mint_authority],
) )
.await .await
.unwrap(); .unwrap();
@ -374,7 +350,7 @@ async fn transfer_with_fee_on_mint_without_fee_configured() {
&alice.pubkey(), &alice.pubkey(),
1, 1,
0, 0,
&vec![&alice], &[&alice],
) )
.await .await
.unwrap(); .unwrap();
@ -387,7 +363,7 @@ async fn transfer_with_fee_on_mint_without_fee_configured() {
&alice.pubkey(), &alice.pubkey(),
2, 2,
1, 1,
&vec![&alice], &[&alice],
) )
.await .await
.unwrap_err(); .unwrap_err();

View File

@ -136,7 +136,7 @@ async fn create_mint_with_accounts(alice_amount: u64) -> TokenWithAccounts {
&alice_account, &alice_account,
&mint_authority.pubkey(), &mint_authority.pubkey(),
alice_amount, alice_amount,
&vec![&mint_authority], &[&mint_authority],
) )
.await .await
.unwrap(); .unwrap();
@ -296,7 +296,7 @@ async fn set_fee() {
&transfer_fee_config_authority.pubkey(), &transfer_fee_config_authority.pubkey(),
new_transfer_fee_basis_points, new_transfer_fee_basis_points,
new_maximum_fee, new_maximum_fee,
&vec![&transfer_fee_config_authority], &[&transfer_fee_config_authority],
) )
.await .await
.unwrap(); .unwrap();
@ -320,7 +320,7 @@ async fn set_fee() {
&transfer_fee_config_authority.pubkey(), &transfer_fee_config_authority.pubkey(),
new_transfer_fee_basis_points, new_transfer_fee_basis_points,
new_maximum_fee, new_maximum_fee,
&vec![&transfer_fee_config_authority], &[&transfer_fee_config_authority],
) )
.await .await
.unwrap(); .unwrap();
@ -350,7 +350,7 @@ async fn set_fee() {
&transfer_fee_config_authority.pubkey(), &transfer_fee_config_authority.pubkey(),
new_transfer_fee_basis_points, new_transfer_fee_basis_points,
new_maximum_fee, new_maximum_fee,
&vec![&transfer_fee_config_authority], &[&transfer_fee_config_authority],
) )
.await .await
.unwrap(); .unwrap();
@ -381,7 +381,7 @@ async fn set_fee() {
&transfer_fee_config_authority.pubkey(), &transfer_fee_config_authority.pubkey(),
new_transfer_fee_basis_points, new_transfer_fee_basis_points,
new_maximum_fee, new_maximum_fee,
&vec![&transfer_fee_config_authority], &[&transfer_fee_config_authority],
) )
.await .await
.unwrap(); .unwrap();
@ -403,7 +403,7 @@ async fn set_fee() {
&withdraw_withheld_authority.pubkey(), &withdraw_withheld_authority.pubkey(),
new_transfer_fee_basis_points, new_transfer_fee_basis_points,
new_maximum_fee, new_maximum_fee,
&vec![&withdraw_withheld_authority], &[&withdraw_withheld_authority],
) )
.await .await
.err() .err()
@ -424,7 +424,7 @@ async fn set_fee() {
&transfer_fee_config_authority.pubkey(), &transfer_fee_config_authority.pubkey(),
MAX_FEE_BASIS_POINTS + 1, MAX_FEE_BASIS_POINTS + 1,
new_maximum_fee, new_maximum_fee,
&vec![&transfer_fee_config_authority], &[&transfer_fee_config_authority],
) )
.await .await
.err() .err()
@ -456,7 +456,7 @@ async fn fail_unsupported_mint() {
&mint_authority.pubkey(), &mint_authority.pubkey(),
transfer_fee_basis_points, transfer_fee_basis_points,
maximum_fee, maximum_fee,
&vec![&mint_authority], &[&mint_authority],
) )
.await .await
.err() .err()
@ -482,7 +482,7 @@ async fn fail_unsupported_mint() {
.withdraw_withheld_tokens_from_mint( .withdraw_withheld_tokens_from_mint(
&Pubkey::new_unique(), &Pubkey::new_unique(),
&mint_authority.pubkey(), &mint_authority.pubkey(),
&vec![&mint_authority], &[&mint_authority],
) )
.await .await
.err() .err()
@ -567,7 +567,7 @@ async fn set_transfer_fee_config_authority() {
&transfer_fee_config_authority.pubkey(), &transfer_fee_config_authority.pubkey(),
transfer_fee_basis_points, transfer_fee_basis_points,
maximum_fee, maximum_fee,
&vec![&transfer_fee_config_authority], &[&transfer_fee_config_authority],
) )
.await .await
.unwrap_err(); .unwrap_err();
@ -585,7 +585,7 @@ async fn set_transfer_fee_config_authority() {
&new_authority.pubkey(), &new_authority.pubkey(),
transfer_fee_basis_points, transfer_fee_basis_points,
maximum_fee, maximum_fee,
&vec![&new_authority], &[&new_authority],
) )
.await .await
.unwrap(); .unwrap();
@ -635,7 +635,7 @@ async fn set_transfer_fee_config_authority() {
&transfer_fee_config_authority.pubkey(), &transfer_fee_config_authority.pubkey(),
0, 0,
0, 0,
&vec![&transfer_fee_config_authority], &[&transfer_fee_config_authority],
) )
.await .await
.unwrap_err(); .unwrap_err();
@ -726,7 +726,7 @@ async fn set_withdraw_withheld_authority() {
&account, &account,
&new_authority.pubkey(), &new_authority.pubkey(),
&[&account], &[&account],
&vec![&new_authority], &[&new_authority],
) )
.await .await
.unwrap(); .unwrap();
@ -736,7 +736,7 @@ async fn set_withdraw_withheld_authority() {
&account, &account,
&withdraw_withheld_authority.pubkey(), &withdraw_withheld_authority.pubkey(),
&[&account], &[&account],
&vec![&withdraw_withheld_authority], &[&withdraw_withheld_authority],
) )
.await .await
.unwrap_err(); .unwrap_err();
@ -801,7 +801,7 @@ async fn set_withdraw_withheld_authority() {
&account, &account,
&withdraw_withheld_authority.pubkey(), &withdraw_withheld_authority.pubkey(),
&[&account], &[&account],
&vec![&withdraw_withheld_authority], &[&withdraw_withheld_authority],
) )
.await .await
.unwrap_err(); .unwrap_err();
@ -819,7 +819,7 @@ async fn set_withdraw_withheld_authority() {
&account, &account,
&new_authority.pubkey(), &new_authority.pubkey(),
&[&account], &[&account],
&vec![&new_authority], &[&new_authority],
) )
.await .await
.unwrap_err(); .unwrap_err();
@ -855,7 +855,7 @@ async fn transfer_checked() {
&bob_account, &bob_account,
&alice.pubkey(), &alice.pubkey(),
maximum_fee, maximum_fee,
&vec![&alice], &[&alice],
) )
.await .await
.unwrap_err(); .unwrap_err();
@ -876,7 +876,7 @@ async fn transfer_checked() {
&bob_account, &bob_account,
&alice.pubkey(), &alice.pubkey(),
alice_amount + 1, alice_amount + 1,
&vec![&alice], &[&alice],
) )
.await .await
.unwrap_err(); .unwrap_err();
@ -903,7 +903,7 @@ async fn transfer_checked() {
&bob_account, &bob_account,
&alice.pubkey(), &alice.pubkey(),
maximum_fee, maximum_fee,
&vec![&alice], &[&alice],
) )
.await .await
.unwrap(); .unwrap();
@ -931,7 +931,7 @@ async fn transfer_checked() {
&bob_account, &bob_account,
&alice.pubkey(), &alice.pubkey(),
transfer_amount, transfer_amount,
&vec![&alice], &[&alice],
) )
.await .await
.unwrap(); .unwrap();
@ -964,7 +964,7 @@ async fn transfer_checked() {
&bob_account, &bob_account,
&alice.pubkey(), &alice.pubkey(),
transfer_amount, transfer_amount,
&vec![&alice], &[&alice],
) )
.await .await
.unwrap(); .unwrap();
@ -987,7 +987,7 @@ async fn transfer_checked() {
&bob_account, &bob_account,
&alice.pubkey(), &alice.pubkey(),
alice_amount - 1, alice_amount - 1,
&vec![&alice], &[&alice],
) )
.await .await
.unwrap(); .unwrap();
@ -1005,13 +1005,7 @@ async fn transfer_checked() {
// final transfer, only move tokens to withheld amount, nothing received // final transfer, only move tokens to withheld amount, nothing received
token token
.transfer( .transfer(&alice_account, &bob_account, &alice.pubkey(), 1, &[&alice])
&alice_account,
&bob_account,
&alice.pubkey(),
1,
&vec![&alice],
)
.await .await
.unwrap(); .unwrap();
withheld_amount += 1; withheld_amount += 1;
@ -1051,7 +1045,7 @@ async fn transfer_checked_with_fee() {
&alice.pubkey(), &alice.pubkey(),
transfer_amount, transfer_amount,
fee, fee,
&vec![&alice], &[&alice],
) )
.await .await
.unwrap_err(); .unwrap_err();
@ -1077,7 +1071,7 @@ async fn transfer_checked_with_fee() {
&alice.pubkey(), &alice.pubkey(),
transfer_amount, transfer_amount,
fee, fee,
&vec![&alice], &[&alice],
) )
.await .await
.unwrap_err(); .unwrap_err();
@ -1103,7 +1097,7 @@ async fn transfer_checked_with_fee() {
&alice.pubkey(), &alice.pubkey(),
alice_amount + 1, alice_amount + 1,
fee, fee,
&vec![&alice], &[&alice],
) )
.await .await
.unwrap_err(); .unwrap_err();
@ -1128,7 +1122,7 @@ async fn transfer_checked_with_fee() {
&alice.pubkey(), &alice.pubkey(),
transfer_amount, transfer_amount,
fee, fee,
&vec![&alice], &[&alice],
) )
.await .await
.unwrap(); .unwrap();
@ -1163,7 +1157,7 @@ async fn no_fees_from_self_transfer() {
&alice.pubkey(), &alice.pubkey(),
amount, amount,
fee, fee,
&vec![&alice], &[&alice],
) )
.await .await
.unwrap(); .unwrap();
@ -1187,13 +1181,7 @@ async fn create_and_transfer_to_account(
.unwrap(); .unwrap();
let account = account.pubkey(); let account = account.pubkey();
token token
.transfer( .transfer(source, &account, &authority.pubkey(), amount, &[authority])
source,
&account,
&authority.pubkey(),
amount,
&vec![authority],
)
.await .await
.unwrap(); .unwrap();
account account
@ -1335,7 +1323,7 @@ async fn max_withdraw_withheld_tokens_from_accounts() {
&destination, &destination,
&withdraw_withheld_authority.pubkey(), &withdraw_withheld_authority.pubkey(),
&accounts, &accounts,
&vec![&withdraw_withheld_authority], &[&withdraw_withheld_authority],
) )
.await .await
.unwrap(); .unwrap();
@ -1369,7 +1357,7 @@ async fn withdraw_withheld_tokens_from_mint() {
.withdraw_withheld_tokens_from_mint( .withdraw_withheld_tokens_from_mint(
&alice_account, &alice_account,
&withdraw_withheld_authority.pubkey(), &withdraw_withheld_authority.pubkey(),
&vec![&withdraw_withheld_authority], &[&withdraw_withheld_authority],
) )
.await .await
.unwrap(); .unwrap();
@ -1405,7 +1393,7 @@ async fn withdraw_withheld_tokens_from_mint() {
.withdraw_withheld_tokens_from_mint( .withdraw_withheld_tokens_from_mint(
&bob_account, &bob_account,
&withdraw_withheld_authority.pubkey(), &withdraw_withheld_authority.pubkey(),
&vec![&withdraw_withheld_authority], &[&withdraw_withheld_authority],
) )
.await .await
.unwrap(); .unwrap();
@ -1420,7 +1408,7 @@ async fn withdraw_withheld_tokens_from_mint() {
// fail wrong signer // fail wrong signer
let error = token let error = token
.withdraw_withheld_tokens_from_mint(&alice_account, &alice.pubkey(), &vec![&alice]) .withdraw_withheld_tokens_from_mint(&alice_account, &alice.pubkey(), &[&alice])
.await .await
.unwrap_err(); .unwrap_err();
assert_eq!( assert_eq!(
@ -1438,18 +1426,14 @@ async fn withdraw_withheld_tokens_from_mint() {
create_and_transfer_to_account(&token, &alice_account, &alice, &alice.pubkey(), amount) create_and_transfer_to_account(&token, &alice_account, &alice, &alice.pubkey(), amount)
.await; .await;
token token
.freeze( .freeze(&account, &freeze_authority.pubkey(), &[&freeze_authority])
&account,
&freeze_authority.pubkey(),
&vec![&freeze_authority],
)
.await .await
.unwrap(); .unwrap();
let error = token let error = token
.withdraw_withheld_tokens_from_mint( .withdraw_withheld_tokens_from_mint(
&account, &account,
&withdraw_withheld_authority.pubkey(), &withdraw_withheld_authority.pubkey(),
&vec![&withdraw_withheld_authority], &[&withdraw_withheld_authority],
) )
.await .await
.unwrap_err(); .unwrap_err();
@ -1481,7 +1465,7 @@ async fn withdraw_withheld_tokens_from_mint() {
.withdraw_withheld_tokens_from_mint( .withdraw_withheld_tokens_from_mint(
&account, &account,
&withdraw_withheld_authority.pubkey(), &withdraw_withheld_authority.pubkey(),
&vec![&withdraw_withheld_authority], &[&withdraw_withheld_authority],
) )
.await .await
.unwrap_err(); .unwrap_err();
@ -1510,7 +1494,7 @@ async fn withdraw_withheld_tokens_from_mint() {
.withdraw_withheld_tokens_from_mint( .withdraw_withheld_tokens_from_mint(
&account, &account,
&withdraw_withheld_authority.pubkey(), &withdraw_withheld_authority.pubkey(),
&vec![&withdraw_withheld_authority], &[&withdraw_withheld_authority],
) )
.await .await
.unwrap_err(); .unwrap_err();
@ -1545,7 +1529,7 @@ async fn withdraw_withheld_tokens_from_accounts() {
&alice_account, &alice_account,
&wrong_signer.pubkey(), &wrong_signer.pubkey(),
&[], &[],
&vec![&wrong_signer], &[&wrong_signer],
) )
.await .await
.unwrap_err(); .unwrap_err();
@ -1565,7 +1549,7 @@ async fn withdraw_withheld_tokens_from_accounts() {
&alice_account, &alice_account,
&withdraw_withheld_authority.pubkey(), &withdraw_withheld_authority.pubkey(),
&[], &[],
&vec![&withdraw_withheld_authority], &[&withdraw_withheld_authority],
) )
.await .await
.unwrap(); .unwrap();
@ -1581,7 +1565,7 @@ async fn withdraw_withheld_tokens_from_accounts() {
&account, &account,
&withdraw_withheld_authority.pubkey(), &withdraw_withheld_authority.pubkey(),
&[&account], &[&account],
&vec![&withdraw_withheld_authority], &[&withdraw_withheld_authority],
) )
.await .await
.unwrap(); .unwrap();
@ -1598,7 +1582,7 @@ async fn withdraw_withheld_tokens_from_accounts() {
&alice_account, &alice_account,
&withdraw_withheld_authority.pubkey(), &withdraw_withheld_authority.pubkey(),
&[&account], &[&account],
&vec![&withdraw_withheld_authority], &[&withdraw_withheld_authority],
) )
.await .await
.unwrap(); .unwrap();
@ -1635,7 +1619,7 @@ async fn withdraw_withheld_tokens_from_accounts() {
&withdraw_account, &withdraw_account,
&withdraw_withheld_authority.pubkey(), &withdraw_withheld_authority.pubkey(),
&[&account], &[&account],
&vec![&withdraw_withheld_authority], &[&withdraw_withheld_authority],
) )
.await .await
.unwrap(); .unwrap();
@ -1649,7 +1633,7 @@ async fn withdraw_withheld_tokens_from_accounts() {
&account, &account,
&withdraw_withheld_authority.pubkey(), &withdraw_withheld_authority.pubkey(),
&[&withdraw_account], &[&withdraw_account],
&vec![&withdraw_withheld_authority], &[&withdraw_withheld_authority],
) )
.await .await
.unwrap_err(); .unwrap_err();
@ -1689,7 +1673,7 @@ async fn fail_close_with_withheld() {
&alice_account, &alice_account,
&alice.pubkey(), &alice.pubkey(),
amount - fee, amount - fee,
&vec![&alice], &[&alice],
) )
.await .await
.unwrap(); .unwrap();