Struct sp_core::offchain::testing::TestOffchainExt
source · pub struct TestOffchainExt(pub Arc<RwLock<OffchainState>>);
Expand description
Implementation of offchain externalities used for tests.
Tuple Fields
0: Arc<RwLock<OffchainState>>
Implementations
sourceimpl TestOffchainExt
impl TestOffchainExt
sourcepub fn new() -> (Self, Arc<RwLock<OffchainState>>)
pub fn new() -> (Self, Arc<RwLock<OffchainState>>)
Create new TestOffchainExt
and a reference to the internal state.
sourcepub fn with_offchain_db(
offchain_db: TestPersistentOffchainDB
) -> (Self, Arc<RwLock<OffchainState>>)
pub fn with_offchain_db(
offchain_db: TestPersistentOffchainDB
) -> (Self, Arc<RwLock<OffchainState>>)
Create new TestOffchainExt
and a reference to the internal state.
Trait Implementations
sourceimpl Clone for TestOffchainExt
impl Clone for TestOffchainExt
sourcefn clone(&self) -> TestOffchainExt
fn clone(&self) -> TestOffchainExt
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresourceimpl DbExternalities for TestOffchainExt
impl DbExternalities for TestOffchainExt
sourcefn local_storage_set(&mut self, kind: StorageKind, key: &[u8], value: &[u8])
fn local_storage_set(&mut self, kind: StorageKind, key: &[u8], value: &[u8])
Sets a value in the local storage. Read more
sourcefn local_storage_clear(&mut self, kind: StorageKind, key: &[u8])
fn local_storage_clear(&mut self, kind: StorageKind, key: &[u8])
Removes a value in the local storage. Read more
sourcefn local_storage_compare_and_set(
&mut self,
kind: StorageKind,
key: &[u8],
old_value: Option<&[u8]>,
new_value: &[u8]
) -> bool
fn local_storage_compare_and_set(
&mut self,
kind: StorageKind,
key: &[u8],
old_value: Option<&[u8]>,
new_value: &[u8]
) -> bool
Sets a value in the local storage if it matches current value. Read more
sourcefn local_storage_get(&mut self, kind: StorageKind, key: &[u8]) -> Option<Vec<u8>>
fn local_storage_get(&mut self, kind: StorageKind, key: &[u8]) -> Option<Vec<u8>>
Gets a value from the local storage. Read more
sourceimpl Debug for TestOffchainExt
impl Debug for TestOffchainExt
sourceimpl Default for TestOffchainExt
impl Default for TestOffchainExt
sourcefn default() -> TestOffchainExt
fn default() -> TestOffchainExt
Returns the “default value” for a type. Read more
sourceimpl Externalities for TestOffchainExt
impl Externalities for TestOffchainExt
sourcefn is_validator(&self) -> bool
fn is_validator(&self) -> bool
Returns if the local node is a potential validator. Read more
sourcefn network_state(&self) -> Result<OpaqueNetworkState, ()>
fn network_state(&self) -> Result<OpaqueNetworkState, ()>
Returns information about the local node’s network state.
sourcefn sleep_until(&mut self, deadline: Timestamp)
fn sleep_until(&mut self, deadline: Timestamp)
Pause the execution until
deadline
is reached.sourcefn random_seed(&mut self) -> [u8; 32]
fn random_seed(&mut self) -> [u8; 32]
Returns a random seed. Read more
sourcefn http_request_start(
&mut self,
method: &str,
uri: &str,
meta: &[u8]
) -> Result<RequestId, ()>
fn http_request_start(
&mut self,
method: &str,
uri: &str,
meta: &[u8]
) -> Result<RequestId, ()>
Initiates a http request given HTTP verb and the URL. Read more
sourcefn http_request_add_header(
&mut self,
request_id: RequestId,
name: &str,
value: &str
) -> Result<(), ()>
fn http_request_add_header(
&mut self,
request_id: RequestId,
name: &str,
value: &str
) -> Result<(), ()>
Append header to the request. Read more
sourcefn http_request_write_body(
&mut self,
request_id: RequestId,
chunk: &[u8],
_deadline: Option<Timestamp>
) -> Result<(), HttpError>
fn http_request_write_body(
&mut self,
request_id: RequestId,
chunk: &[u8],
_deadline: Option<Timestamp>
) -> Result<(), HttpError>
Write a chunk of request body. Read more
sourcefn http_response_wait(
&mut self,
ids: &[RequestId],
_deadline: Option<Timestamp>
) -> Vec<RequestStatus> ⓘ
fn http_response_wait(
&mut self,
ids: &[RequestId],
_deadline: Option<Timestamp>
) -> Vec<RequestStatus> ⓘ
Block and wait for the responses for given requests. Read more
sourcefn http_response_headers(
&mut self,
request_id: RequestId
) -> Vec<(Vec<u8>, Vec<u8>)> ⓘ
fn http_response_headers(
&mut self,
request_id: RequestId
) -> Vec<(Vec<u8>, Vec<u8>)> ⓘ
Read all response headers. Read more
sourcefn http_response_read_body(
&mut self,
request_id: RequestId,
buffer: &mut [u8],
_deadline: Option<Timestamp>
) -> Result<usize, HttpError>
fn http_response_read_body(
&mut self,
request_id: RequestId,
buffer: &mut [u8],
_deadline: Option<Timestamp>
) -> Result<usize, HttpError>
Read a chunk of body response to given buffer. Read more
Set the authorized nodes from runtime. Read more
Auto Trait Implementations
impl !RefUnwindSafe for TestOffchainExt
impl Send for TestOffchainExt
impl Sync for TestOffchainExt
impl Unpin for TestOffchainExt
impl !UnwindSafe for TestOffchainExt
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
impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
Convert
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
. Read morefn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Convert
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
. Read morefn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s. Read morefn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s. Read moresourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T, Outer> IsWrappedBy<Outer> for Twhere
Outer: AsRef<T> + AsMut<T> + From<T>,
T: From<Outer>,
impl<T, Outer> IsWrappedBy<Outer> for Twhere
Outer: AsRef<T> + AsMut<T> + From<T>,
T: From<Outer>,
sourceimpl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
sourcefn unchecked_into(self) -> T
fn unchecked_into(self) -> T
The counterpart to
unchecked_from
.