Struct solana_client::mock_sender::MockSender
source · [−]pub struct MockSender { /* private fields */ }
Implementations
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
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
pub default fn example() -> T
Mutably borrows from an owned value. Read more
pub fn vzip(self) -> V
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more