Struct solana_client::mock_sender::MockSender
source · [−]pub struct MockSender { /* private fields */ }
Implementations
sourceimpl MockSender
impl MockSender
An RpcSender
used for unit testing RpcClient
.
This is primarily for internal use.
Unless directed otherwise, it will generally return a reasonable default
response, at least for RpcRequest
values for which responses have been
implemented.
The behavior can be customized in two ways:
-
The
url
constructor argument is not actually a URL, but a simple string directive that changesMockSender
s behavior in specific scenarios.If
url
is “fails” then any call tosend
will returnOk(Value::Null)
.It is customary to set the
url
to “succeeds” for mocks that should return sucessfully, though this value is not actually interpreted.Other possible values of
url
are specific to differentRpcRequest
values. Read the implementation for specifics. -
Custom responses can be configured by providing
Mocks
to theMockSender::new_with_mocks
constructor. This type is aHashMap
fromRpcRequest
to a JSONValue
response, Any entries in this map override the default behavior for the given request.
Trait Implementations
sourceimpl RpcSender for MockSender
impl RpcSender for MockSender
fn get_transport_stats(&self) -> RpcTransportStats
fn send(&self, request: RpcRequest, params: Value) -> Result<Value>
Auto Trait Implementations
impl RefUnwindSafe for MockSender
impl Send for MockSender
impl Sync for MockSender
impl Unpin for MockSender
impl UnwindSafe for MockSender
Blanket Implementations
impl<T> AbiExample for T
impl<T> AbiExample for T
default fn example() -> T
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
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
sourceimpl<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>
impl<T> Pointable for T
impl<T> Pointable for T
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more