diff --git a/tap_core/Cargo.toml b/tap_core/Cargo.toml index 18476b6f..8c9f64cb 100644 --- a/tap_core/Cargo.toml +++ b/tap_core/Cargo.toml @@ -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' diff --git a/tap_core/src/adapters/mock.rs b/tap_core/src/adapters/mock.rs new file mode 100644 index 00000000..4b0fe771 --- /dev/null +++ b/tap_core/src/adapters/mock.rs @@ -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; diff --git a/tap_core/src/adapters/test/escrow_adapter_mock.rs b/tap_core/src/adapters/mock/escrow_adapter_mock.rs similarity index 100% rename from tap_core/src/adapters/test/escrow_adapter_mock.rs rename to tap_core/src/adapters/mock/escrow_adapter_mock.rs diff --git a/tap_core/src/adapters/test/rav_storage_adapter_mock.rs b/tap_core/src/adapters/mock/rav_storage_adapter_mock.rs similarity index 100% rename from tap_core/src/adapters/test/rav_storage_adapter_mock.rs rename to tap_core/src/adapters/mock/rav_storage_adapter_mock.rs diff --git a/tap_core/src/adapters/test/receipt_checks_adapter_mock.rs b/tap_core/src/adapters/mock/receipt_checks_adapter_mock.rs similarity index 100% rename from tap_core/src/adapters/test/receipt_checks_adapter_mock.rs rename to tap_core/src/adapters/mock/receipt_checks_adapter_mock.rs diff --git a/tap_core/src/adapters/test/receipt_storage_adapter_mock.rs b/tap_core/src/adapters/mock/receipt_storage_adapter_mock.rs similarity index 100% rename from tap_core/src/adapters/test/receipt_storage_adapter_mock.rs rename to tap_core/src/adapters/mock/receipt_storage_adapter_mock.rs diff --git a/tap_core/src/adapters/mod.rs b/tap_core/src/adapters/mod.rs index aea7be53..96ab5cea 100644 --- a/tap_core/src/adapters/mod.rs +++ b/tap_core/src/adapters/mod.rs @@ -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; diff --git a/tap_core/src/adapters/rav_storage_adapter.rs b/tap_core/src/adapters/rav_storage_adapter.rs index 0188a647..aee6c1be 100644 --- a/tap_core/src/adapters/rav_storage_adapter.rs +++ b/tap_core/src/adapters/rav_storage_adapter.rs @@ -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 diff --git a/tap_core/src/adapters/receipt_storage_adapter.rs b/tap_core/src/adapters/receipt_storage_adapter.rs index 962eb8f9..be98c215 100644 --- a/tap_core/src/adapters/receipt_storage_adapter.rs +++ b/tap_core/src/adapters/receipt_storage_adapter.rs @@ -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 @@ -118,12 +116,8 @@ pub trait ReceiptRead { timestamp_range_ns: R, limit: Option, ) -> Result, Self::AdapterError>; - } - - - /// See [`ReceiptStorageAdapter::retrieve_receipts_in_timestamp_range()`] for details. /// /// WARNING: Will sort the receipts by timestamp using diff --git a/tap_core/src/adapters/test/mod.rs b/tap_core/src/adapters/test/mod.rs index 9940e265..318c6216 100644 --- a/tap_core/src/adapters/test/mod.rs +++ b/tap_core/src/adapters/test/mod.rs @@ -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; diff --git a/tap_core/src/tap_manager/manager.rs b/tap_core/src/tap_manager/manager.rs index f29eb629..2c2bb6bc 100644 --- a/tap_core/src/tap_manager/manager.rs +++ b/tap_core/src/tap_manager/manager.rs @@ -116,7 +116,6 @@ where EA: EscrowAdapter, RCA: ReceiptChecksAdapter, RSA: ReceiptRead, - // RAVSA: RAVRead, { async fn collect_receipts( &self,