#![cfg(feature = "test-bpf")] use anchor_client::Program; use anchor_lang::AnchorDeserialize; use anchor_lang::{solana_program, system_program}; use { anchor_client::solana_sdk::{ account::Account, instruction::Instruction, program_pack::Pack, pubkey::Pubkey, signature::{Keypair, Signer}, sysvar::clock::Clock, sysvar::{clock, rent::Rent}, transaction::Transaction, }, anchor_lang::{prelude::*, InstructionData}, solana_test_framework::*, }; #[tokio::test] async fn poc() { // @fixme modify let program_id = ""; let program_name = ""; let solana_program_id = system_program::ID; // generate some keys let payer = Keypair::new(); // Deploy program // @fixme MODIFY PROCESS INSTRUCTION let mut program = ProgramTest::new( program_name, program_id, // the entrypoint function is generated by the #[program] macro processor!(MODIFY PROCESS INSTRUCTION), ); program.add_account( payer.pubkey(), Account { lamports: 1_000_000_000_000_000, ..Account::default() }, ); let mut program_context = program.start_with_context().await; let mut recent_blockhash = program_context.last_blockhash.clone(); // Get PDA let (pda1, _) = Pubkey::find_program_address(&[b""], &program_id); // Create instruction // @fixme - modify INSTRUCTION and ACCOUNTS let ix = Instruction { program_id, data: INSTRUCTION { global_market_seed, interest_fee: Fraction::new(1, 100).unwrap(), withdrawal_fee: Fraction::new(1, 100).unwrap(), } .data(), accounts: ACCOUNTS { owner: payer.pubkey(), system_program: solana_program_id, } .to_account_metas(None), }; let mut tx = Transaction::new_with_payer(&[ix], Some(&payer.pubkey())); tx.partial_sign(&[&payer], recent_blockhash); // process transactions program_context .banks_client .process_transaction(tx) .await .unwrap(); let mut recent_blockhash = program_context.last_blockhash.clone(); // Get account and deserialize // @fixme modify type let pda_state: TYPE = program_context .banks_client .get_anchor_account_data(pda1) .await .unwrap(); println!("{:?}", pda_state); }