Skip to content

Commit

Permalink
hide mock() methods behind cfg(test) or feature
Browse files Browse the repository at this point in the history
  • Loading branch information
arya2 committed Jan 31, 2024
1 parent 3742711 commit 0e1061d
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions zebra-scan/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ categories = ["cryptography::cryptocurrencies"]
[[bin]] # Bin to run the Scanner gRPC server
name = "scanner-grpc-server"
path = "src/bin/rpc_server.rs"
required-features = ["proptest-impl"]

[features]

Expand Down
1 change: 1 addition & 0 deletions zebra-scan/src/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ pub struct ScanTask {

impl ScanTask {
/// Spawns a new [`ScanTask`] for tests.
#[cfg(any(test, feature = "proptest-impl"))]
pub fn mock() -> (Self, Receiver<ScanTaskCommand>) {
let (cmd_sender, cmd_receiver) = mpsc::channel();

Expand Down
1 change: 1 addition & 0 deletions zebra-scan/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ impl ScanService {
}

/// Create a new [`ScanService`] with a mock `ScanTask`
#[cfg(any(test, feature = "proptest-impl"))]
pub fn new_with_mock_scanner(db: Storage) -> (Self, Receiver<ScanTaskCommand>) {
let (scan_task, cmd_receiver) = ScanTask::mock();
(Self { db, scan_task }, cmd_receiver)
Expand Down

0 comments on commit 0e1061d

Please sign in to comment.