program-test: Set context without panic (#14997)

* program-test: Fix CPI and multiple instructions

* Whitespace

* Add CPI test in program-test
This commit is contained in:
Jon Cinque
2021-02-03 13:45:29 +01:00
committed by GitHub
parent 286e4d6924
commit 4324374ab5
3 changed files with 87 additions and 8 deletions

View File

@ -71,13 +71,11 @@ pub fn to_instruction_error(error: ProgramError) -> InstructionError {
}
thread_local! {
static INVOKE_CONTEXT:RefCell<Option<(usize, usize)>> = RefCell::new(None);
static INVOKE_CONTEXT: RefCell<Option<(usize, usize)>> = RefCell::new(None);
}
fn set_invoke_context(new: &mut dyn InvokeContext) {
INVOKE_CONTEXT.with(|invoke_context| {
if unsafe { invoke_context.replace(Some(transmute::<_, (usize, usize)>(new))) }.is_some() {
panic!("Overwiting invoke context!")
}
INVOKE_CONTEXT.with(|invoke_context| unsafe {
invoke_context.replace(Some(transmute::<_, (usize, usize)>(new)))
});
}
fn get_invoke_context<'a>() -> &'a mut dyn InvokeContext {