Skip to content

Commit

Permalink
style: fix clippy
Browse files Browse the repository at this point in the history
Signed-off-by: Gustavo Inacio <[email protected]>
  • Loading branch information
gusinacio committed Dec 28, 2023
1 parent 6794fbb commit 49e0790
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 50 deletions.
7 changes: 5 additions & 2 deletions tap_core/src/adapters/mock/executor_mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ use std::{
};
use tokio::sync::RwLock;

pub type EscrowStorage = Arc<RwLock<HashMap<Address, u128>>>;
pub type QueryAppraisals = Arc<RwLock<HashMap<u64, u128>>>;

/// `RAVStorageAdapterMock` is a mock implementation of the `RAVStorageAdapter` trait.
///
/// It serves two main purposes:
Expand Down Expand Up @@ -57,9 +60,9 @@ pub struct ExecutorMock {
receipt_storage: Arc<RwLock<HashMap<u64, ReceivedReceipt>>>,
unique_id: Arc<RwLock<u64>>,

sender_escrow_storage: Arc<RwLock<HashMap<Address, u128>>>,
sender_escrow_storage: EscrowStorage,

query_appraisals: Arc<RwLock<HashMap<u64, u128>>>,
query_appraisals: QueryAppraisals,
allocation_ids: Arc<RwLock<HashSet<Address>>>,
sender_ids: Arc<RwLock<HashSet<Address>>>,
}
Expand Down
35 changes: 8 additions & 27 deletions tap_core/src/tap_manager/test/manager_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ mod manager_unit_test {
use super::super::Manager;
use crate::{
adapters::{
escrow_adapter_mock::EscrowAdapterMock, executor_mock::ExecutorMock,
escrow_adapter_mock::EscrowAdapterMock,
executor_mock::{EscrowStorage, ExecutorMock, QueryAppraisals},
receipt_checks_adapter_mock::ReceiptChecksAdapterMock,
receipt_storage_adapter::ReceiptRead,
},
Expand Down Expand Up @@ -71,11 +72,7 @@ mod manager_unit_test {
}

#[fixture]
fn executor_mock() -> (
ExecutorMock,
Arc<RwLock<HashMap<Address, u128>>>,
Arc<RwLock<HashMap<u64, u128>>>,
) {
fn executor_mock() -> (ExecutorMock, EscrowStorage, QueryAppraisals) {
let rav_storage = Arc::new(RwLock::new(None));
let receipt_storage = Arc::new(RwLock::new(HashMap::new()));

Expand All @@ -100,7 +97,7 @@ mod manager_unit_test {
}

#[fixture]
fn escrow_adapters() -> (EscrowAdapterMock, Arc<RwLock<HashMap<Address, u128>>>) {
fn escrow_adapters() -> (EscrowAdapterMock, EscrowStorage) {
let sender_escrow_storage = Arc::new(RwLock::new(HashMap::new()));
let escrow_adapter = EscrowAdapterMock::new(Arc::clone(&sender_escrow_storage));
(escrow_adapter, sender_escrow_storage)
Expand Down Expand Up @@ -130,11 +127,7 @@ mod manager_unit_test {
#[case::no_checks(Vec::<ReceiptCheck>::new())]
#[tokio::test]
async fn manager_verify_and_store_varying_initial_checks(
executor_mock: (
ExecutorMock,
Arc<RwLock<HashMap<Address, u128>>>,
Arc<RwLock<HashMap<u64, u128>>>,
),
executor_mock: (ExecutorMock, EscrowStorage, QueryAppraisals),
keys: (LocalWallet, Address),
allocation_ids: Vec<Address>,
domain_separator: Eip712Domain,
Expand Down Expand Up @@ -178,11 +171,7 @@ mod manager_unit_test {
#[case::no_checks(Vec::<ReceiptCheck>::new())]
#[tokio::test]
async fn manager_create_rav_request_all_valid_receipts(
executor_mock: (
ExecutorMock,
Arc<RwLock<HashMap<Address, u128>>>,
Arc<RwLock<HashMap<u64, u128>>>,
),
executor_mock: (ExecutorMock, EscrowStorage, QueryAppraisals),
keys: (LocalWallet, Address),
allocation_ids: Vec<Address>,
domain_separator: Eip712Domain,
Expand Down Expand Up @@ -248,11 +237,7 @@ mod manager_unit_test {
#[case::no_checks(Vec::<ReceiptCheck>::new())]
#[tokio::test]
async fn manager_create_multiple_rav_requests_all_valid_receipts(
executor_mock: (
ExecutorMock,
Arc<RwLock<HashMap<Address, u128>>>,
Arc<RwLock<HashMap<u64, u128>>>,
),
executor_mock: (ExecutorMock, EscrowStorage, QueryAppraisals),
keys: (LocalWallet, Address),
allocation_ids: Vec<Address>,
domain_separator: Eip712Domain,
Expand Down Expand Up @@ -374,11 +359,7 @@ mod manager_unit_test {
#[rstest]
#[tokio::test]
async fn manager_create_multiple_rav_requests_all_valid_receipts_consecutive_timestamps(
executor_mock: (
ExecutorMock,
Arc<RwLock<HashMap<Address, u128>>>,
Arc<RwLock<HashMap<u64, u128>>>,
),
executor_mock: (ExecutorMock, EscrowStorage, QueryAppraisals),
keys: (LocalWallet, Address),
allocation_ids: Vec<Address>,
domain_separator: Eip712Domain,
Expand Down
28 changes: 7 additions & 21 deletions tap_core/src/tap_receipt/tests/received_receipt_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ mod received_receipt_unit_test {

use crate::{
adapters::{
auditor_executor_mock::AuditorExecutorMock, escrow_adapter_mock::EscrowAdapterMock,
auditor_executor_mock::AuditorExecutorMock,
escrow_adapter_mock::EscrowAdapterMock,
executor_mock::{EscrowStorage, QueryAppraisals},
receipt_checks_adapter_mock::ReceiptChecksAdapterMock,
receipt_storage_adapter_mock::ReceiptStorageAdapterMock,
},
Expand Down Expand Up @@ -96,11 +98,7 @@ mod received_receipt_unit_test {
}

#[fixture]
fn auditor_executor() -> (
AuditorExecutorMock,
Arc<RwLock<HashMap<Address, u128>>>,
Arc<RwLock<HashMap<u64, u128>>>,
) {
fn auditor_executor() -> (AuditorExecutorMock, EscrowStorage, QueryAppraisals) {
let sender_escrow_storage = Arc::new(RwLock::new(HashMap::new()));

let receipt_storage = Arc::new(RwLock::new(HashMap::new()));
Expand Down Expand Up @@ -165,11 +163,7 @@ mod received_receipt_unit_test {
keys: (LocalWallet, Address),
domain_separator: Eip712Domain,
allocation_ids: Vec<Address>,
auditor_executor: (
AuditorExecutorMock,
Arc<RwLock<HashMap<Address, u128>>>,
Arc<RwLock<HashMap<u64, u128>>>,
),
auditor_executor: (AuditorExecutorMock, EscrowStorage, QueryAppraisals),
) {
let (executor, escrow_storage, query_appraisal_storage) = auditor_executor;
// give receipt 5 second variance for min start time
Expand Down Expand Up @@ -233,11 +227,7 @@ mod received_receipt_unit_test {
keys: (LocalWallet, Address),
allocation_ids: Vec<Address>,
domain_separator: Eip712Domain,
auditor_executor: (
AuditorExecutorMock,
Arc<RwLock<HashMap<Address, u128>>>,
Arc<RwLock<HashMap<u64, u128>>>,
),
auditor_executor: (AuditorExecutorMock, EscrowStorage, QueryAppraisals),
) {
let (executor, escrow_storage, query_appraisal_storage) = auditor_executor;
// give receipt 5 second variance for min start time
Expand Down Expand Up @@ -302,11 +292,7 @@ mod received_receipt_unit_test {
keys: (LocalWallet, Address),
allocation_ids: Vec<Address>,
domain_separator: Eip712Domain,
auditor_executor: (
AuditorExecutorMock,
Arc<RwLock<HashMap<Address, u128>>>,
Arc<RwLock<HashMap<u64, u128>>>,
),
auditor_executor: (AuditorExecutorMock, EscrowStorage, QueryAppraisals),
) {
let (executor, escrow_storage, query_appraisal_storage) = auditor_executor;
// give receipt 5 second variance for min start time
Expand Down

0 comments on commit 49e0790

Please sign in to comment.