Skip to content

Commit

Permalink
chore: add testing feature, use automock only as test
Browse files Browse the repository at this point in the history
commit-id:c208af25
  • Loading branch information
Itay-Tsabary-Starkware committed Nov 19, 2024
1 parent 7f1752a commit b163d1f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion crates/starknet_gateway_types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,18 @@ edition.workspace = true
license.workspace = true
repository.workspace = true

[features]
testing = ["mockall"]


[lints]
workspace = true

[dependencies]
async-trait.workspace = true
axum.workspace = true
enum-assoc.workspace = true
mockall.workspace = true
mockall = { workspace = true, optional = true }
papyrus_network_types.workspace = true
papyrus_proc_macros.workspace = true
papyrus_rpc.workspace = true
Expand All @@ -22,3 +26,7 @@ starknet_api.workspace = true
starknet_sequencer_infra.workspace = true
thiserror.workspace = true
tracing.workspace = true

[dev-dependencies]
# Enable self with "testing" feature in tests.
starknet_gateway_types = { workspace = true, features = ["testing"] }
6 changes: 3 additions & 3 deletions crates/starknet_gateway_types/src/communication.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use std::sync::Arc;

use async_trait::async_trait;
use mockall::predicate::*;
use mockall::*;
#[cfg(any(feature = "testing", test))]
use mockall::automock;
use papyrus_proc_macros::handle_response_variants;
use serde::{Deserialize, Serialize};
use starknet_api::transaction::TransactionHash;
Expand Down Expand Up @@ -30,7 +30,7 @@ use tracing::{error, instrument};

/// Serves as the gateway's shared interface. Requires `Send + Sync` to allow transferring
/// and sharing resources (inputs, futures) across threads.
#[automock]
#[cfg_attr(any(feature = "testing", test), automock)]
#[async_trait]
pub trait GatewayClient: Send + Sync {
async fn add_tx(&self, gateway_input: GatewayInput) -> GatewayClientResult<TransactionHash>;
Expand Down

0 comments on commit b163d1f

Please sign in to comment.