Add BPf loader finalize test via inner instruction (#15708)

This commit is contained in:
Jack May
2021-03-04 12:34:36 -08:00
committed by GitHub
parent 99f0d29dd1
commit fb3837260c
8 changed files with 142 additions and 8 deletions

View File

@ -0,0 +1,25 @@
//! @brief Example Rust-based BPF sanity program that finalizes a BPF program
#![allow(unreachable_code)]
extern crate solana_program;
use solana_program::{
account_info::AccountInfo, bpf_loader, entrypoint, entrypoint::ProgramResult,
loader_instruction, msg, program::invoke, pubkey::Pubkey,
};
entrypoint!(process_instruction);
fn process_instruction(
_program_id: &Pubkey,
accounts: &[AccountInfo],
_instruction_data: &[u8],
) -> ProgramResult {
msg!("Finalize a program");
invoke(
&loader_instruction::finalize(&accounts[0].key.clone(), &bpf_loader::id()),
accounts,
)?;
msg!("check executable");
assert!(accounts[0].executable);
Ok(())
}