Struct sp_state_machine::TestExternalities
source · [−]pub struct TestExternalities<H: Hasher, N: ChangesTrieBlockNumber = u64> where
H::Out: Codec + Ord, { /* private fields */ }
Expand description
Simple HashMap-based Externalities impl.
Implementations
sourceimpl<H: Hasher, N: ChangesTrieBlockNumber> TestExternalities<H, N> where
H::Out: Ord + 'static + Codec,
impl<H: Hasher, N: ChangesTrieBlockNumber> TestExternalities<H, N> where
H::Out: Ord + 'static + Codec,
sourcepub fn ext(&mut self) -> Ext<'_, H, N, InMemoryBackend<H>>
pub fn ext(&mut self) -> Ext<'_, H, N, InMemoryBackend<H>>
Get externalities implementation.
sourcepub fn new_with_code(code: &[u8], storage: Storage) -> Self
pub fn new_with_code(code: &[u8], storage: Storage) -> Self
Create a new instance of TestExternalities
with code and storage.
sourcepub fn overlayed_changes(&self) -> &OverlayedChanges
pub fn overlayed_changes(&self) -> &OverlayedChanges
Returns the overlayed changes.
sourcepub fn persist_offchain_overlay(&mut self)
pub fn persist_offchain_overlay(&mut self)
Move offchain changes from overlay to the persistent store.
sourcepub fn offchain_db(&self) -> TestPersistentOffchainDB
pub fn offchain_db(&self) -> TestPersistentOffchainDB
A shared reference type around the offchain worker storage.
sourcepub fn insert(&mut self, k: StorageKey, v: StorageValue)
pub fn insert(&mut self, k: StorageKey, v: StorageValue)
Insert key/value into backend
sourcepub fn register_extension<E: Any + Extension>(&mut self, ext: E)
pub fn register_extension<E: Any + Extension>(&mut self, ext: E)
Registers the given extension for this instance.
sourcepub fn changes_trie_storage(&mut self) -> &mut ChangesTrieInMemoryStorage<H, N>
pub fn changes_trie_storage(&mut self) -> &mut ChangesTrieInMemoryStorage<H, N>
Get mutable reference to changes trie storage.
sourcepub fn commit_all(&mut self) -> Result<(), String>
pub fn commit_all(&mut self) -> Result<(), String>
Commit all pending changes to the underlying backend.
Panic
This will panic if there are still open transactions.
sourcepub fn execute_with<R>(&mut self, execute: impl FnOnce() -> R) -> R
pub fn execute_with<R>(&mut self, execute: impl FnOnce() -> R) -> R
Execute the given closure while self
is set as externalities.
Returns the result of the given closure.
sourcepub fn execute_with_safe<R>(
&mut self,
f: impl FnOnce() -> R + UnwindSafe
) -> Result<R, String>
pub fn execute_with_safe<R>(
&mut self,
f: impl FnOnce() -> R + UnwindSafe
) -> Result<R, String>
Execute the given closure while self
is set as externalities.
Returns the result of the given closure, if no panics occured.
Otherwise, returns Err
.
Trait Implementations
sourceimpl<H: Hasher, N: ChangesTrieBlockNumber> Debug for TestExternalities<H, N> where
H::Out: Ord + Codec,
impl<H: Hasher, N: ChangesTrieBlockNumber> Debug for TestExternalities<H, N> where
H::Out: Ord + Codec,
sourceimpl<H: Hasher, N: ChangesTrieBlockNumber> Default for TestExternalities<H, N> where
H::Out: Ord + 'static + Codec,
impl<H: Hasher, N: ChangesTrieBlockNumber> Default for TestExternalities<H, N> where
H::Out: Ord + 'static + Codec,
sourceimpl<H, N> ExtensionStore for TestExternalities<H, N> where
H: Hasher,
H::Out: Ord + Codec,
N: ChangesTrieBlockNumber,
impl<H, N> ExtensionStore for TestExternalities<H, N> where
H: Hasher,
H::Out: Ord + Codec,
N: ChangesTrieBlockNumber,
sourcefn extension_by_type_id(&mut self, type_id: TypeId) -> Option<&mut dyn Any>
fn extension_by_type_id(&mut self, type_id: TypeId) -> Option<&mut dyn Any>
Tries to find a registered extension by the given type_id
and returns it as a &mut dyn Any
. Read more
sourceimpl<H: Hasher, N: ChangesTrieBlockNumber> From<Storage> for TestExternalities<H, N> where
H::Out: Ord + 'static + Codec,
impl<H: Hasher, N: ChangesTrieBlockNumber> From<Storage> for TestExternalities<H, N> where
H::Out: Ord + 'static + Codec,
sourceimpl<H: Hasher, N: ChangesTrieBlockNumber> PartialEq<TestExternalities<H, N>> for TestExternalities<H, N> where
H::Out: Ord + 'static + Codec,
impl<H: Hasher, N: ChangesTrieBlockNumber> PartialEq<TestExternalities<H, N>> for TestExternalities<H, N> where
H::Out: Ord + 'static + Codec,
Auto Trait Implementations
impl<H, N = u64> !RefUnwindSafe for TestExternalities<H, N>
impl<H, N> Send for TestExternalities<H, N>
impl<H, N = u64> !Sync for TestExternalities<H, N>
impl<H, N> Unpin for TestExternalities<H, N> where
H: Unpin,
N: Unpin,
<H as Hasher>::Out: Unpin,
impl<H, N = u64> !UnwindSafe for TestExternalities<H, N>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T, Outer> IsWrappedBy<Outer> for T where
Outer: AsRef<T> + AsMut<T> + From<T>,
T: From<Outer>,
impl<T, Outer> IsWrappedBy<Outer> for T where
Outer: AsRef<T> + AsMut<T> + From<T>,
T: From<Outer>,
sourceimpl<S, T> UncheckedInto<T> for S where
T: UncheckedFrom<S>,
impl<S, T> UncheckedInto<T> for S where
T: UncheckedFrom<S>,
sourcepub fn unchecked_into(self) -> T
pub fn unchecked_into(self) -> T
The counterpart to unchecked_from
.