|
@@ -5,7 +5,7 @@ mod setup;
|
|
|
use {
|
|
|
mollusk_svm::{result::Check, Mollusk},
|
|
|
solana_sdk::{
|
|
|
- account::{AccountSharedData, ReadableAccount},
|
|
|
+ account::{Account as SolanaAccount, ReadableAccount},
|
|
|
program_error::ProgramError,
|
|
|
program_pack::Pack,
|
|
|
pubkey::Pubkey,
|
|
@@ -24,7 +24,7 @@ fn success_init_after_close_account() {
|
|
|
let destination = Pubkey::new_unique();
|
|
|
let decimals = 9;
|
|
|
|
|
|
- let owner_account = AccountSharedData::new(1_000_000_000, 0, &system_program::id());
|
|
|
+ let owner_account = SolanaAccount::new(1_000_000_000, 0, &system_program::id());
|
|
|
let mint_account = setup::setup_mint_account(None, None, 0, decimals);
|
|
|
let token_account = setup::setup_token_account(&mint, &owner, 0);
|
|
|
|
|
@@ -32,36 +32,45 @@ fn success_init_after_close_account() {
|
|
|
|
|
|
mollusk.process_and_validate_instruction_chain(
|
|
|
&[
|
|
|
- instruction::close_account(&spl_token::id(), &account, &destination, &owner, &[])
|
|
|
- .unwrap(),
|
|
|
- system_instruction::create_account(
|
|
|
- &owner,
|
|
|
- &account,
|
|
|
- 1_000_000_000,
|
|
|
- Account::LEN as u64,
|
|
|
- &spl_token::id(),
|
|
|
+ (
|
|
|
+ &instruction::close_account(&spl_token::id(), &account, &destination, &owner, &[])
|
|
|
+ .unwrap(),
|
|
|
+ &[Check::success()],
|
|
|
+ ),
|
|
|
+ (
|
|
|
+ &system_instruction::create_account(
|
|
|
+ &owner,
|
|
|
+ &account,
|
|
|
+ 1_000_000_000,
|
|
|
+ Account::LEN as u64,
|
|
|
+ &spl_token::id(),
|
|
|
+ ),
|
|
|
+ &[Check::success()],
|
|
|
+ ),
|
|
|
+ (
|
|
|
+ &instruction::initialize_account(&spl_token::id(), &account, &mint, &owner)
|
|
|
+ .unwrap(),
|
|
|
+ &[
|
|
|
+ Check::success(),
|
|
|
+ // Account successfully re-initialized.
|
|
|
+ Check::account(&account)
|
|
|
+ .data(setup::setup_token_account(&mint, &owner, 0).data())
|
|
|
+ .owner(&spl_token::id())
|
|
|
+ .build(),
|
|
|
+ // The destination should have the lamports from the closed account.
|
|
|
+ Check::account(&destination)
|
|
|
+ .lamports(expected_destination_lamports)
|
|
|
+ .build(),
|
|
|
+ ],
|
|
|
),
|
|
|
- instruction::initialize_account(&spl_token::id(), &account, &mint, &owner).unwrap(),
|
|
|
],
|
|
|
&[
|
|
|
(mint, mint_account),
|
|
|
(account, token_account),
|
|
|
(owner, owner_account),
|
|
|
- (destination, AccountSharedData::default()),
|
|
|
+ (destination, SolanaAccount::default()),
|
|
|
mollusk.sysvars.keyed_account_for_rent_sysvar(),
|
|
|
],
|
|
|
- &[
|
|
|
- Check::success(),
|
|
|
- // Account successfully re-initialized.
|
|
|
- Check::account(&account)
|
|
|
- .data(setup::setup_token_account(&mint, &owner, 0).data())
|
|
|
- .owner(&spl_token::id())
|
|
|
- .build(),
|
|
|
- // The destination should have the lamports from the closed account.
|
|
|
- Check::account(&destination)
|
|
|
- .lamports(expected_destination_lamports)
|
|
|
- .build(),
|
|
|
- ],
|
|
|
);
|
|
|
}
|
|
|
|
|
@@ -75,7 +84,7 @@ fn fail_init_after_close_account() {
|
|
|
let destination = Pubkey::new_unique();
|
|
|
let decimals = 9;
|
|
|
|
|
|
- let owner_account = AccountSharedData::new(1_000_000_000, 0, &system_program::id());
|
|
|
+ let owner_account = SolanaAccount::new(1_000_000_000, 0, &system_program::id());
|
|
|
let mint_account = setup::setup_mint_account(None, None, 0, decimals);
|
|
|
let token_account = setup::setup_token_account(&mint, &owner, 0);
|
|
|
|
|
@@ -83,29 +92,38 @@ fn fail_init_after_close_account() {
|
|
|
|
|
|
mollusk.process_and_validate_instruction_chain(
|
|
|
&[
|
|
|
- instruction::close_account(&spl_token::id(), &account, &destination, &owner, &[])
|
|
|
- .unwrap(),
|
|
|
- system_instruction::transfer(&owner, &account, 1_000_000_000),
|
|
|
- instruction::initialize_account(&spl_token::id(), &account, &mint, &owner).unwrap(),
|
|
|
+ (
|
|
|
+ &instruction::close_account(&spl_token::id(), &account, &destination, &owner, &[])
|
|
|
+ .unwrap(),
|
|
|
+ &[Check::success()],
|
|
|
+ ),
|
|
|
+ (
|
|
|
+ &system_instruction::transfer(&owner, &account, 1_000_000_000),
|
|
|
+ &[Check::success()],
|
|
|
+ ),
|
|
|
+ (
|
|
|
+ &instruction::initialize_account(&spl_token::id(), &account, &mint, &owner)
|
|
|
+ .unwrap(),
|
|
|
+ &[
|
|
|
+ Check::err(ProgramError::InvalidAccountData),
|
|
|
+ // Account not re-initialized.
|
|
|
+ Check::account(&account)
|
|
|
+ .lamports(1_000_000_000)
|
|
|
+ .owner(&system_program::id())
|
|
|
+ .build(),
|
|
|
+ // The destination should have the lamports from the closed account.
|
|
|
+ Check::account(&destination)
|
|
|
+ .lamports(expected_destination_lamports)
|
|
|
+ .build(),
|
|
|
+ ],
|
|
|
+ ),
|
|
|
],
|
|
|
&[
|
|
|
(mint, mint_account),
|
|
|
(account, token_account),
|
|
|
(owner, owner_account),
|
|
|
- (destination, AccountSharedData::default()),
|
|
|
+ (destination, SolanaAccount::default()),
|
|
|
mollusk.sysvars.keyed_account_for_rent_sysvar(),
|
|
|
],
|
|
|
- &[
|
|
|
- Check::err(ProgramError::InvalidAccountData),
|
|
|
- // Account not re-initialized.
|
|
|
- Check::account(&account)
|
|
|
- .lamports(1_000_000_000)
|
|
|
- .owner(&system_program::id())
|
|
|
- .build(),
|
|
|
- // The destination should have the lamports from the closed account.
|
|
|
- Check::account(&destination)
|
|
|
- .lamports(expected_destination_lamports)
|
|
|
- .build(),
|
|
|
- ],
|
|
|
);
|
|
|
}
|