Skip to content

Commit

Permalink
Update tests with missing mut signer attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
losman0s committed Feb 7, 2022
1 parent 2103e2b commit 74086b6
Show file tree
Hide file tree
Showing 12 changed files with 82 additions and 103 deletions.
6 changes: 2 additions & 4 deletions tests/cashiers-check/programs/cashiers-check/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,7 @@ pub struct CashCheck<'info> {
check_signer: AccountInfo<'info>,
#[account(mut, has_one = owner)]
to: Account<'info, TokenAccount>,
#[account(signer)]
owner: AccountInfo<'info>,
owner: Signer<'info>,
token_program: AccountInfo<'info>,
}

Expand All @@ -148,8 +147,7 @@ pub struct CancelCheck<'info> {
check_signer: AccountInfo<'info>,
#[account(mut, has_one = owner)]
from: Account<'info, TokenAccount>,
#[account(signer)]
owner: AccountInfo<'info>,
owner: Signer<'info>,
token_program: AccountInfo<'info>,
}

Expand Down
2 changes: 2 additions & 0 deletions tests/cfo/programs/cfo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@ pub struct CreateOfficer<'info> {
token::authority = officer,
)]
treasury: Box<Account<'info, TokenAccount>>,
#[account(mut)]
authority: Signer<'info>,
#[cfg_attr(
not(feature = "test"),
Expand Down Expand Up @@ -393,6 +394,7 @@ pub struct AuthorizeMarket<'info> {
bump,
)]
market_auth: Account<'info, MarketAuth>,
#[account(mut)]
payer: Signer<'info>,
// Not read or written to so not validated.
market: UncheckedAccount<'info>,
Expand Down
7 changes: 3 additions & 4 deletions tests/chat/programs/chat/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ pub struct CreateUser<'info> {
space = 320,
)]
user: Account<'info, User>,
#[account(signer)]
authority: AccountInfo<'info>,
#[account(mut)]
authority: Signer<'info>,
system_program: AccountInfo<'info>,
}

Expand All @@ -68,8 +68,7 @@ pub struct SendMessage<'info> {
has_one = authority,
)]
user: Account<'info, User>,
#[account(signer)]
authority: AccountInfo<'info>,
authority: Signer<'info>,
#[account(mut)]
chat_room: Loader<'info, ChatRoom>,
}
Expand Down
3 changes: 1 addition & 2 deletions tests/errors/programs/errors/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ pub struct HasOneError<'info> {

#[derive(Accounts)]
pub struct SignerError<'info> {
#[account(signer)]
my_account: AccountInfo<'info>,
my_account: Signer<'info>,
}

#[account]
Expand Down
2 changes: 1 addition & 1 deletion tests/errors/tests/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ describe("errors", () => {
assert.ok(false);
} catch (err) {
const errMsg =
"Error: failed to send transaction: Transaction simulation failed: Error processing Instruction 0: custom program error: 0x7d2";
"Error: failed to send transaction: Transaction simulation failed: Error processing Instruction 0: custom program error: 0xbc2";
assert.equal(err.toString(), errMsg);
}
});
Expand Down
6 changes: 3 additions & 3 deletions tests/escrow/programs/escrow/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ pub mod escrow {
#[derive(Accounts)]
#[instruction(initializer_amount: u64)]
pub struct InitializeEscrow<'info> {
#[account(signer)]
pub initializer: AccountInfo<'info>,
#[account(mut)]
pub initializer: Signer<'info>,
#[account(
mut,
constraint = initializer_deposit_token_account.amount >= initializer_amount
Expand Down Expand Up @@ -181,7 +181,7 @@ impl<'info> From<&mut InitializeEscrow<'info>>
.initializer_deposit_token_account
.to_account_info()
.clone(),
current_authority: accounts.initializer.clone(),
current_authority: accounts.initializer.to_account_info().clone(),
};
let cpi_program = accounts.token_program.to_account_info();
CpiContext::new(cpi_program, cpi_accounts)
Expand Down
6 changes: 2 additions & 4 deletions tests/lockup/programs/lockup/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,7 @@ pub struct Withdraw<'info> {
// Vesting.
#[account(mut, has_one = beneficiary, has_one = vault)]
vesting: Account<'info, Vesting>,
#[account(signer)]
beneficiary: AccountInfo<'info>,
beneficiary: Signer<'info>,
#[account(mut)]
vault: Account<'info, TokenAccount>,
#[account(
Expand Down Expand Up @@ -281,8 +280,7 @@ pub struct WhitelistDeposit<'info> {
#[derive(Accounts)]
pub struct WhitelistTransfer<'info> {
lockup: ProgramState<'info, Lockup>,
#[account(signer)]
beneficiary: AccountInfo<'info>,
beneficiary: Signer<'info>,
whitelisted_program: AccountInfo<'info>,

