Skip to content

Commit

Permalink
Cleanup - mock InvokeContext (#31007)
Browse files Browse the repository at this point in the history
* Turns with_mock_invoke_context() into a macro.

* Removes prepare_mock_invoke_context().

* Replaces InvokeContext::new_mock() with with_mock_invoke_context().

* Removes InvokeContext::new_mock().

* Removes Cow from InvokeContext::sysvar_cache.

* Removes override parameters from mock_process_instruction().

* cargo fmt
  • Loading branch information
Lichtso authored Apr 3, 2023
1 parent 9219a16 commit a0c7fde
Show file tree
Hide file tree
Showing 19 changed files with 1,014 additions and 1,417 deletions.
7 changes: 2 additions & 5 deletions cli/src/program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ use {
account_utils::StateMut,
bpf_loader, bpf_loader_deprecated,
bpf_loader_upgradeable::{self, UpgradeableLoaderState},
feature_set::FeatureSet,
instruction::{Instruction, InstructionError},
loader_instruction,
message::Message,
Expand All @@ -46,9 +47,7 @@ use {
signature::{keypair_from_seed, read_keypair_file, Keypair, Signature, Signer},
system_instruction::{self, SystemError},
system_program,
sysvar::rent::Rent,
transaction::{Transaction, TransactionError},
transaction_context::TransactionContext,
},
std::{
fs::File,
Expand Down Expand Up @@ -2018,12 +2017,10 @@ fn read_and_verify_elf(program_location: &str) -> Result<Vec<u8>, Box<dyn std::e
let mut program_data = Vec::new();
file.read_to_end(&mut program_data)
.map_err(|err| format!("Unable to read program file: {err}"))?;
let mut transaction_context = TransactionContext::new(Vec::new(), Some(Rent::default()), 1, 1);
let invoke_context = InvokeContext::new_mock(&mut transaction_context, &[]);

// Verify the program
let loader = create_loader(
&invoke_context.feature_set,
&FeatureSet::default(),
&ComputeBudget::default(),
true,
true,
Expand Down
Loading

0 comments on commit a0c7fde

Please sign in to comment.