Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add testing feature, use automock only as test #2159

Merged
merged 1 commit into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.

9 changes: 8 additions & 1 deletion crates/starknet_gateway_types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@ 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 +25,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
Loading