Struct sp_state_machine::TestExternalities[][src]

pub struct TestExternalities<H: Hasher, N: ChangesTrieBlockNumber = u64> where
    H::Out: Codec + Ord
{ /* fields omitted */ }

Simple HashMap-based Externalities impl.

Implementations

impl<H: Hasher, N: ChangesTrieBlockNumber> TestExternalities<H, N> where
    H::Out: Ord + 'static + Codec
[src]

pub fn ext(&mut self) -> Ext<'_, H, N, InMemoryBackend<H>>[src]

Get externalities implementation.

pub fn new(storage: Storage) -> Self[src]

Create a new instance of TestExternalities with storage.

pub fn new_empty() -> Self[src]

New empty test externalities.

pub fn new_with_code(code: &[u8], mut storage: Storage) -> Self[src]

Create a new instance of TestExternalities with code and storage.

pub fn overlayed_changes(&self) -> &OverlayedChanges[src]

Returns the overlayed changes.

pub fn persist_offchain_overlay(&mut self)[src]

Move offchain changes from overlay to the persistent store.

pub fn offchain_db(&self) -> TestPersistentOffchainDB[src]

A shared reference type around the offchain worker storage.

pub fn insert(&mut self, k: StorageKey, v: StorageValue)[src]

Insert key/value into backend

pub fn register_extension<E: Any + Extension>(&mut self, ext: E)[src]

Registers the given extension for this instance.

pub fn changes_trie_storage(&mut self) -> &mut ChangesTrieInMemoryStorage<H, N>[src]

Get mutable reference to changes trie storage.

pub fn commit_all(&mut self) -> Result<(), String>[src]

Commit all pending changes to the underlying backend.

Panic

This will panic if there are still open transactions.

pub fn execute_with<R>(&mut self, execute: impl FnOnce() -> R) -> R[src]

Execute the given closure while self is set as externalities.

Returns the result of the given closure.

pub fn execute_with_safe<R>(
    &mut self,
    f: impl FnOnce() -> R + UnwindSafe
) -> Result<R, String>
[src]

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

impl<H: Hasher, N: ChangesTrieBlockNumber> Debug for TestExternalities<H, N> where
    H::Out: Ord + Codec
[src]

impl<H: Hasher, N: ChangesTrieBlockNumber> Default for TestExternalities<H, N> where
    H::Out: Ord + 'static + Codec
[src]

impl<H, N> ExtensionStore for TestExternalities<H, N> where
    H: Hasher,
    H::Out: Ord + Codec,
    N: ChangesTrieBlockNumber
[src]

impl<H: Hasher, N: ChangesTrieBlockNumber> From<Storage> for TestExternalities<H, N> where
    H::Out: Ord + 'static + Codec
[src]

impl<H: Hasher, N: ChangesTrieBlockNumber> PartialEq<TestExternalities<H, N>> for TestExternalities<H, N> where
    H::Out: Ord + 'static + Codec
[src]

fn eq(&self, other: &TestExternalities<H, N>) -> bool[src]

This doesn't test if they are in the same state, only if they contains the same data at this state

Auto Trait Implementations

impl<H, N = u64> !RefUnwindSafe for TestExternalities<H, N>[src]

impl<H, N> Send for TestExternalities<H, N>[src]

impl<H, N = u64> !Sync for TestExternalities<H, N>[src]

impl<H, N> Unpin for TestExternalities<H, N> where
    H: Unpin,
    N: Unpin,
    <H as Hasher>::Out: Unpin
[src]

impl<H, N = u64> !UnwindSafe for TestExternalities<H, N>[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, Outer> IsWrappedBy<Outer> for T where
    T: From<Outer>,
    Outer: AsRef<T> + AsMut<T> + From<T>, 
[src]

pub fn from_ref(outer: &Outer) -> &T[src]

Get a reference to the inner from the outer.

pub fn from_mut(outer: &mut Outer) -> &mut T[src]

Get a mutable reference to the inner from the outer.

impl<T> MaybeDebug for T where
    T: Debug
[src]

impl<T> MaybeDebug for T where
    T: Debug

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<S, T> UncheckedInto<T> for S where
    T: UncheckedFrom<S>, 
[src]

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,