program-test: Set context without panic (#14997)

* program-test: Fix CPI and multiple instructions

* Whitespace

* Add CPI test in program-test
This commit is contained in:
Jon Cinque
2021-02-03 13:45:29 +01:00
committed by GitHub
parent 286e4d6924
commit 4324374ab5
3 changed files with 87 additions and 8 deletions

View File

@ -1,8 +1,8 @@
use {
solana_banks_client::BanksClient,
solana_program::{
account_info::AccountInfo, entrypoint::ProgramResult, hash::Hash, pubkey::Pubkey,
rent::Rent,
account_info::AccountInfo, entrypoint::ProgramResult, hash::Hash, instruction::Instruction,
msg, pubkey::Pubkey, rent::Rent,
},
solana_program_test::{processor, ProgramTest},
solana_sdk::{
@ -10,13 +10,14 @@ use {
},
};
// Dummy process instruction required to instantiate ProgramTest
#[allow(clippy::unnecessary_wraps)]
fn process_instruction(
_program_id: &Pubkey,
_accounts: &[AccountInfo],
_input: &[u8],
) -> ProgramResult {
// if we can call `msg!` successfully, then InvokeContext exists as required
msg!("Processing instruction");
Ok(())
}
@ -94,6 +95,7 @@ async fn run_fuzz_instructions(
program_id,
);
instructions.push(instruction);
instructions.push(Instruction::new(*program_id, &[0], vec![]));
signer_keypairs.push(keypair);
}
// Process transaction on test network