Fixes a bug in MockInvokeContext::get_compute_meter() and adjusts the test assert_instruction_count accordingly. (#20854)

The get_compute_meter() method created a reference to a clone instead of cloning the reference.
This commit is contained in:
Alexander Meißner
2021-10-22 09:46:47 +02:00
committed by GitHub
parent 0d4dbd5588
commit e7c9b9329d
4 changed files with 33 additions and 33 deletions

View File

@ -25,11 +25,11 @@ use solana_sdk::{
entrypoint::SUCCESS,
instruction::{AccountMeta, Instruction},
message::Message,
process_instruction::{InvokeContext, MockInvokeContext},
process_instruction::{InvokeContext, MockComputeMeter, MockInvokeContext},
pubkey::Pubkey,
signature::{Keypair, Signer},
};
use std::{cell::RefCell, env, fs::File, io::Read, mem, path::PathBuf, sync::Arc};
use std::{cell::RefCell, env, fs::File, io::Read, mem, path::PathBuf, rc::Rc, sync::Arc};
use test::Bencher;
/// BPF program file extension
@ -237,7 +237,7 @@ fn bench_create_vm(bencher: &mut Bencher) {
let instruction_data = vec![0u8];
let mut invoke_context = MockInvokeContext::new(&loader_id, keyed_accounts);
invoke_context.compute_meter.remaining = BUDGET;
invoke_context.compute_meter = Rc::new(RefCell::new(MockComputeMeter { remaining: BUDGET }));
// Serialize account data
let keyed_accounts = invoke_context.get_keyed_accounts().unwrap();
@ -296,7 +296,7 @@ fn bench_instruction_count_tuner(_bencher: &mut Bencher) {
.collect();
let instruction_data = vec![0u8];
let mut invoke_context = MockInvokeContext::new(&program_id, keyed_accounts);
invoke_context.compute_meter.remaining = BUDGET;
invoke_context.compute_meter = Rc::new(RefCell::new(MockComputeMeter { remaining: BUDGET }));
// Serialize account data
let (mut serialized, account_lengths) = serialize_parameters(