Skip to content

Commit

Permalink
refactor: add mock feature flag
Browse files Browse the repository at this point in the history
  • Loading branch information
gusinacio committed Dec 14, 2023
1 parent dfe7fde commit aa3203b
Show file tree
Hide file tree
Showing 11 changed files with 19 additions and 18 deletions.
5 changes: 5 additions & 0 deletions tap_core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ tokio = { version = "1.29.1", features = ["macros", "rt-multi-thread"] }
[dev-dependencies]
criterion = { version = "0.5", features = ["async_std"] }
futures = "0.3.17"
tap_core = { path = ".", features = ["mock"] }


[features]
mock = []

[[bench]]
name = 'timeline_aggretion_protocol_benchmark'
Expand Down
7 changes: 7 additions & 0 deletions tap_core/src/adapters/mock.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Copyright 2023-, Semiotic AI, Inc.
// SPDX-License-Identifier: Apache-2.0

pub mod escrow_adapter_mock;
pub mod rav_storage_adapter_mock;
pub mod receipt_checks_adapter_mock;
pub mod receipt_storage_adapter_mock;
12 changes: 7 additions & 5 deletions tap_core/src/adapters/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ pub mod rav_storage_adapter;
pub mod receipt_checks_adapter;
pub mod receipt_storage_adapter;

mod test;
#[cfg(feature = "mock")]
mod mock;

#[cfg(feature = "mock")]
pub use mock::*;

pub use test::escrow_adapter_mock;
pub use test::rav_storage_adapter_mock;
pub use test::receipt_checks_adapter_mock;
pub use test::receipt_storage_adapter_mock;
#[cfg(test)]
mod test;
1 change: 0 additions & 1 deletion tap_core/src/adapters/rav_storage_adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ pub trait RAVStore {
async fn update_last_rav(&self, rav: SignedRAV) -> Result<(), Self::AdapterError>;
}


/// `RAVRead` defines a trait for read storage adapters to handle `SignedRAV` data.
///
/// This trait is designed to be implemented by users of this library who want to
Expand Down
6 changes: 0 additions & 6 deletions tap_core/src/adapters/receipt_storage_adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,6 @@ pub trait ReceiptStore {
) -> Result<(), Self::AdapterError>;
}



/// `ReceiptRead` defines a trait for read storage adapters to manage `ReceivedReceipt` data.
///
/// This trait is designed to be implemented by users of this library who want to
Expand Down Expand Up @@ -118,12 +116,8 @@ pub trait ReceiptRead {
timestamp_range_ns: R,
limit: Option<u64>,
) -> Result<Vec<(u64, ReceivedReceipt)>, Self::AdapterError>;

}




/// See [`ReceiptStorageAdapter::retrieve_receipts_in_timestamp_range()`] for details.
///
/// WARNING: Will sort the receipts by timestamp using
Expand Down
5 changes: 0 additions & 5 deletions tap_core/src/adapters/test/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,3 @@ pub mod escrow_adapter_test;
pub mod rav_storage_adapter_test;
pub mod receipt_checks_adapter_test;
pub mod receipt_storage_adapter_test;

pub mod escrow_adapter_mock;
pub mod rav_storage_adapter_mock;
pub mod receipt_checks_adapter_mock;
pub mod receipt_storage_adapter_mock;
1 change: 0 additions & 1 deletion tap_core/src/tap_manager/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ where
EA: EscrowAdapter,
RCA: ReceiptChecksAdapter,
RSA: ReceiptRead,
// RAVSA: RAVRead,
{
async fn collect_receipts(
&self,
Expand Down

0 comments on commit aa3203b

Please sign in to comment.