// Whitelist interface.
Expand Down
47 changes: 16 additions & 31 deletions tests/lockup/programs/registry/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -596,8 +596,7 @@ impl<'info> Initialize<'info> {
pub struct UpdateRegistrar<'info> {
#[account(mut, has_one = authority)]
registrar: Account<'info, Registrar>,
#[account(signer)]
authority: AccountInfo<'info>,
authority: Signer<'info>,
}

#[derive(Accounts)]
Expand All @@ -607,8 +606,7 @@ pub struct CreateMember<'info> {
// Member.
#[account(zero)]
member: Box<Account<'info, Member>>,
#[account(signer)]
beneficiary: AccountInfo<'info>,
beneficiary: Signer<'info>,
#[account(
"&balances.spt.owner == member_signer.key",
"balances.spt.mint == registrar.pool_mint",
Expand Down Expand Up @@ -672,8 +670,7 @@ pub struct Ctor<'info> {

#[derive(Accounts)]
pub struct SetLockupProgram<'info> {
#[account(signer)]
authority: AccountInfo<'info>,
authority: Signer<'info>,
}

#[derive(Accounts)]
Expand All @@ -691,17 +688,15 @@ pub struct IsRealized<'info> {
pub struct UpdateMember<'info> {
#[account(mut, has_one = beneficiary)]
member: Account<'info, Member>,
#[account(signer)]
beneficiary: AccountInfo<'info>,
beneficiary: Signer<'info>,
}

#[derive(Accounts)]
pub struct Deposit<'info> {
// Member.
#[account(has_one = beneficiary)]
member: Account<'info, Member>,
#[account(signer)]
beneficiary: AccountInfo<'info>,
beneficiary: Signer<'info>,
#[account(mut, constraint = vault.to_account_info().key == &member.balances.vault)]
vault: Account<'info, TokenAccount>,
// Depositor.
Expand All @@ -726,8 +721,7 @@ pub struct DepositLocked<'info> {
vesting_vault: AccountInfo<'info>,
// Note: no need to verify the depositor_authority since the SPL program
// will fail the transaction if it's not correct.
#[account(signer)]
depositor_authority: AccountInfo<'info>,
pub depositor_authority: Signer<'info>,
#[account(constraint = token_program.key == &token::ID)]
token_program: AccountInfo<'info>,
#[account(
Expand All @@ -746,8 +740,7 @@ pub struct DepositLocked<'info> {
registrar: Box<Account<'info, Registrar>>,
#[account(has_one = registrar, has_one = beneficiary)]
member: Box<Account<'info, Member>>,
#[account(signer)]
beneficiary: AccountInfo<'info>,
beneficiary: Signer<'info>,
}

