Skip to content

Commit

Permalink
Adjusts the tests and benchmarks.
Browse files Browse the repository at this point in the history
  • Loading branch information
Lichtso committed May 1, 2023
1 parent d5f10e3 commit 0fb43cf
Show file tree
Hide file tree
Showing 4 changed files with 122 additions and 70 deletions.
12 changes: 9 additions & 3 deletions ledger/src/blockstore_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1809,7 +1809,7 @@ pub mod tests {
matches::assert_matches,
rand::{thread_rng, Rng},
solana_entry::entry::{create_ticks, next_entry, next_entry_mut},
solana_program_runtime::declare_process_instruction,
solana_program_runtime::{builtin_program::create_builtin, declare_process_instruction},
solana_runtime::{
genesis_utils::{
self, create_genesis_config_with_vote_accounts, ValidatorVoteKeypairs,
Expand Down Expand Up @@ -2971,7 +2971,10 @@ pub mod tests {
let mock_program_id = solana_sdk::pubkey::new_rand();

let mut bank = Bank::new_for_tests(&genesis_config);
bank.add_builtin("mock_processor", &mock_program_id, mock_processor_ok);
bank.add_builtin(
mock_program_id,
create_builtin("mockup".to_string(), mock_processor_ok),
);

let tx = Transaction::new_signed_with_payer(
&[Instruction::new_with_bincode(
Expand Down Expand Up @@ -3012,7 +3015,10 @@ pub mod tests {

(0..get_instruction_errors().len()).for_each(|err| {
let mut bank = Bank::new_for_tests(&genesis_config);
bank.add_builtin("mock_processor", &mock_program_id, mock_processor_err);
bank.add_builtin(
mock_program_id,
create_builtin("mockup".to_string(), mock_processor_err),
);

let tx = Transaction::new_signed_with_payer(
&[Instruction::new_with_bincode(
Expand Down
17 changes: 6 additions & 11 deletions program-test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use {
solana_banks_server::banks_server::start_local_server,
solana_bpf_loader_program::serialization::serialize_parameters,
solana_program_runtime::{
builtin_program::{BuiltinProgram, BuiltinPrograms, ProcessInstructionWithContext},
builtin_program::{create_builtin, BuiltinPrograms, ProcessInstructionWithContext},
compute_budget::ComputeBudget,
ic_msg, stable_log,
timings::ExecuteTimings,
Expand Down Expand Up @@ -692,11 +692,10 @@ impl ProgramTest {
process_instruction: ProcessInstructionWithContext,
) {
info!("\"{}\" builtin program", program_name);
self.builtin_programs.vec.push(BuiltinProgram {
name: program_name.to_string(),
self.builtin_programs.vec.push((
program_id,
process_instruction,
});
create_builtin(program_name.to_string(), process_instruction),
));
}

/// Deactivate a runtime feature.
Expand Down Expand Up @@ -791,12 +790,8 @@ impl ProgramTest {
}

// User-supplied additional builtins
for builtin in self.builtin_programs.vec.iter() {
bank.add_builtin(
&builtin.name,
&builtin.program_id,
builtin.process_instruction,
);
for (program_id, builtin) in self.builtin_programs.vec.iter() {
bank.add_builtin(*program_id, builtin.clone());
}

for (address, account) in self.accounts.iter() {
Expand Down
7 changes: 3 additions & 4 deletions runtime/benches/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ extern crate test;

use {
log::*,
solana_program_runtime::declare_process_instruction,
solana_program_runtime::{builtin_program::create_builtin, declare_process_instruction},
solana_runtime::{
bank::{test_utils::goto_end_of_slot, *},
bank_client::BankClient,
Expand Down Expand Up @@ -132,9 +132,8 @@ fn do_bench_transactions(

let mut bank = Bank::new_from_parent(&Arc::new(bank), &Pubkey::default(), 1);
bank.add_builtin(
"builtin_program",
&Pubkey::from(BUILTIN_PROGRAM_ID),
process_instruction,
Pubkey::from(BUILTIN_PROGRAM_ID),
create_builtin("mockup".to_string(), process_instruction),
);
bank.add_builtin_account("solana_noop_program", &Pubkey::from(NOOP_PROGRAM_ID), false);
let bank = Arc::new(bank);
Expand Down
Loading

0 comments on commit 0fb43cf

Please sign in to comment.