penumbra_sdk_mock_tendermint_proxy/
stub.rs

1use {
2    penumbra_sdk_proto::util::tendermint_proxy::v1::{
3        tendermint_proxy_service_server::TendermintProxyService, AbciQueryRequest,
4        AbciQueryResponse, BroadcastTxAsyncRequest, BroadcastTxAsyncResponse,
5        BroadcastTxSyncRequest, BroadcastTxSyncResponse, GetBlockByHeightRequest,
6        GetBlockByHeightResponse, GetStatusRequest, GetStatusResponse, GetTxRequest, GetTxResponse,
7    },
8    tonic::Status,
9    tracing::instrument,
10};
11
12/// A tendermint proxy service for use in tests.
13///
14/// This implements [`TendermintProxyService`], but will return a [`Status::unimplemented`] error
15/// for any requests it receives.
16pub struct StubProxy;
17
18#[tonic::async_trait]
19impl TendermintProxyService for StubProxy {
20    async fn get_tx(
21        &self,
22        _req: tonic::Request<GetTxRequest>,
23    ) -> Result<tonic::Response<GetTxResponse>, Status> {
24        Err(Status::unimplemented("get_tx"))
25    }
26
27    /// Broadcasts a transaction asynchronously.
28    #[instrument(
29        level = "info",
30        skip_all,
31        fields(req_id = tracing::field::Empty),
32    )]
33    async fn broadcast_tx_async(
34        &self,
35        _req: tonic::Request<BroadcastTxAsyncRequest>,
36    ) -> Result<tonic::Response<BroadcastTxAsyncResponse>, Status> {
37        Err(Status::unimplemented("broadcast_tx_async"))
38    }
39
40    // Broadcasts a transaction synchronously.
41    #[instrument(
42        level = "info",
43        skip_all,
44        fields(req_id = tracing::field::Empty),
45    )]
46    async fn broadcast_tx_sync(
47        &self,
48        _req: tonic::Request<BroadcastTxSyncRequest>,
49    ) -> Result<tonic::Response<BroadcastTxSyncResponse>, Status> {
50        Err(Status::unimplemented("broadcast_tx_sync"))
51    }
52
53    // Queries the current status.
54    #[instrument(level = "info", skip_all)]
55    async fn get_status(
56        &self,
57        __req: tonic::Request<GetStatusRequest>,
58    ) -> Result<tonic::Response<GetStatusResponse>, Status> {
59        Err(Status::unimplemented("get_status"))
60    }
61
62    #[instrument(level = "info", skip_all)]
63    async fn abci_query(
64        &self,
65        _req: tonic::Request<AbciQueryRequest>,
66    ) -> Result<tonic::Response<AbciQueryResponse>, Status> {
67        Err(Status::unimplemented("abci_query"))
68    }
69
70    #[instrument(level = "info", skip_all)]
71    async fn get_block_by_height(
72        &self,
73        _req: tonic::Request<GetBlockByHeightRequest>,
74    ) -> Result<tonic::Response<GetBlockByHeightResponse>, Status> {
75        Err(Status::unimplemented("get_block_by_height"))
76    }
77}