#[derive(Accounts)]
Expand All @@ -762,8 +755,7 @@ pub struct Stake<'info> {
// Member.
#[account(mut, has_one = beneficiary, has_one = registrar)]
member: Account<'info, Member>,
#[account(signer)]
beneficiary: AccountInfo<'info>,
beneficiary: Signer<'info>,
#[account(constraint = BalanceSandbox::from(&balances) == member.balances)]
balances: BalanceSandboxAccounts<'info>,
#[account(constraint = BalanceSandbox::from(&balances_locked) == member.balances_locked)]
Expand Down Expand Up @@ -801,8 +793,7 @@ pub struct StartUnstake<'info> {
pending_withdrawal: Account<'info, PendingWithdrawal>,
#[account(has_one = beneficiary, has_one = registrar)]
member: Account<'info, Member>,
#[account(signer)]
beneficiary: AccountInfo<'info>,
beneficiary: Signer<'info>,
#[account(constraint = BalanceSandbox::from(&balances) == member.balances)]
balances: BalanceSandboxAccounts<'info>,
#[account(constraint = BalanceSandbox::from(&balances_locked) == member.balances_locked)]
Expand All @@ -827,8 +818,7 @@ pub struct EndUnstake<'info> {

#[account(has_one = registrar, has_one = beneficiary)]
member: Account<'info, Member>,
#[account(signer)]
beneficiary: AccountInfo<'info>,
beneficiary: Signer<'info>,
#[account(mut, has_one = registrar, has_one = member, constraint = !pending_withdrawal.burned)]
pending_withdrawal: Account<'info, PendingWithdrawal>,

Expand Down Expand Up @@ -859,8 +849,7 @@ pub struct Withdraw<'info> {
// Member.
#[account(has_one = registrar, has_one = beneficiary)]
member: Account<'info, Member>,
#[account(signer)]
beneficiary: AccountInfo<'info>,
beneficiary: Signer<'info>,
#[account(mut, constraint = vault.to_account_info().key == &member.balances.vault)]
vault: Account<'info, TokenAccount>,
#[account(
Expand All @@ -886,8 +875,7 @@ pub struct WithdrawLocked<'info> {
vesting: Box<Account<'info, Vesting>>,
#[account(mut, constraint = vesting_vault.key == &vesting.vault)]
vesting_vault: AccountInfo<'info>,
#[account(signer)]
vesting_signer: AccountInfo<'info>,
vesting_signer: Signer<'info>,
#[account(constraint = token_program.key == &token::ID)]
token_program: AccountInfo<'info>,
#[account(
Expand All @@ -906,8 +894,7 @@ pub struct WithdrawLocked<'info> {
registrar: Box<Account<'info, Registrar>>,
#[account(has_one = registrar, has_one = beneficiary)]
member: Box<Account<'info, Member>>,
#[account(signer)]
beneficiary: AccountInfo<'info>,
beneficiary: Signer<'info>,
}

#[derive(Accounts)]
Expand Down Expand Up @@ -977,8 +964,7 @@ pub struct ClaimRewardCommon<'info> {
// Member.
#[account(mut, has_one = registrar, has_one = beneficiary)]
member: Account<'info, Member>,
#[account(signer)]
beneficiary: AccountInfo<'info>,
beneficiary: Signer<'info>,
#[account(constraint = BalanceSandbox::from(&balances) == member.balances)]
balances: BalanceSandboxAccounts<'info>,
#[account(constraint = BalanceSandbox::from(&balances_locked) == member.balances_locked)]
Expand Down Expand Up @@ -1014,8 +1000,7 @@ pub struct ExpireReward<'info> {
)]
vendor_signer: AccountInfo<'info>,
// Receiver.
#[account(signer)]
expiry_receiver: AccountInfo<'info>,
expiry_receiver: Signer<'info>,
#[account(mut)]
expiry_receiver_token: AccountInfo<'info>,
// Misc.
Expand Down Expand Up @@ -1263,7 +1248,7 @@ impl<'a, 'b, 'c, 'info> From<&mut DepositLocked<'info>>
let cpi_accounts = Transfer {
from: accounts.vesting_vault.clone(),
to: accounts.member_vault.to_account_info(),
authority: accounts.depositor_authority.clone(),
authority: accounts.depositor_authority.to_account_info().clone(),
};
let cpi_program = accounts.token_program.clone();
CpiContext::new(cpi_program, cpi_accounts)
Expand Down
Loading

0 comments on commit 74086b6

Please sign in to comment.