Add built-in programs to InvokeContext (#10383)

automerge
This commit is contained in:
Michael Vines
2020-06-03 12:48:19 -07:00
committed by GitHub
parent ea9b958dff
commit a4cd96609c
7 changed files with 36 additions and 14 deletions

View File

@ -259,7 +259,8 @@ mod tests {
use super::*;
use rand::Rng;
use solana_sdk::{
account::Account, instruction::CompiledInstruction, message::Message, rent::Rent,
account::Account, entrypoint_native::ProcessInstruction, instruction::CompiledInstruction,
message::Message, rent::Rent,
};
use std::{cell::RefCell, fs::File, io::Read, ops::Range, rc::Rc};
@ -283,6 +284,9 @@ mod tests {
fn get_caller(&self) -> Result<&Pubkey, InstructionError> {
Ok(&self.key)
}
fn get_programs(&self) -> &[(Pubkey, ProcessInstruction)] {
&[]
}
}
#[test]

View File

@ -6,7 +6,7 @@ use solana_rbpf::{
memory_region::{translate_addr, MemoryRegion},
EbpfVm,
};
use solana_runtime::{builtin_programs::get_builtin_programs, message_processor::MessageProcessor};
use solana_runtime::message_processor::MessageProcessor;
use solana_sdk::{
account::Account,
account::KeyedAccount,
@ -767,9 +767,8 @@ fn call<'a>(
let program_account = (*accounts[callee_program_id_index]).clone();
let executable_accounts = vec![(callee_program_id, program_account)];
let mut message_processor = MessageProcessor::default();
let builtin_programs = get_builtin_programs();
for program in builtin_programs.iter() {
message_processor.add_program(program.id, program.process_instruction);
for (program_id, process_instruction) in invoke_context.get_programs().iter() {
message_processor.add_program(*program_id, *process_instruction);
}
message_processor.add_loader(bpf_loader::id(), crate::process_instruction);