Struct tendermint_rpc::MockClient [−][src]
pub struct MockClient<M: MockRequestMatcher> { /* fields omitted */ }
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
Create a new mock RPC client using the given request matcher.
Publishes the given event to all subscribers whose query exactly matches that of the event.
Trait Implementations
Perform a request against the RPC endpoint
/abci_info
: get information about the ABCI application.
/abci_query
: query the ABCI application
/block
: get block at a given height.
/block
: get the latest block.
/block_results
: get ABCI results for a block at a particular height.
/block_results
: get ABCI results for the latest block.
/block_search
: search for blocks by BeginBlock and EndBlock events.
/blockchain
: get block headers for min
<= height
<= max
. Read more
/broadcast_tx_async
: broadcast a transaction, returning immediately.
/broadcast_tx_sync
: broadcast a transaction, returning the response
from CheckTx
. Read more
/broadcast_tx_commit
: broadcast a transaction, returning the response
from DeliverTx
. Read more
/commit
: get block commit at a given height.
/consensus_params
: get current consensus parameters at the specified
height. Read more
/consensus_state
: get current consensus state
/validators
: get validators a given height.
/consensus_params
: get the latest consensus parameters.
/commit
: get the latest block commit
/health
: get node health. Read more
/genesis
: get genesis file.
/net_info
: obtain information about P2P and other network connections.
/status
: get Tendermint status including node info, pubkey, latest
block hash, app hash, block height and time. Read more
/broadcast_evidence
: broadcast an evidence.
/tx
: find transaction by hash.
/tx_search
: search for transactions with their results.
Poll the /health
endpoint until it returns a successful result or
the given timeout
has elapsed. Read more
/subscribe
: subscribe to receive events produced by the given query.
/unsubscribe
: unsubscribe from events relating to the given query. Read more
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
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