Struct near_sdk::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
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
pub fn take_storage(&mut self) -> HashMap<Vec<u8>, Vec<u8>>
sourcepub fn created_receipts(&self) -> Vec<Receipt>
pub fn created_receipts(&self) -> Vec<Receipt>
Returns metadata about the receipts created
pub fn gas(&mut self, gas_amount: u32)
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