multiversx_chain_vm/world_mock/
failing_executor.rs

1use multiversx_chain_vm_executor::Executor;
2
3/// Dummy executor that fails whenever called.
4///
5/// Used in dummy contexts.
6///
7/// TODO: either remove, or move to vm-executor repo.
8pub struct FailingExecutor;
9
10impl Executor for FailingExecutor {
11    fn set_vm_hooks_ptr(
12        &mut self,
13        _vm_hooks_ptr: *mut std::ffi::c_void,
14    ) -> Result<(), multiversx_chain_vm_executor::ExecutorError> {
15        panic!("called FailingExecutor")
16    }
17
18    fn set_opcode_cost(
19        &mut self,
20        _opcode_cost: &multiversx_chain_vm_executor::OpcodeCost,
21    ) -> Result<(), multiversx_chain_vm_executor::ExecutorError> {
22        panic!("called FailingExecutor")
23    }
24
25    fn new_instance(
26        &self,
27        _wasm_bytes: &[u8],
28        _compilation_options: &multiversx_chain_vm_executor::CompilationOptions,
29    ) -> Result<
30        Box<dyn multiversx_chain_vm_executor::Instance>,
31        multiversx_chain_vm_executor::ExecutorError,
32    > {
33        panic!("called FailingExecutor")
34    }
35
36    fn new_instance_from_cache(
37        &self,
38        _cache_bytes: &[u8],
39        _compilation_options: &multiversx_chain_vm_executor::CompilationOptions,
40    ) -> Result<
41        Box<dyn multiversx_chain_vm_executor::Instance>,
42        multiversx_chain_vm_executor::ExecutorError,
43    > {
44        panic!("called FailingExecutor")
45    }
46}