Struct tendermint_rpc::MockClient
source · [−]pub struct MockClient<M: MockRequestMatcher> { /* private fields */ }Expand description
A mock client implementation for use in testing.
Examples
use tendermint_rpc::{Client, Method, MockClient, MockRequestMatcher, MockRequestMethodMatcher};
const ABCI_INFO_RESPONSE: &str = r#"{
"jsonrpc": "2.0",
"id": "",
"result": {
"response": {
"data": "GaiaApp",
"version": "0.17.0",
"app_version": "1",
"last_block_height": "488120",
"last_block_app_hash": "2LnCw0fN+Zq/gs5SOuya/GRHUmtWftAqAkTUuoxl4g4="
}
}
}"#;
tokio_test::block_on(async {
let matcher = MockRequestMethodMatcher::default()
.map(Method::AbciInfo, Ok(ABCI_INFO_RESPONSE.to_string()));
let (client, driver) = MockClient::new(matcher);
let driver_hdl = tokio::spawn(async move { driver.run().await });
let abci_info = client.abci_info().await.unwrap();
println!("Got mock ABCI info: {:?}", abci_info);
assert_eq!("GaiaApp".to_string(), abci_info.data);
client.close();
driver_hdl.await.unwrap();
});Implementations
sourceimpl<M: MockRequestMatcher> MockClient<M>
impl<M: MockRequestMatcher> MockClient<M>
Trait Implementations
sourceimpl<M: MockRequestMatcher> Client for MockClient<M>
impl<M: MockRequestMatcher> Client for MockClient<M>
sourcefn perform<'life0, 'async_trait, R>(
&'life0 self,
request: R
) -> Pin<Box<dyn Future<Output = Result<R::Response, Error>> + Send + 'async_trait>> where
R: Request,
R: 'async_trait,
'life0: 'async_trait,
Self: 'async_trait,
fn perform<'life0, 'async_trait, R>(
&'life0 self,
request: R
) -> Pin<Box<dyn Future<Output = Result<R::Response, Error>> + Send + 'async_trait>> where
R: Request,
R: 'async_trait,
'life0: 'async_trait,
Self: 'async_trait,
Perform a request against the RPC endpoint
sourcefn abci_info<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<AbciInfo, Error>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: Sync + 'async_trait,
fn abci_info<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<AbciInfo, Error>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: Sync + 'async_trait,
/abci_info: get information about the ABCI application.
sourcefn abci_query<'life0, 'async_trait, V>(
&'life0 self,
path: Option<Path>,
data: V,
height: Option<Height>,
prove: bool
) -> Pin<Box<dyn Future<Output = Result<AbciQuery, Error>> + Send + 'async_trait>> where
V: Into<Vec<u8>> + Send,
V: 'async_trait,
'life0: 'async_trait,
Self: Sync + 'async_trait,
fn abci_query<'life0, 'async_trait, V>(
&'life0 self,
path: Option<Path>,
data: V,
height: Option<Height>,
prove: bool
) -> Pin<Box<dyn Future<Output = Result<AbciQuery, Error>> + Send + 'async_trait>> where
V: Into<Vec<u8>> + Send,
V: 'async_trait,
'life0: 'async_trait,
Self: Sync + 'async_trait,
/abci_query: query the ABCI application
sourcefn block<'life0, 'async_trait, H>(
&'life0 self,
height: H
) -> Pin<Box<dyn Future<Output = Result<Response, Error>> + Send + 'async_trait>> where
H: Into<Height> + Send,
H: 'async_trait,
'life0: 'async_trait,
Self: Sync + 'async_trait,
fn block<'life0, 'async_trait, H>(
&'life0 self,
height: H
) -> Pin<Box<dyn Future<Output = Result<Response, Error>> + Send + 'async_trait>> where
H: Into<Height> + Send,
H: 'async_trait,
'life0: 'async_trait,
Self: Sync + 'async_trait,
/block: get block at a given height.
sourcefn latest_block<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<Response, Error>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: Sync + 'async_trait,
fn latest_block<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<Response, Error>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: Sync + 'async_trait,
/block: get the latest block.
sourcefn block_results<'life0, 'async_trait, H>(
&'life0 self,
height: H
) -> Pin<Box<dyn Future<Output = Result<Response, Error>> + Send + 'async_trait>> where
H: Into<Height> + Send,
H: 'async_trait,
'life0: 'async_trait,
Self: Sync + 'async_trait,
fn block_results<'life0, 'async_trait, H>(
&'life0 self,
height: H
) -> Pin<Box<dyn Future<Output = Result<Response, Error>> + Send + 'async_trait>> where
H: Into<Height> + Send,
H: 'async_trait,
'life0: 'async_trait,
Self: Sync + 'async_trait,
/block_results: get ABCI results for a block at a particular height.
sourcefn latest_block_results<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<Response, Error>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: Sync + 'async_trait,
fn latest_block_results<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<Response, Error>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: Sync + 'async_trait,
/block_results: get ABCI results for the latest block.
sourcefn block_search<'life0, 'async_trait>(
&'life0 self,
query: Query,
page: u32,
per_page: u8,
order: Order
) -> Pin<Box<dyn Future<Output = Result<Response, Error>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: Sync + 'async_trait,
fn block_search<'life0, 'async_trait>(
&'life0 self,
query: Query,
page: u32,
per_page: u8,
order: Order
) -> Pin<Box<dyn Future<Output = Result<Response, Error>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: Sync + 'async_trait,
/block_search: search for blocks by BeginBlock and EndBlock events.
sourcefn blockchain<'life0, 'async_trait, H>(
&'life0 self,
min: H,
max: H
) -> Pin<Box<dyn Future<Output = Result<Response, Error>> + Send + 'async_trait>> where
H: Into<Height> + Send,
H: 'async_trait,
'life0: 'async_trait,
Self: Sync + 'async_trait,
fn blockchain<'life0, 'async_trait, H>(
&'life0 self,
min: H,
max: H
) -> Pin<Box<dyn Future<Output = Result<Response, Error>> + Send + 'async_trait>> where
H: Into<Height> + Send,
H: 'async_trait,
'life0: 'async_trait,
Self: Sync + 'async_trait,
/blockchain: get block headers for min <= height <= max. Read more
sourcefn broadcast_tx_async<'life0, 'async_trait>(
&'life0 self,
tx: Transaction
) -> Pin<Box<dyn Future<Output = Result<Response, Error>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: Sync + 'async_trait,
fn broadcast_tx_async<'life0, 'async_trait>(
&'life0 self,
tx: Transaction
) -> Pin<Box<dyn Future<Output = Result<Response, Error>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: Sync + 'async_trait,
/broadcast_tx_async: broadcast a transaction, returning immediately.
sourcefn broadcast_tx_sync<'life0, 'async_trait>(
&'life0 self,
tx: Transaction
) -> Pin<Box<dyn Future<Output = Result<Response, Error>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: Sync + 'async_trait,
fn broadcast_tx_sync<'life0, 'async_trait>(
&'life0 self,
tx: Transaction
) -> Pin<Box<dyn Future<Output = Result<Response, Error>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: Sync + 'async_trait,
/broadcast_tx_sync: broadcast a transaction, returning the response
from CheckTx. Read more
sourcefn broadcast_tx_commit<'life0, 'async_trait>(
&'life0 self,
tx: Transaction
) -> Pin<Box<dyn Future<Output = Result<Response, Error>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: Sync + 'async_trait,
fn broadcast_tx_commit<'life0, 'async_trait>(
&'life0 self,
tx: Transaction
) -> Pin<Box<dyn Future<Output = Result<Response, Error>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: Sync + 'async_trait,
/broadcast_tx_commit: broadcast a transaction, returning the response
from DeliverTx. Read more
sourcefn commit<'life0, 'async_trait, H>(
&'life0 self,
height: H
) -> Pin<Box<dyn Future<Output = Result<Response, Error>> + Send + 'async_trait>> where
H: Into<Height> + Send,
H: 'async_trait,
'life0: 'async_trait,
Self: Sync + 'async_trait,
fn commit<'life0, 'async_trait, H>(
&'life0 self,
height: H
) -> Pin<Box<dyn Future<Output = Result<Response, Error>> + Send + 'async_trait>> where
H: Into<Height> + Send,
H: 'async_trait,
'life0: 'async_trait,
Self: Sync + 'async_trait,
/commit: get block commit at a given height.
sourcefn consensus_params<'life0, 'async_trait, H>(
&'life0 self,
height: H
) -> Pin<Box<dyn Future<Output = Result<Response, Error>> + Send + 'async_trait>> where
H: Into<Height> + Send,
H: 'async_trait,
'life0: 'async_trait,
Self: Sync + 'async_trait,
fn consensus_params<'life0, 'async_trait, H>(
&'life0 self,
height: H
) -> Pin<Box<dyn Future<Output = Result<Response, Error>> + Send + 'async_trait>> where
H: Into<Height> + Send,
H: 'async_trait,
'life0: 'async_trait,
Self: Sync + 'async_trait,
/consensus_params: get current consensus parameters at the specified
height. Read more
sourcefn consensus_state<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<Response, Error>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: Sync + 'async_trait,
fn consensus_state<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<Response, Error>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: Sync + 'async_trait,
/consensus_state: get current consensus state
sourcefn validators<'life0, 'async_trait, H>(
&'life0 self,
height: H,
paging: Paging
) -> Pin<Box<dyn Future<Output = Result<Response, Error>> + Send + 'async_trait>> where
H: Into<Height> + Send,
H: 'async_trait,
'life0: 'async_trait,
Self: Sync + 'async_trait,
fn validators<'life0, 'async_trait, H>(
&'life0 self,
height: H,
paging: Paging
) -> Pin<Box<dyn Future<Output = Result<Response, Error>> + Send + 'async_trait>> where
H: Into<Height> + Send,
H: 'async_trait,
'life0: 'async_trait,
Self: Sync + 'async_trait,
/validators: get validators a given height.
sourcefn latest_consensus_params<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<Response, Error>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: Sync + 'async_trait,
fn latest_consensus_params<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<Response, Error>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: Sync + 'async_trait,
/consensus_params: get the latest consensus parameters.
sourcefn latest_commit<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<Response, Error>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: Sync + 'async_trait,
fn latest_commit<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<Response, Error>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: Sync + 'async_trait,
/commit: get the latest block commit
sourcefn health<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: Sync + 'async_trait,
fn health<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: Sync + 'async_trait,
/health: get node health. Read more
sourcefn genesis<'life0, 'async_trait, AppState>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<Genesis<AppState>, Error>> + Send + 'async_trait>> where
AppState: Debug + Serialize + DeserializeOwned + Send,
AppState: 'async_trait,
'life0: 'async_trait,
Self: Sync + 'async_trait,
fn genesis<'life0, 'async_trait, AppState>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<Genesis<AppState>, Error>> + Send + 'async_trait>> where
AppState: Debug + Serialize + DeserializeOwned + Send,
AppState: 'async_trait,
'life0: 'async_trait,
Self: Sync + 'async_trait,
/genesis: get genesis file.
sourcefn net_info<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<Response, Error>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: Sync + 'async_trait,
fn net_info<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<Response, Error>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: Sync + 'async_trait,
/net_info: obtain information about P2P and other network connections.
sourcefn status<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<Response, Error>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: Sync + 'async_trait,
fn status<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<Response, Error>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: Sync + 'async_trait,
/status: get Tendermint status including node info, pubkey, latest
block hash, app hash, block height and time. Read more
sourcefn broadcast_evidence<'life0, 'async_trait>(
&'life0 self,
e: Evidence
) -> Pin<Box<dyn Future<Output = Result<Response, Error>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: Sync + 'async_trait,
fn broadcast_evidence<'life0, 'async_trait>(
&'life0 self,
e: Evidence
) -> Pin<Box<dyn Future<Output = Result<Response, Error>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: Sync + 'async_trait,
/broadcast_evidence: broadcast an evidence.
sourcefn tx<'life0, 'async_trait>(
&'life0 self,
hash: Hash,
prove: bool
) -> Pin<Box<dyn Future<Output = Result<Response, Error>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: Sync + 'async_trait,
fn tx<'life0, 'async_trait>(
&'life0 self,
hash: Hash,
prove: bool
) -> Pin<Box<dyn Future<Output = Result<Response, Error>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: Sync + 'async_trait,
/tx: find transaction by hash.
sourcefn tx_search<'life0, 'async_trait>(
&'life0 self,
query: Query,
prove: bool,
page: u32,
per_page: u8,
order: Order
) -> Pin<Box<dyn Future<Output = Result<Response, Error>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: Sync + 'async_trait,
fn tx_search<'life0, 'async_trait>(
&'life0 self,
query: Query,
prove: bool,
page: u32,
per_page: u8,
order: Order
) -> Pin<Box<dyn Future<Output = Result<Response, Error>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: Sync + 'async_trait,
/tx_search: search for transactions with their results.
sourcefn wait_until_healthy<'life0, 'async_trait, T>(
&'life0 self,
timeout: T
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>> where
T: Into<Duration> + Send,
T: 'async_trait,
'life0: 'async_trait,
Self: Sync + 'async_trait,
fn wait_until_healthy<'life0, 'async_trait, T>(
&'life0 self,
timeout: T
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>> where
T: Into<Duration> + Send,
T: 'async_trait,
'life0: 'async_trait,
Self: Sync + 'async_trait,
Poll the /health endpoint until it returns a successful result or
the given timeout has elapsed. Read more
sourceimpl<M: Debug + MockRequestMatcher> Debug for MockClient<M>
impl<M: Debug + MockRequestMatcher> Debug for MockClient<M>
sourceimpl<M: MockRequestMatcher> SubscriptionClient for MockClient<M>
impl<M: MockRequestMatcher> SubscriptionClient for MockClient<M>
sourcefn subscribe<'life0, 'async_trait>(
&'life0 self,
query: Query
) -> Pin<Box<dyn Future<Output = Result<Subscription, Error>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
fn subscribe<'life0, 'async_trait>(
&'life0 self,
query: Query
) -> Pin<Box<dyn Future<Output = Result<Subscription, Error>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
/subscribe: subscribe to receive events produced by the given query.
Auto Trait Implementations
impl<M> !RefUnwindSafe for MockClient<M>
impl<M> Send for MockClient<M>
impl<M> Sync for MockClient<M>
impl<M> Unpin for MockClient<M> where
M: Unpin,
impl<M> !UnwindSafe for MockClient<M>
Blanket Implementations
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<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