use light_token::instruction::{CloseAccount, LIGHT_TOKEN_PROGRAM_ID, LIGHT_TOKEN_RENT_SPONSOR};
use solana_instruction::{AccountMeta, Instruction};
use solana_pubkey::Pubkey;
#[test]
fn test_close_account_instruction() {
let account = Pubkey::new_from_array([1u8; 32]);
let destination = Pubkey::new_from_array([2u8; 32]);
let owner = Pubkey::new_from_array([3u8; 32]);
let instruction = CloseAccount::new(LIGHT_TOKEN_PROGRAM_ID, account, destination, owner)
.instruction()
.expect("Failed to create instruction");
let expected = Instruction {
program_id: LIGHT_TOKEN_PROGRAM_ID,
accounts: vec![
AccountMeta::new(account, false), AccountMeta::new(destination, false), AccountMeta::new_readonly(owner, true), AccountMeta::new(LIGHT_TOKEN_RENT_SPONSOR, false), ],
data: vec![9u8], };
assert_eq!(
instruction, expected,
"CloseAccount instruction should match expected"
);
}
#[test]
fn test_close_account_custom_rent_sponsor() {
let account = Pubkey::new_from_array([1u8; 32]);
let destination = Pubkey::new_from_array([2u8; 32]);
let owner = Pubkey::new_from_array([3u8; 32]);
let custom_sponsor = Pubkey::new_from_array([4u8; 32]);
let instruction = CloseAccount::new(LIGHT_TOKEN_PROGRAM_ID, account, destination, owner)
.custom_rent_sponsor(custom_sponsor)
.instruction()
.expect("Failed to create instruction");
let expected = Instruction {
program_id: LIGHT_TOKEN_PROGRAM_ID,
accounts: vec![
AccountMeta::new(account, false), AccountMeta::new(destination, false), AccountMeta::new_readonly(owner, true), AccountMeta::new(custom_sponsor, false), ],
data: vec![9u8], };
assert_eq!(
instruction, expected,
"CloseAccount instruction with custom rent sponsor should match expected"
);
}