pub struct MockStateStorage { /* private fields */ }Expand description
Mock implementation of StateStorage for testing.
Stores state in memory and provides:
- Failure injection via
configure_failures() - Operation tracking via
operations()andoperation_count() - State inspection via
get_stored_state()andget_stored_params()
Implementations§
Source§impl MockStateStorage
impl MockStateStorage
Sourcepub fn configure_failures(&self, config: FailureConfig)
pub fn configure_failures(&self, config: FailureConfig)
Configure failure injection.
Sourcepub fn fail_next_stores(&self, count: usize)
pub fn fail_next_stores(&self, count: usize)
Set to fail the next N store operations.
Sourcepub fn fail_next_gets(&self, count: usize)
pub fn fail_next_gets(&self, count: usize)
Set to fail the next N get operations.
Sourcepub fn fail_next_store_params(&self, count: usize)
pub fn fail_next_store_params(&self, count: usize)
Set to fail the next N store_params operations.
Sourcepub fn fail_next_get_params(&self, count: usize)
pub fn fail_next_get_params(&self, count: usize)
Set to fail the next N get_params operations.
Sourcepub fn fail_for_key(&self, key: ContractKey)
pub fn fail_for_key(&self, key: ContractKey)
Add a key that should always fail.
Sourcepub fn operations(&self) -> Vec<StorageOperation>
pub fn operations(&self) -> Vec<StorageOperation>
Get all recorded operations.
Sourcepub fn store_count(&self) -> usize
pub fn store_count(&self) -> usize
Get the total count of store operations.
Sourcepub fn operation_count(&self) -> usize
pub fn operation_count(&self) -> usize
Get total operation count.
Sourcepub fn get_stored_state(&self, key: &ContractKey) -> Option<WrappedState>
pub fn get_stored_state(&self, key: &ContractKey) -> Option<WrappedState>
Get stored state directly (bypassing normal get logic).
Sourcepub fn get_stored_params(
&self,
key: &ContractKey,
) -> Option<Parameters<'static>>
pub fn get_stored_params( &self, key: &ContractKey, ) -> Option<Parameters<'static>>
Get stored params directly (bypassing normal get logic).
Sourcepub fn stored_keys(&self) -> Vec<ContractKey>
pub fn stored_keys(&self) -> Vec<ContractKey>
Get all stored keys.
Sourcepub fn seed_state(&self, key: ContractKey, state: WrappedState)
pub fn seed_state(&self, key: ContractKey, state: WrappedState)
Pre-populate with state (useful for setting up test scenarios).
Sourcepub fn seed_params(&self, key: ContractKey, params: Parameters<'static>)
pub fn seed_params(&self, key: ContractKey, params: Parameters<'static>)
Pre-populate with params (useful for setting up test scenarios).
Trait Implementations§
Source§impl Clone for MockStateStorage
impl Clone for MockStateStorage
Source§fn clone(&self) -> MockStateStorage
fn clone(&self) -> MockStateStorage
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for MockStateStorage
impl Debug for MockStateStorage
Source§impl Default for MockStateStorage
impl Default for MockStateStorage
Source§fn default() -> MockStateStorage
fn default() -> MockStateStorage
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for MockStateStorage
impl RefUnwindSafe for MockStateStorage
impl Send for MockStateStorage
impl Sync for MockStateStorage
impl Unpin for MockStateStorage
impl UnsafeUnpin for MockStateStorage
impl UnwindSafe for MockStateStorage
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more