shank_parse::shank_parse!("../idl/basic_mint.json");
#[cfg(test)]
mod tests {
use super::basic_mint::instructions::*;
use super::basic_mint::ID;
use shank_parse::__private::Pubkey;
#[test]
fn test_program_id() {
assert_eq!(ID.to_string(), "8F1XtWR4wTs37nnutBvd2MWpCTfb7XAciFYkw5XHaENj");
}
#[test]
fn test_create_mint_instruction() {
let program_id = Pubkey::new_from_array([1u8; 32]);
let accounts = CreateMintAccounts {
payer: Pubkey::new_from_array([2u8; 32]),
mint: Pubkey::new_from_array([3u8; 32]),
token_program: Pubkey::new_from_array([4u8; 32]),
system_program: Pubkey::new_from_array([5u8; 32]),
};
let args = CreateMintArgs {
decimals: 9,
name: [0u8; 32],
symbol: [0u8; 8],
uri: [0u8; 64],
};
let ix = create_mint(&program_id, &accounts, &args);
assert_eq!(ix.program_id, program_id);
assert_eq!(ix.accounts.len(), 4);
assert_eq!(ix.data[0], 0); assert_eq!(ix.data[1], 9); assert_eq!(&ix.data[2..34], &[0u8; 32]); assert_eq!(&ix.data[34..42], &[0u8; 8]); assert_eq!(&ix.data[42..106], &[0u8; 64]); }
#[test]
fn test_transfer_mint_instruction() {
let program_id = Pubkey::new_from_array([1u8; 32]);
let accounts = TransferMintAccounts {
from_token_account: Pubkey::new_from_array([2u8; 32]),
mint: Pubkey::new_from_array([3u8; 32]),
to_token_account: Pubkey::new_from_array([4u8; 32]),
authority: Pubkey::new_from_array([5u8; 32]),
token_program: Pubkey::new_from_array([6u8; 32]),
};
let args = TransferMintArgs {
amount: 1000,
decimals: 6,
};
let ix = transfer_mint(&program_id, &accounts, &args);
assert_eq!(ix.data[0], 1); assert_eq!(
u64::from_le_bytes(ix.data[1..9].try_into().expect("slice")),
1000
);
assert_eq!(ix.data[9], 6); assert_eq!(ix.accounts.len(), 5);
assert!(ix.accounts[0].is_writable); assert!(!ix.accounts[1].is_writable); assert!(ix.accounts[3].is_signer); }
#[test]
fn test_create_mint_args_struct() {
let args = CreateMintArgs {
decimals: 9,
name: [b'T'; 32],
symbol: [b'S'; 8],
uri: [b'U'; 64],
};
assert_eq!(args.decimals, 9);
assert_eq!(args.name, [b'T'; 32]);
assert_eq!(args.symbol, [b'S'; 8]);
assert_eq!(args.uri, [b'U'; 64]);
}
}