Struct nesdie::mock::MockedBlockchain
source · [−]pub struct MockedBlockchain { /* private fields */ }
Expand description
Mocked blockchain that can be used in the tests for the smart contracts.
It implements BlockchainInterface
by redirecting calls to VMLogic
. It unwraps errors of
VMLogic
to cause panic during the unit tests similarly to how errors of VMLogic
would cause
the termination of guest program execution. Unit tests can even assert the expected error
message.
Implementations
sourceimpl MockedBlockchain
impl MockedBlockchain
sourcepub fn new(
context: VMContext,
config: VMConfig,
fees_config: RuntimeFeesConfig,
promise_results: Vec<PromiseResult>,
storage: HashMap<Vec<u8>, Vec<u8>>,
validators: HashMap<String, Balance>,
memory_opt: Option<Box<dyn MemoryLike>>
) -> Self
pub fn new(
context: VMContext,
config: VMConfig,
fees_config: RuntimeFeesConfig,
promise_results: Vec<PromiseResult>,
storage: HashMap<Vec<u8>, Vec<u8>>,
validators: HashMap<String, Balance>,
memory_opt: Option<Box<dyn MemoryLike>>
) -> Self
Initialize new mocked blockchain with configuration
sourcepub fn storage_mut(&mut self) -> &mut HashMap<Vec<u8>, Vec<u8>>
pub fn storage_mut(&mut self) -> &mut HashMap<Vec<u8>, Vec<u8>>
Returns mutable reference to mock storage.
sourcepub fn created_receipts(&self) -> &[Receipt]
pub fn created_receipts(&self) -> &[Receipt]
Returns slice of created receipts from mocked transactions.
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for MockedBlockchain
impl !Send for MockedBlockchain
impl !Sync for MockedBlockchain
impl Unpin for MockedBlockchain
impl !UnwindSafe for MockedBlockchain
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more