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

@ -354,7 +354,7 @@ pub struct MockInvokeContext<'a> {
pub invoke_stack: Vec<InvokeContextStackFrame<'a>>,
pub logger: MockLogger,
pub compute_budget: ComputeBudget,
pub compute_meter: MockComputeMeter,
pub compute_meter: Rc<RefCell<dyn ComputeMeter>>,
pub programs: Vec<(Pubkey, ProcessInstructionWithContext)>,
pub accounts: Vec<(Pubkey, Rc<RefCell<AccountSharedData>>)>,
#[allow(clippy::type_complexity)]
@ -372,9 +372,9 @@ impl<'a> MockInvokeContext<'a> {
invoke_stack: Vec::with_capacity(compute_budget.max_invoke_depth),
logger: MockLogger::default(),
compute_budget,
compute_meter: MockComputeMeter {
compute_meter: Rc::new(RefCell::new(MockComputeMeter {
remaining: std::i64::MAX as u64,
},
})),
programs: vec![],
accounts: vec![],
sysvars: RefCell::new(Vec::new()),
@ -464,7 +464,7 @@ impl<'a> InvokeContext for MockInvokeContext<'a> {
Rc::new(RefCell::new(self.logger.clone()))
}
fn get_compute_meter(&self) -> Rc<RefCell<dyn ComputeMeter>> {
Rc::new(RefCell::new(self.compute_meter.clone()))
self.compute_meter.clone()
}
fn add_executor(&self, _pubkey: &Pubkey, _executor: Arc<dyn Executor>) {}
fn get_executor(&self, _pubkey: &Pubkey) -> Option<Arc<dyn Executor>> {