From 5851af0418a910e73b93e31ad3a9427934a12a20 Mon Sep 17 00:00:00 2001 From: DJO <790521+Alenar@users.noreply.github.com> Date: Tue, 22 Jul 2025 17:05:30 +0200 Subject: [PATCH 01/15] refactor(common): move `fake_data` & `fake_keys` to `test_utils::double` plus `precomputed_kes_key` --- .../src/test/double/chain_observer.rs | 2 +- internal/tests/mithril-api-spec/src/apispec.rs | 5 ++++- .../src/artifact_builder/cardano_database.rs | 5 ++++- .../artifact_builder/cardano_immutable_files_full.rs | 2 +- .../artifact_builder/cardano_stake_distribution.rs | 2 +- .../src/artifact_builder/cardano_transactions.rs | 2 +- .../artifact_builder/mithril_stake_distribution.rs | 2 +- .../certificate/insert_or_replace_certificate.rs | 2 +- .../query/epoch_settings/update_epoch_settings.rs | 2 +- .../query/signed_entity/get_signed_entity.rs | 2 +- .../record/buffered_single_signature_record.rs | 2 +- .../src/database/record/certificate.rs | 2 +- .../src/database/record/signed_entity.rs | 4 ++-- .../src/database/record/single_signature.rs | 2 +- .../buffered_single_signature_repository.rs | 2 +- .../src/database/repository/signed_entity_store.rs | 2 +- .../database/repository/signer_registration_store.rs | 2 +- mithril-aggregator/src/database/test_helper.rs | 2 +- mithril-aggregator/src/entities/open_message.rs | 2 +- .../src/event_store/database/repository.rs | 2 +- .../http_server/routes/artifact_routes/snapshot.rs | 2 +- .../src/http_server/routes/certificate_routes.rs | 2 +- .../src/http_server/routes/proof_routes.rs | 5 ++++- .../src/http_server/routes/signer_routes.rs | 5 ++++- mithril-aggregator/src/http_server/routes/status.rs | 5 ++++- mithril-aggregator/src/multi_signer.rs | 5 ++++- mithril-aggregator/src/runtime/runner.rs | 5 ++++- mithril-aggregator/src/runtime/state_machine.rs | 2 +- mithril-aggregator/src/services/aggregator_client.rs | 2 +- .../synchronizer_service.rs | 3 ++- .../src/services/certifier/buffered_certifier.rs | 2 +- .../src/services/certifier/certifier_service.rs | 2 +- mithril-aggregator/src/services/epoch_service.rs | 6 +++--- mithril-aggregator/src/services/message.rs | 2 +- .../src/services/signature_consumer/dmq.rs | 2 +- .../src/services/signature_consumer/fake.rs | 2 +- .../src/services/signature_processor.rs | 2 +- mithril-aggregator/src/services/signed_entity.rs | 2 +- .../snapshotter/compressed_archive_snapshotter.rs | 2 +- mithril-aggregator/src/test/double/dummies.rs | 2 +- mithril-aggregator/src/tools/genesis.rs | 2 +- .../download_unpack/download_task.rs | 2 +- .../download_unpack/internal_downloader.rs | 2 +- mithril-client/src/certificate_client/fetch.rs | 2 +- .../certificate_client/verify_cache/memory_cache.rs | 2 +- .../src/mithril_stake_distribution_client.rs | 2 +- mithril-client/src/snapshot_client.rs | 2 +- mithril-client/src/utils/ancillary_verifier.rs | 2 +- .../cardano_db_snapshot_list_get_download_verify.rs | 5 ++--- mithril-client/tests/cardano_transaction_proof.rs | 7 ++++--- mithril-client/tests/certificate_get_list.rs | 7 ++++--- .../extensions/fake_aggregator/cardano_db_v1.rs | 2 +- .../extensions/fake_aggregator/cardano_db_v2.rs | 2 +- ...ithril_stake_distribution_list_get_show_verify.rs | 7 ++++--- .../tests/snapshot_list_get_show_download_verify.rs | 4 ++-- .../certificate_chain/fake_certificate_retriever.rs | 2 +- .../src/crypto_helper/types/protocol_key.rs | 2 +- mithril-common/src/entities/certificate.rs | 8 +++++--- .../src/entities/mithril_stake_distribution.rs | 2 +- mithril-common/src/entities/signed_entity_config.rs | 2 +- mithril-common/src/entities/signer.rs | 2 +- .../src/messages/mithril_stake_distribution.rs | 2 +- mithril-common/src/protocol/multi_signer.rs | 2 +- mithril-common/src/protocol/signer_builder.rs | 2 +- .../src/test_utils/certificate_chain_builder.rs | 12 +++++------- mithril-common/src/test_utils/double/dummies.rs | 4 +--- .../src/test_utils/{ => double}/fake_data.rs | 0 .../src/test_utils/{ => double}/fake_keys.rs | 0 mithril-common/src/test_utils/double/mod.rs | 3 +++ .../test_utils/{ => double}/precomputed_kes_key.rs | 0 mithril-common/src/test_utils/fixture_builder.rs | 4 ++-- mithril-common/src/test_utils/mod.rs | 3 --- .../src/database/tests/protocol_initializer.rs | 2 +- mithril-signer/src/entities/signer_epoch_settings.rs | 2 +- .../to_register_signature_message.rs | 2 +- .../message_adapters/to_register_signer_message.rs | 2 +- mithril-signer/src/runtime/runner.rs | 5 ++++- mithril-signer/src/runtime/state_machine.rs | 2 +- mithril-signer/src/services/aggregator_client.rs | 5 ++++- mithril-signer/src/services/certifier.rs | 2 +- mithril-signer/src/services/epoch_service.rs | 7 +++++-- .../src/services/signature_publisher/delayer.rs | 2 +- .../src/services/signature_publisher/dmq.rs | 2 +- .../src/services/signature_publisher/retrier.rs | 2 +- .../tests/test_extensions/certificate_handler.rs | 4 ++-- 85 files changed, 139 insertions(+), 108 deletions(-) rename mithril-common/src/test_utils/{ => double}/fake_data.rs (100%) rename mithril-common/src/test_utils/{ => double}/fake_keys.rs (100%) rename mithril-common/src/test_utils/{ => double}/precomputed_kes_key.rs (100%) diff --git a/internal/cardano-node/mithril-cardano-node-chain/src/test/double/chain_observer.rs b/internal/cardano-node/mithril-cardano-node-chain/src/test/double/chain_observer.rs index 0c671a5bc5e..00843c5e92f 100644 --- a/internal/cardano-node/mithril-cardano-node-chain/src/test/double/chain_observer.rs +++ b/internal/cardano-node/mithril-cardano-node-chain/src/test/double/chain_observer.rs @@ -212,7 +212,7 @@ impl ChainObserver for FakeChainObserver { #[cfg(test)] mod tests { - use mithril_common::test_utils::{double::Dummy, fake_data}; + use mithril_common::test_utils::double::{Dummy, fake_data}; use super::*; diff --git a/internal/tests/mithril-api-spec/src/apispec.rs b/internal/tests/mithril-api-spec/src/apispec.rs index 7f41cb3dcf4..b0cb3fa3c4a 100644 --- a/internal/tests/mithril-api-spec/src/apispec.rs +++ b/internal/tests/mithril-api-spec/src/apispec.rs @@ -343,7 +343,10 @@ mod tests { use mithril_common::entities; use mithril_common::messages::{AggregatorFeaturesMessage, SignerMessagePart}; - use mithril_common::test_utils::{TempDir, double::Dummy, fake_data}; + use mithril_common::test_utils::{ + TempDir, + double::{Dummy, fake_data}, + }; use super::*; diff --git a/mithril-aggregator/src/artifact_builder/cardano_database.rs b/mithril-aggregator/src/artifact_builder/cardano_database.rs index cd4e66cf8b6..2099701d73d 100644 --- a/mithril-aggregator/src/artifact_builder/cardano_database.rs +++ b/mithril-aggregator/src/artifact_builder/cardano_database.rs @@ -112,7 +112,10 @@ mod tests { ImmutablesLocation, MultiFilesUri, ProtocolMessage, ProtocolMessagePartKey, TemplateUri, }, - test_utils::{TempDir, fake_data, fake_keys}, + test_utils::{ + TempDir, + double::{fake_data, fake_keys}, + }, }; use crate::{ diff --git a/mithril-aggregator/src/artifact_builder/cardano_immutable_files_full.rs b/mithril-aggregator/src/artifact_builder/cardano_immutable_files_full.rs index a0b4aebd86b..79693f87005 100644 --- a/mithril-aggregator/src/artifact_builder/cardano_immutable_files_full.rs +++ b/mithril-aggregator/src/artifact_builder/cardano_immutable_files_full.rs @@ -206,7 +206,7 @@ mod tests { use anyhow::anyhow; use tempfile::NamedTempFile; - use mithril_common::{entities::CompressionAlgorithm, test_utils::fake_data}; + use mithril_common::{entities::CompressionAlgorithm, test_utils::double::fake_data}; use crate::{ DumbUploader, file_uploaders::MockFileUploader, services::DumbSnapshotter, diff --git a/mithril-aggregator/src/artifact_builder/cardano_stake_distribution.rs b/mithril-aggregator/src/artifact_builder/cardano_stake_distribution.rs index 305ba745c8a..39b00b0ca41 100644 --- a/mithril-aggregator/src/artifact_builder/cardano_stake_distribution.rs +++ b/mithril-aggregator/src/artifact_builder/cardano_stake_distribution.rs @@ -43,7 +43,7 @@ impl ArtifactBuilder for CardanoStakeDistributi #[cfg(test)] mod tests { - use mithril_common::{entities::StakeDistribution, test_utils::fake_data}; + use mithril_common::{entities::StakeDistribution, test_utils::double::fake_data}; use mockall::{mock, predicate::eq}; use super::*; diff --git a/mithril-aggregator/src/artifact_builder/cardano_transactions.rs b/mithril-aggregator/src/artifact_builder/cardano_transactions.rs index d845efb57af..83ece810522 100644 --- a/mithril-aggregator/src/artifact_builder/cardano_transactions.rs +++ b/mithril-aggregator/src/artifact_builder/cardano_transactions.rs @@ -58,7 +58,7 @@ impl ArtifactBuilder #[cfg(test)] mod tests { - use mithril_common::{entities::ProtocolMessage, test_utils::fake_data}; + use mithril_common::{entities::ProtocolMessage, test_utils::double::fake_data}; use crate::services::MockProverService; diff --git a/mithril-aggregator/src/artifact_builder/mithril_stake_distribution.rs b/mithril-aggregator/src/artifact_builder/mithril_stake_distribution.rs index a858d606135..c80721ff709 100644 --- a/mithril-aggregator/src/artifact_builder/mithril_stake_distribution.rs +++ b/mithril-aggregator/src/artifact_builder/mithril_stake_distribution.rs @@ -40,7 +40,7 @@ impl ArtifactBuilder for MithrilStakeDistributi mod tests { use mithril_common::{ crypto_helper::ProtocolParameters, - test_utils::{double::Dummy, fake_data}, + test_utils::double::{Dummy, fake_data}, }; use std::sync::Arc; use tokio::sync::RwLock; diff --git a/mithril-aggregator/src/database/query/certificate/insert_or_replace_certificate.rs b/mithril-aggregator/src/database/query/certificate/insert_or_replace_certificate.rs index fa34bb91588..f5f94fc27c7 100644 --- a/mithril-aggregator/src/database/query/certificate/insert_or_replace_certificate.rs +++ b/mithril-aggregator/src/database/query/certificate/insert_or_replace_certificate.rs @@ -40,7 +40,7 @@ mod tests { use mithril_common::crypto_helper::tests_setup::setup_certificate_chain; use mithril_common::entities::Epoch; - use mithril_common::test_utils::fake_data; + use mithril_common::test_utils::double::fake_data; use mithril_persistence::sqlite::ConnectionExtensions; use crate::database::query::{GetCertificateRecordQuery, InsertCertificateRecordQuery}; diff --git a/mithril-aggregator/src/database/query/epoch_settings/update_epoch_settings.rs b/mithril-aggregator/src/database/query/epoch_settings/update_epoch_settings.rs index 534fc1f63ec..f24eacd06ec 100644 --- a/mithril-aggregator/src/database/query/epoch_settings/update_epoch_settings.rs +++ b/mithril-aggregator/src/database/query/epoch_settings/update_epoch_settings.rs @@ -53,7 +53,7 @@ impl Query for UpdateEpochSettingsQuery { #[cfg(test)] mod tests { use mithril_common::entities::{BlockNumber, CardanoTransactionsSigningConfig}; - use mithril_common::test_utils::fake_data; + use mithril_common::test_utils::double::fake_data; use mithril_persistence::sqlite::ConnectionExtensions; use crate::database::query::GetEpochSettingsQuery; diff --git a/mithril-aggregator/src/database/query/signed_entity/get_signed_entity.rs b/mithril-aggregator/src/database/query/signed_entity/get_signed_entity.rs index 088ead61920..6ba7ed951a1 100644 --- a/mithril-aggregator/src/database/query/signed_entity/get_signed_entity.rs +++ b/mithril-aggregator/src/database/query/signed_entity/get_signed_entity.rs @@ -96,7 +96,7 @@ mod tests { use chrono::DateTime; use mithril_common::{ entities::{CardanoDbBeacon, SignedEntityType}, - test_utils::fake_data, + test_utils::double::fake_data, }; use mithril_persistence::sqlite::ConnectionExtensions; use sqlite::ConnectionThreadSafe; diff --git a/mithril-aggregator/src/database/record/buffered_single_signature_record.rs b/mithril-aggregator/src/database/record/buffered_single_signature_record.rs index 89843cb3ea8..91d81a5a3ac 100644 --- a/mithril-aggregator/src/database/record/buffered_single_signature_record.rs +++ b/mithril-aggregator/src/database/record/buffered_single_signature_record.rs @@ -176,7 +176,7 @@ mod tests { use mithril_common::entities::SignedEntityTypeDiscriminants::{ CardanoTransactions, MithrilStakeDistribution, }; - use mithril_common::test_utils::fake_data; + use mithril_common::test_utils::double::fake_data; use super::*; diff --git a/mithril-aggregator/src/database/record/certificate.rs b/mithril-aggregator/src/database/record/certificate.rs index 493c91b747e..32fc0b0f9ec 100644 --- a/mithril-aggregator/src/database/record/certificate.rs +++ b/mithril-aggregator/src/database/record/certificate.rs @@ -12,7 +12,7 @@ use mithril_common::messages::{ #[cfg(test)] use mithril_common::{ entities::{CardanoDbBeacon, ImmutableFileNumber}, - test_utils::{fake_data, fake_keys}, + test_utils::double::{fake_data, fake_keys}, }; use mithril_persistence::{ database::Hydrator, diff --git a/mithril-aggregator/src/database/record/signed_entity.rs b/mithril-aggregator/src/database/record/signed_entity.rs index 3ea224a5477..89a976638b0 100644 --- a/mithril-aggregator/src/database/record/signed_entity.rs +++ b/mithril-aggregator/src/database/record/signed_entity.rs @@ -101,7 +101,7 @@ impl SignedEntityRecord { } pub(crate) fn fake_records(number_if_records: usize) -> Vec { - use mithril_common::test_utils::fake_data; + use mithril_common::test_utils::double::fake_data; let snapshots = fake_data::snapshots(number_if_records as u64); (0..number_if_records) @@ -435,7 +435,7 @@ impl SqLiteEntity for SignedEntityRecord { #[cfg(test)] mod tests { - use mithril_common::test_utils::fake_data; + use mithril_common::test_utils::double::fake_data; use super::*; diff --git a/mithril-aggregator/src/database/record/single_signature.rs b/mithril-aggregator/src/database/record/single_signature.rs index 5484b3c140e..58711b8a2a4 100644 --- a/mithril-aggregator/src/database/record/single_signature.rs +++ b/mithril-aggregator/src/database/record/single_signature.rs @@ -133,7 +133,7 @@ impl SqLiteEntity for SingleSignatureRecord { #[cfg(test)] mod tests { - use mithril_common::test_utils::fake_data; + use mithril_common::test_utils::double::fake_data; use super::*; diff --git a/mithril-aggregator/src/database/repository/buffered_single_signature_repository.rs b/mithril-aggregator/src/database/repository/buffered_single_signature_repository.rs index eff564bad60..6913bef3a77 100644 --- a/mithril-aggregator/src/database/repository/buffered_single_signature_repository.rs +++ b/mithril-aggregator/src/database/repository/buffered_single_signature_repository.rs @@ -104,7 +104,7 @@ mod tests { use mithril_common::entities::SignedEntityTypeDiscriminants::{ CardanoTransactions, MithrilStakeDistribution, }; - use mithril_common::test_utils::fake_keys; + use mithril_common::test_utils::double::fake_keys; use crate::database::record::{BufferedSingleSignatureRecord, strip_buffered_sigs_date}; use crate::database::test_helper::{insert_buffered_single_signatures, main_db_connection}; diff --git a/mithril-aggregator/src/database/repository/signed_entity_store.rs b/mithril-aggregator/src/database/repository/signed_entity_store.rs index 202ff163836..ea21b36eb02 100644 --- a/mithril-aggregator/src/database/repository/signed_entity_store.rs +++ b/mithril-aggregator/src/database/repository/signed_entity_store.rs @@ -166,7 +166,7 @@ mod tests { use mithril_common::{ entities::{Epoch, MithrilStakeDistribution, Snapshot}, signable_builder::SignedEntity, - test_utils::fake_data, + test_utils::double::fake_data, }; use crate::database::test_helper::{insert_signed_entities, main_db_connection}; diff --git a/mithril-aggregator/src/database/repository/signer_registration_store.rs b/mithril-aggregator/src/database/repository/signer_registration_store.rs index 05ddd590395..1a9497fd6b9 100644 --- a/mithril-aggregator/src/database/repository/signer_registration_store.rs +++ b/mithril-aggregator/src/database/repository/signer_registration_store.rs @@ -142,7 +142,7 @@ mod tests { use crate::database::test_helper::{insert_signer_registrations, main_db_connection}; use mithril_common::entities::{Epoch, PartyId, Signer, SignerWithStake}; - use mithril_common::test_utils::fake_keys; + use mithril_common::test_utils::double::fake_keys; use std::collections::HashMap; use std::sync::Arc; diff --git a/mithril-aggregator/src/database/test_helper.rs b/mithril-aggregator/src/database/test_helper.rs index 19f072b7bd1..7c8aebe06a7 100644 --- a/mithril-aggregator/src/database/test_helper.rs +++ b/mithril-aggregator/src/database/test_helper.rs @@ -6,7 +6,7 @@ use uuid::Uuid; use mithril_common::entities::{ BlockNumber, CardanoTransactionsSigningConfig, ProtocolParameters, SignerWithStake, }; -use mithril_common::{StdError, StdResult, entities::Epoch, test_utils::fake_keys}; +use mithril_common::{StdError, StdResult, entities::Epoch, test_utils::double::fake_keys}; use mithril_persistence::sqlite::{ ConnectionBuilder, ConnectionExtensions, ConnectionOptions, Query, SqliteConnection, }; diff --git a/mithril-aggregator/src/entities/open_message.rs b/mithril-aggregator/src/entities/open_message.rs index 453755dd71f..53c895a7c3b 100644 --- a/mithril-aggregator/src/entities/open_message.rs +++ b/mithril-aggregator/src/entities/open_message.rs @@ -85,7 +85,7 @@ mod test { use mithril_common::{ entities::{Epoch, ProtocolMessage, SignedEntityType}, - test_utils::{double::Dummy, fake_data}, + test_utils::double::{Dummy, fake_data}, }; use crate::database::record::{OpenMessageRecord, OpenMessageWithSingleSignaturesRecord}; diff --git a/mithril-aggregator/src/event_store/database/repository.rs b/mithril-aggregator/src/event_store/database/repository.rs index 370e3bed624..2575db56876 100644 --- a/mithril-aggregator/src/event_store/database/repository.rs +++ b/mithril-aggregator/src/event_store/database/repository.rs @@ -437,7 +437,7 @@ mod tests { use crate::event_store::database::test_helper::event_store_db_connection; use mithril_common::entities::{SignerWithStake, Stake}; - use mithril_common::{StdResult, test_utils::fake_data}; + use mithril_common::{StdResult, test_utils::double::fake_data}; use sqlite::ConnectionThreadSafe; use super::{EventMessage, EventPersister}; diff --git a/mithril-aggregator/src/http_server/routes/artifact_routes/snapshot.rs b/mithril-aggregator/src/http_server/routes/artifact_routes/snapshot.rs index bb6c6c2f570..c2e753851b5 100644 --- a/mithril-aggregator/src/http_server/routes/artifact_routes/snapshot.rs +++ b/mithril-aggregator/src/http_server/routes/artifact_routes/snapshot.rs @@ -215,7 +215,7 @@ mod tests { MITHRIL_CLIENT_TYPE_HEADER, MITHRIL_ORIGIN_TAG_HEADER, entities::{CardanoDbBeacon, SignedEntityType, Snapshot}, messages::{SnapshotListItemMessage, SnapshotMessage}, - test_utils::{double::Dummy, fake_data}, + test_utils::double::{Dummy, fake_data}, }; use mithril_persistence::sqlite::HydrationError; diff --git a/mithril-aggregator/src/http_server/routes/certificate_routes.rs b/mithril-aggregator/src/http_server/routes/certificate_routes.rs index d9bf9aca7d1..fddab0ddcb3 100644 --- a/mithril-aggregator/src/http_server/routes/certificate_routes.rs +++ b/mithril-aggregator/src/http_server/routes/certificate_routes.rs @@ -140,7 +140,7 @@ mod tests { use mithril_api_spec::APISpec; use mithril_common::{ MITHRIL_CLIENT_TYPE_HEADER, MITHRIL_ORIGIN_TAG_HEADER, messages::CertificateMessage, - test_utils::fake_data, + test_utils::double::fake_data, }; use crate::{initialize_dependencies, services::MockMessageService}; diff --git a/mithril-aggregator/src/http_server/routes/proof_routes.rs b/mithril-aggregator/src/http_server/routes/proof_routes.rs index 293feb79a46..b340b65d98e 100644 --- a/mithril-aggregator/src/http_server/routes/proof_routes.rs +++ b/mithril-aggregator/src/http_server/routes/proof_routes.rs @@ -164,7 +164,10 @@ mod tests { MITHRIL_CLIENT_TYPE_HEADER, MITHRIL_ORIGIN_TAG_HEADER, entities::{BlockNumber, CardanoTransactionsSetProof, CardanoTransactionsSnapshot}, signable_builder::SignedEntity, - test_utils::{assert_equivalent, double::Dummy, fake_data}, + test_utils::{ + assert_equivalent, + double::{Dummy, fake_data}, + }, }; use crate::services::MockProverService; diff --git a/mithril-aggregator/src/http_server/routes/signer_routes.rs b/mithril-aggregator/src/http_server/routes/signer_routes.rs index 9bdea379c17..51ec6864e3b 100644 --- a/mithril-aggregator/src/http_server/routes/signer_routes.rs +++ b/mithril-aggregator/src/http_server/routes/signer_routes.rs @@ -271,7 +271,10 @@ mod tests { crypto_helper::ProtocolRegistrationError, entities::Epoch, messages::RegisterSignerMessage, - test_utils::{MithrilFixtureBuilder, double::Dummy, fake_data}, + test_utils::{ + MithrilFixtureBuilder, + double::{Dummy, fake_data}, + }, }; use crate::{ diff --git a/mithril-aggregator/src/http_server/routes/status.rs b/mithril-aggregator/src/http_server/routes/status.rs index 9092c882067..66563356c23 100644 --- a/mithril-aggregator/src/http_server/routes/status.rs +++ b/mithril-aggregator/src/http_server/routes/status.rs @@ -115,7 +115,10 @@ mod tests { use mithril_api_spec::APISpec; use mithril_common::{ entities::{Epoch, ProtocolParameters, Stake}, - test_utils::{MithrilFixtureBuilder, double::Dummy, fake_data}, + test_utils::{ + MithrilFixtureBuilder, + double::{Dummy, fake_data}, + }, }; use crate::{ diff --git a/mithril-aggregator/src/multi_signer.rs b/mithril-aggregator/src/multi_signer.rs index a65ec518918..f06669054e1 100644 --- a/mithril-aggregator/src/multi_signer.rs +++ b/mithril-aggregator/src/multi_signer.rs @@ -146,7 +146,10 @@ mod tests { use mithril_common::crypto_helper::tests_setup::*; use mithril_common::entities::{CardanoDbBeacon, Epoch, SignedEntityType, SignerWithStake}; use mithril_common::protocol::ToMessage; - use mithril_common::test_utils::{MithrilFixtureBuilder, double::Dummy, fake_data}; + use mithril_common::test_utils::{ + MithrilFixtureBuilder, + double::{Dummy, fake_data}, + }; use crate::entities::AggregatorEpochSettings; use crate::services::{FakeEpochService, FakeEpochServiceBuilder}; diff --git a/mithril-aggregator/src/runtime/runner.rs b/mithril-aggregator/src/runtime/runner.rs index 79700d2c806..86237b66a67 100644 --- a/mithril-aggregator/src/runtime/runner.rs +++ b/mithril-aggregator/src/runtime/runner.rs @@ -549,7 +549,10 @@ pub mod tests { }, signable_builder::SignableBuilderService, temp_dir, - test_utils::{MithrilFixtureBuilder, double::Dummy, fake_data}, + test_utils::{ + MithrilFixtureBuilder, + double::{Dummy, fake_data}, + }, }; use mithril_persistence::store::StakeStorer; use mithril_signed_entity_lock::SignedEntityTypeLock; diff --git a/mithril-aggregator/src/runtime/state_machine.rs b/mithril-aggregator/src/runtime/state_machine.rs index c290ee8d48c..27e72a52b2d 100644 --- a/mithril-aggregator/src/runtime/state_machine.rs +++ b/mithril-aggregator/src/runtime/state_machine.rs @@ -387,7 +387,7 @@ mod tests { use mockall::predicate; use std::time::Duration; - use mithril_common::test_utils::{double::Dummy, fake_data}; + use mithril_common::test_utils::double::{Dummy, fake_data}; use crate::entities::OpenMessage; use crate::test_tools::TestLogger; diff --git a/mithril-aggregator/src/services/aggregator_client.rs b/mithril-aggregator/src/services/aggregator_client.rs index 4b09c7c517f..302163bdf84 100644 --- a/mithril-aggregator/src/services/aggregator_client.rs +++ b/mithril-aggregator/src/services/aggregator_client.rs @@ -1006,7 +1006,7 @@ mod tests { } mod remote_certificate_retriever { - use mithril_common::test_utils::fake_data; + use mithril_common::test_utils::double::fake_data; use super::*; diff --git a/mithril-aggregator/src/services/certificate_chain_synchronizer/synchronizer_service.rs b/mithril-aggregator/src/services/certificate_chain_synchronizer/synchronizer_service.rs index 0eb8261f304..62949a3eb27 100644 --- a/mithril-aggregator/src/services/certificate_chain_synchronizer/synchronizer_service.rs +++ b/mithril-aggregator/src/services/certificate_chain_synchronizer/synchronizer_service.rs @@ -228,7 +228,8 @@ mod tests { FakeCertificaterRetriever, MithrilCertificateVerifier, }; use mithril_common::test_utils::{ - CertificateChainBuilder, CertificateChainFixture, fake_data, fake_keys, + CertificateChainBuilder, CertificateChainFixture, + double::{fake_data, fake_keys}, mock_extensions::MockBuilder, }; diff --git a/mithril-aggregator/src/services/certifier/buffered_certifier.rs b/mithril-aggregator/src/services/certifier/buffered_certifier.rs index 7d7f34a736b..d5134e8a700 100644 --- a/mithril-aggregator/src/services/certifier/buffered_certifier.rs +++ b/mithril-aggregator/src/services/certifier/buffered_certifier.rs @@ -191,7 +191,7 @@ mod tests { CardanoTransactions, MithrilStakeDistribution, }; use mithril_common::entities::SingleSignatureAuthenticationStatus; - use mithril_common::test_utils::{double::Dummy, fake_data}; + use mithril_common::test_utils::double::{Dummy, fake_data}; use crate::database::repository::BufferedSingleSignatureRepository; use crate::database::test_helper::main_db_connection; diff --git a/mithril-aggregator/src/services/certifier/certifier_service.rs b/mithril-aggregator/src/services/certifier/certifier_service.rs index a26230c8cb1..4aef9316f62 100644 --- a/mithril-aggregator/src/services/certifier/certifier_service.rs +++ b/mithril-aggregator/src/services/certifier/certifier_service.rs @@ -419,7 +419,7 @@ mod tests { use mithril_common::{ entities::{CardanoDbBeacon, ProtocolMessagePartKey}, temp_dir, - test_utils::{MithrilFixture, MithrilFixtureBuilder, fake_data}, + test_utils::{MithrilFixture, MithrilFixtureBuilder, double::fake_data}, }; use tokio::sync::RwLock; diff --git a/mithril-aggregator/src/services/epoch_service.rs b/mithril-aggregator/src/services/epoch_service.rs index be9174a3cde..da9d49fc1cc 100644 --- a/mithril-aggregator/src/services/epoch_service.rs +++ b/mithril-aggregator/src/services/epoch_service.rs @@ -560,7 +560,7 @@ pub(crate) struct FakeEpochServiceBuilder { #[cfg(test)] impl FakeEpochServiceBuilder { pub fn dummy(epoch: Epoch) -> Self { - use mithril_common::test_utils::{double::Dummy, fake_data}; + use mithril_common::test_utils::double::{Dummy, fake_data}; let signers = fake_data::signers_with_stakes(3); Self { @@ -841,8 +841,8 @@ mod tests { BlockNumber, CardanoTransactionsSigningConfig, Stake, StakeDistribution, SupportedEra, }; use mithril_common::test_utils::{ - MithrilFixture, MithrilFixtureBuilder, StakeDistributionGenerationMethod, double::Dummy, - fake_data, + MithrilFixture, MithrilFixtureBuilder, StakeDistributionGenerationMethod, + double::{Dummy, fake_data}, }; use mockall::predicate::eq; diff --git a/mithril-aggregator/src/services/message.rs b/mithril-aggregator/src/services/message.rs index b7b3639dace..be66312e184 100644 --- a/mithril-aggregator/src/services/message.rs +++ b/mithril-aggregator/src/services/message.rs @@ -342,7 +342,7 @@ impl MessageService for MithrilMessageService { #[cfg(test)] mod tests { use mithril_common::entities::{BlockNumber, Certificate, SignedEntityType}; - use mithril_common::test_utils::{double::Dummy, fake_data}; + use mithril_common::test_utils::double::{Dummy, fake_data}; use tokio::sync::RwLock; use crate::database::record::SignedEntityRecord; diff --git a/mithril-aggregator/src/services/signature_consumer/dmq.rs b/mithril-aggregator/src/services/signature_consumer/dmq.rs index ffc401d0dc7..8704b964683 100644 --- a/mithril-aggregator/src/services/signature_consumer/dmq.rs +++ b/mithril-aggregator/src/services/signature_consumer/dmq.rs @@ -57,7 +57,7 @@ impl SignatureConsumer for SignatureConsumerDmq { mod tests { use mithril_common::{ crypto_helper::ProtocolSingleSignature, - test_utils::{double::Dummy, fake_keys}, + test_utils::double::{Dummy, fake_keys}, }; use mithril_dmq::test::double::DmqConsumerFake; diff --git a/mithril-aggregator/src/services/signature_consumer/fake.rs b/mithril-aggregator/src/services/signature_consumer/fake.rs index 0eb07d7630f..b6464d27b02 100644 --- a/mithril-aggregator/src/services/signature_consumer/fake.rs +++ b/mithril-aggregator/src/services/signature_consumer/fake.rs @@ -46,7 +46,7 @@ impl SignatureConsumer for FakeSignatureConsumer { mod tests { use super::*; - use mithril_common::{entities::Epoch, test_utils::fake_data}; + use mithril_common::{entities::Epoch, test_utils::double::fake_data}; #[tokio::test] async fn fake_signature_consumer_returns_signature_batches_in_expected_order() { diff --git a/mithril-aggregator/src/services/signature_processor.rs b/mithril-aggregator/src/services/signature_processor.rs index 02054b36b6d..155cba3e8fd 100644 --- a/mithril-aggregator/src/services/signature_processor.rs +++ b/mithril-aggregator/src/services/signature_processor.rs @@ -99,7 +99,7 @@ mod tests { use anyhow::anyhow; use mithril_common::{ entities::{Epoch, SignedEntityType}, - test_utils::fake_data, + test_utils::double::fake_data, }; use mockall::predicate::eq; use tokio::{ diff --git a/mithril-aggregator/src/services/signed_entity.rs b/mithril-aggregator/src/services/signed_entity.rs index 83e22540404..51490774a64 100644 --- a/mithril-aggregator/src/services/signed_entity.rs +++ b/mithril-aggregator/src/services/signed_entity.rs @@ -504,7 +504,7 @@ mod tests { use mithril_common::{ entities::{CardanoTransactionsSnapshot, Epoch, StakeDistribution}, signable_builder, - test_utils::fake_data, + test_utils::double::fake_data, }; use mithril_metric::CounterValue; use serde::{Serialize, de::DeserializeOwned}; diff --git a/mithril-aggregator/src/services/snapshotter/compressed_archive_snapshotter.rs b/mithril-aggregator/src/services/snapshotter/compressed_archive_snapshotter.rs index 152457e4d8b..6e33446782e 100644 --- a/mithril-aggregator/src/services/snapshotter/compressed_archive_snapshotter.rs +++ b/mithril-aggregator/src/services/snapshotter/compressed_archive_snapshotter.rs @@ -523,7 +523,7 @@ mod tests { } mod snapshot_ancillary { - use mithril_common::test_utils::fake_keys; + use mithril_common::test_utils::double::fake_keys; use super::*; diff --git a/mithril-aggregator/src/test/double/dummies.rs b/mithril-aggregator/src/test/double/dummies.rs index 5bb10cddff8..2dd218e70d0 100644 --- a/mithril-aggregator/src/test/double/dummies.rs +++ b/mithril-aggregator/src/test/double/dummies.rs @@ -1,7 +1,7 @@ use chrono::Utc; use uuid::Uuid; -use mithril_common::test_utils::{double::Dummy, fake_data}; +use mithril_common::test_utils::double::{Dummy, fake_data}; mod record { use mithril_common::entities::{ProtocolMessage, SignedEntityType}; diff --git a/mithril-aggregator/src/tools/genesis.rs b/mithril-aggregator/src/tools/genesis.rs index b9fdf3b08c7..09d78c5ff69 100644 --- a/mithril-aggregator/src/tools/genesis.rs +++ b/mithril-aggregator/src/tools/genesis.rs @@ -206,7 +206,7 @@ mod tests { ProtocolGenesisSecretKey, ProtocolGenesisSigner, ProtocolGenesisVerificationKey, ProtocolGenesisVerifier, }, - test_utils::{MithrilFixtureBuilder, TempDir, fake_data}, + test_utils::{MithrilFixtureBuilder, TempDir, double::fake_data}, }; use std::{fs::read_to_string, path::PathBuf}; diff --git a/mithril-client/src/cardano_database_client/download_unpack/download_task.rs b/mithril-client/src/cardano_database_client/download_unpack/download_task.rs index c2613ac8343..3b2121e3fd3 100644 --- a/mithril-client/src/cardano_database_client/download_unpack/download_task.rs +++ b/mithril-client/src/cardano_database_client/download_unpack/download_task.rs @@ -162,7 +162,7 @@ pub struct LocationToDownload { #[cfg(test)] mod tests { use mithril_common::entities::FileUri; - use mithril_common::test_utils::{assert_dir_eq, fake_keys, temp_dir_create}; + use mithril_common::test_utils::{assert_dir_eq, double::fake_keys, temp_dir_create}; use crate::file_downloader::MockFileDownloaderBuilder; use crate::test_utils::TestLogger; diff --git a/mithril-client/src/cardano_database_client/download_unpack/internal_downloader.rs b/mithril-client/src/cardano_database_client/download_unpack/internal_downloader.rs index 6b0e3988d12..c3c9f8ce93f 100644 --- a/mithril-client/src/cardano_database_client/download_unpack/internal_downloader.rs +++ b/mithril-client/src/cardano_database_client/download_unpack/internal_downloader.rs @@ -532,7 +532,7 @@ mod tests { } mod building_download_tasks { - use mithril_common::{entities::CompressionAlgorithm, test_utils::fake_keys}; + use mithril_common::{entities::CompressionAlgorithm, test_utils::double::fake_keys}; use crate::file_downloader::MockFileDownloader; diff --git a/mithril-client/src/certificate_client/fetch.rs b/mithril-client/src/certificate_client/fetch.rs index f4296bb74e9..28fa0c6988b 100644 --- a/mithril-client/src/certificate_client/fetch.rs +++ b/mithril-client/src/certificate_client/fetch.rs @@ -105,7 +105,7 @@ impl CertificateRetriever for InternalCertificateRetriever { #[cfg(test)] mod tests { - use mithril_common::test_utils::{double::Dummy, fake_data}; + use mithril_common::test_utils::double::{Dummy, fake_data}; use crate::certificate_client::tests_utils::CertificateClientTestBuilder; diff --git a/mithril-client/src/certificate_client/verify_cache/memory_cache.rs b/mithril-client/src/certificate_client/verify_cache/memory_cache.rs index 480d8e39ea6..078347ba7dd 100644 --- a/mithril-client/src/certificate_client/verify_cache/memory_cache.rs +++ b/mithril-client/src/certificate_client/verify_cache/memory_cache.rs @@ -161,7 +161,7 @@ pub(crate) mod test_tools { #[cfg(test)] mod tests { use mithril_common::entities::Certificate; - use mithril_common::test_utils::fake_data; + use mithril_common::test_utils::double::fake_data; use super::*; diff --git a/mithril-client/src/mithril_stake_distribution_client.rs b/mithril-client/src/mithril_stake_distribution_client.rs index 18243ec3ec7..9cdc0b49c87 100644 --- a/mithril-client/src/mithril_stake_distribution_client.rs +++ b/mithril-client/src/mithril_stake_distribution_client.rs @@ -95,7 +95,7 @@ impl MithrilStakeDistributionClient { #[cfg(test)] mod tests { use chrono::{DateTime, Utc}; - use mithril_common::test_utils::fake_data; + use mithril_common::test_utils::double::fake_data; use crate::MithrilSigner; use crate::aggregator_client::MockAggregatorClient; diff --git a/mithril-client/src/snapshot_client.rs b/mithril-client/src/snapshot_client.rs index 09e189a24d1..138b781e56a 100644 --- a/mithril-client/src/snapshot_client.rs +++ b/mithril-client/src/snapshot_client.rs @@ -481,7 +481,7 @@ mod tests { }; use mithril_cardano_node_internal_database::IMMUTABLE_DIR; - use mithril_common::test_utils::{double::Dummy, fake_keys}; + use mithril_common::test_utils::double::{Dummy, fake_keys}; use mithril_common::{assert_dir_eq, crypto_helper::ManifestSigner, temp_dir_create}; use super::*; diff --git a/mithril-client/src/utils/ancillary_verifier.rs b/mithril-client/src/utils/ancillary_verifier.rs index 62447c94df0..adb0106b5a2 100644 --- a/mithril-client/src/utils/ancillary_verifier.rs +++ b/mithril-client/src/utils/ancillary_verifier.rs @@ -131,7 +131,7 @@ mod tests { use std::collections::BTreeMap; use mithril_common::entities::SignableManifest; - use mithril_common::{crypto_helper::ManifestSigner, test_utils::fake_keys}; + use mithril_common::{crypto_helper::ManifestSigner, test_utils::double::fake_keys}; use super::*; diff --git a/mithril-client/tests/cardano_db_snapshot_list_get_download_verify.rs b/mithril-client/tests/cardano_db_snapshot_list_get_download_verify.rs index 5750213e5f9..dd94341c738 100644 --- a/mithril-client/tests/cardano_db_snapshot_list_get_download_verify.rs +++ b/mithril-client/tests/cardano_db_snapshot_list_get_download_verify.rs @@ -11,7 +11,7 @@ use mithril_client::{ cardano_database_client::{DownloadUnpackOptions, ImmutableFileRange}, feedback::SlogFeedbackReceiver, }; -use mithril_common::crypto_helper::ManifestSigner; +use mithril_common::{crypto_helper::ManifestSigner, test_utils::double::fake_keys}; use crate::extensions::fake_aggregator::{ CardanoDatabaseSnapshotV2Fixture, FakeAggregator, FakeCertificateVerifier, @@ -20,8 +20,7 @@ use crate::extensions::fake_aggregator::{ #[tokio::test] async fn cardano_db_snapshot_list_get_download_verify() { let work_dir = extensions::get_test_dir("cardano_db_snapshot_list_get_download_verify"); - let genesis_verification_key = - mithril_common::test_utils::fake_keys::genesis_verification_key()[0]; + let genesis_verification_key = fake_keys::genesis_verification_key()[0]; let (ancillary_manifest_signing_key, ancillary_manifest_signer_verification_key) = { let signer = ManifestSigner::create_deterministic_signer(); (signer.secret_key(), signer.verification_key()) diff --git a/mithril-client/tests/cardano_transaction_proof.rs b/mithril-client/tests/cardano_transaction_proof.rs index 369caaf28c8..9220e879e90 100644 --- a/mithril-client/tests/cardano_transaction_proof.rs +++ b/mithril-client/tests/cardano_transaction_proof.rs @@ -1,12 +1,13 @@ mod extensions; -use crate::extensions::fake_aggregator::{FakeAggregator, FakeCertificateVerifier}; use mithril_client::{ClientBuilder, MessageBuilder, aggregator_client::AggregatorRequest}; +use mithril_common::test_utils::double::fake_keys; + +use crate::extensions::fake_aggregator::{FakeAggregator, FakeCertificateVerifier}; #[tokio::test] async fn cardano_transaction_proof_get_validate() { - let genesis_verification_key = - mithril_common::test_utils::fake_keys::genesis_verification_key()[0]; + let genesis_verification_key = fake_keys::genesis_verification_key()[0]; let transactions_hashes = ["abc", "def"]; let certificate_hash = "certificate_hash"; diff --git a/mithril-client/tests/certificate_get_list.rs b/mithril-client/tests/certificate_get_list.rs index 4035dbd294a..49343777bca 100644 --- a/mithril-client/tests/certificate_get_list.rs +++ b/mithril-client/tests/certificate_get_list.rs @@ -1,13 +1,14 @@ mod extensions; -use crate::extensions::fake_aggregator::FakeAggregator; use mithril_client::{ClientBuilder, aggregator_client::AggregatorRequest}; +use mithril_common::test_utils::double::fake_keys; + +use crate::extensions::fake_aggregator::FakeAggregator; #[tokio::test] async fn certificate_get_list() { let certificate_hash_list = vec!["certificate-123".to_string(), "certificate-456".to_string()]; - let genesis_verification_key = - mithril_common::test_utils::fake_keys::genesis_verification_key()[0]; + let genesis_verification_key = fake_keys::genesis_verification_key()[0]; let fake_aggregator = FakeAggregator::spawn_with_certificate(&certificate_hash_list); let client = ClientBuilder::aggregator(&fake_aggregator.server_root_url(), genesis_verification_key) diff --git a/mithril-client/tests/extensions/fake_aggregator/cardano_db_v1.rs b/mithril-client/tests/extensions/fake_aggregator/cardano_db_v1.rs index d162821ab84..797dfb1e2d9 100644 --- a/mithril-client/tests/extensions/fake_aggregator/cardano_db_v1.rs +++ b/mithril-client/tests/extensions/fake_aggregator/cardano_db_v1.rs @@ -7,7 +7,7 @@ use mithril_cardano_node_internal_database::test::DummyCardanoDb; use mithril_client::{MessageBuilder, MithrilCertificate, Snapshot, SnapshotListItem}; use mithril_common::crypto_helper::ManifestVerifierSecretKey; use mithril_common::entities::{CardanoDbBeacon, CompressionAlgorithm, SignedEntityType}; -use mithril_common::test_utils::{double::Dummy, fake_data}; +use mithril_common::test_utils::double::{Dummy, fake_data}; use crate::extensions::{routes, snapshot_archives}; diff --git a/mithril-client/tests/extensions/fake_aggregator/cardano_db_v2.rs b/mithril-client/tests/extensions/fake_aggregator/cardano_db_v2.rs index 641528179ae..572cc1595ed 100644 --- a/mithril-client/tests/extensions/fake_aggregator/cardano_db_v2.rs +++ b/mithril-client/tests/extensions/fake_aggregator/cardano_db_v2.rs @@ -17,7 +17,7 @@ use mithril_client::{ CardanoDatabaseSnapshot, CardanoDatabaseSnapshotListItem, MithrilCertificate, }; use mithril_common::crypto_helper::ManifestVerifierSecretKey; -use mithril_common::test_utils::{double::Dummy, fake_data}; +use mithril_common::test_utils::double::{Dummy, fake_data}; use crate::extensions::{routes, snapshot_archives}; diff --git a/mithril-client/tests/mithril_stake_distribution_list_get_show_verify.rs b/mithril-client/tests/mithril_stake_distribution_list_get_show_verify.rs index 9cf6a62ed43..134b223421d 100644 --- a/mithril-client/tests/mithril_stake_distribution_list_get_show_verify.rs +++ b/mithril-client/tests/mithril_stake_distribution_list_get_show_verify.rs @@ -1,12 +1,13 @@ mod extensions; -use crate::extensions::fake_aggregator::{FakeAggregator, FakeCertificateVerifier}; use mithril_client::{ClientBuilder, MessageBuilder, aggregator_client::AggregatorRequest}; +use mithril_common::test_utils::double::fake_keys; + +use crate::extensions::fake_aggregator::{FakeAggregator, FakeCertificateVerifier}; #[tokio::test] async fn mithril_stake_distribution_list_get_show_verify() { - let genesis_verification_key = - mithril_common::test_utils::fake_keys::genesis_verification_key()[0]; + let genesis_verification_key = fake_keys::genesis_verification_key()[0]; let msd_hash = "msd_hash"; let certificate_hash = "certificate_hash"; let fake_aggregator = diff --git a/mithril-client/tests/snapshot_list_get_show_download_verify.rs b/mithril-client/tests/snapshot_list_get_show_download_verify.rs index 741f723eae7..823f44d07e2 100644 --- a/mithril-client/tests/snapshot_list_get_show_download_verify.rs +++ b/mithril-client/tests/snapshot_list_get_show_download_verify.rs @@ -7,14 +7,14 @@ use mithril_client::aggregator_client::AggregatorRequest; use mithril_client::feedback::SlogFeedbackReceiver; use mithril_client::{ClientBuilder, MessageBuilder}; use mithril_common::crypto_helper::ManifestSigner; +use mithril_common::test_utils::double::fake_keys; use crate::extensions::fake_aggregator::{FakeAggregator, FakeCertificateVerifier}; #[tokio::test] async fn snapshot_list_get_show_download_verify() { let work_dir = extensions::get_test_dir("snapshot_list_get_show_download_verify"); - let genesis_verification_key = - mithril_common::test_utils::fake_keys::genesis_verification_key()[0]; + let genesis_verification_key = fake_keys::genesis_verification_key()[0]; let (ancillary_manifest_signing_key, ancillary_manifest_signer_verification_key) = { let signer = ManifestSigner::create_deterministic_signer(); (signer.secret_key(), signer.verification_key()) diff --git a/mithril-common/src/certificate_chain/fake_certificate_retriever.rs b/mithril-common/src/certificate_chain/fake_certificate_retriever.rs index e92e74a0654..6d9aa1f8c8d 100644 --- a/mithril-common/src/certificate_chain/fake_certificate_retriever.rs +++ b/mithril-common/src/certificate_chain/fake_certificate_retriever.rs @@ -44,7 +44,7 @@ impl CertificateRetriever for FakeCertificaterRetriever { #[cfg(test)] mod tests { - use crate::test_utils::fake_data; + use crate::test_utils::double::fake_data; use super::*; diff --git a/mithril-common/src/crypto_helper/types/protocol_key.rs b/mithril-common/src/crypto_helper/types/protocol_key.rs index 9900409eacf..55928b2f580 100644 --- a/mithril-common/src/crypto_helper/types/protocol_key.rs +++ b/mithril-common/src/crypto_helper/types/protocol_key.rs @@ -287,7 +287,7 @@ macro_rules! impl_codec_and_type_conversions_for_protocol_key { mod test { use crate::{ crypto_helper::ProtocolKey, - test_utils::{TempDir, fake_keys}, + test_utils::{TempDir, double::fake_keys}, }; use mithril_stm::VerificationKeyProofOfPossession; use serde::{Deserialize, Serialize}; diff --git a/mithril-common/src/entities/certificate.rs b/mithril-common/src/entities/certificate.rs index 5f98198b79a..cebc7d1076e 100644 --- a/mithril-common/src/entities/certificate.rs +++ b/mithril-common/src/entities/certificate.rs @@ -163,16 +163,18 @@ impl Debug for Certificate { #[cfg(test)] mod tests { - use super::*; + use chrono::{DateTime, Duration, Utc}; + use crate::entities::SignedEntityType::CardanoStakeDistribution; use crate::{ entities::{ ProtocolMessagePartKey, ProtocolParameters, certificate_metadata::StakeDistributionParty, }, - test_utils::fake_keys, + test_utils::double::fake_keys, }; - use chrono::{DateTime, Duration, Utc}; + + use super::*; fn get_parties() -> Vec { vec![ diff --git a/mithril-common/src/entities/mithril_stake_distribution.rs b/mithril-common/src/entities/mithril_stake_distribution.rs index b5a01c1d3a9..b628acb49b3 100644 --- a/mithril-common/src/entities/mithril_stake_distribution.rs +++ b/mithril-common/src/entities/mithril_stake_distribution.rs @@ -56,7 +56,7 @@ impl MithrilStakeDistribution { #[cfg(test)] mod tests { - use crate::test_utils::{MithrilFixtureBuilder, fake_data}; + use crate::test_utils::{MithrilFixtureBuilder, double::fake_data}; use super::*; diff --git a/mithril-common/src/entities/signed_entity_config.rs b/mithril-common/src/entities/signed_entity_config.rs index 641a1c66f78..fcee7673696 100644 --- a/mithril-common/src/entities/signed_entity_config.rs +++ b/mithril-common/src/entities/signed_entity_config.rs @@ -157,7 +157,7 @@ mod tests { use crate::entities::{ CardanoDbBeacon, ChainPoint, Epoch, SignedEntityType, SlotNumber, TimePoint, }; - use crate::test_utils::{double::Dummy, fake_data}; + use crate::test_utils::{double::Dummy, double::fake_data}; use super::*; diff --git a/mithril-common/src/entities/signer.rs b/mithril-common/src/entities/signer.rs index dbb4639b5c7..8d95bf7158b 100644 --- a/mithril-common/src/entities/signer.rs +++ b/mithril-common/src/entities/signer.rs @@ -264,7 +264,7 @@ impl Debug for SignerWithStake { #[cfg(test)] mod tests { - use crate::test_utils::{MithrilFixtureBuilder, fake_keys}; + use crate::test_utils::{MithrilFixtureBuilder, double::fake_keys}; use super::*; diff --git a/mithril-common/src/messages/mithril_stake_distribution.rs b/mithril-common/src/messages/mithril_stake_distribution.rs index 7ba53c0f314..5b84999e542 100644 --- a/mithril-common/src/messages/mithril_stake_distribution.rs +++ b/mithril-common/src/messages/mithril_stake_distribution.rs @@ -31,7 +31,7 @@ pub struct MithrilStakeDistributionMessage { #[cfg(test)] mod tests { - use crate::test_utils::fake_data; + use crate::test_utils::double::fake_data; use super::*; diff --git a/mithril-common/src/protocol/multi_signer.rs b/mithril-common/src/protocol/multi_signer.rs index 1965edd2b70..f7e48e3e0b4 100644 --- a/mithril-common/src/protocol/multi_signer.rs +++ b/mithril-common/src/protocol/multi_signer.rs @@ -94,7 +94,7 @@ mod test { use crate::{ entities::{ProtocolMessage, ProtocolMessagePartKey, ProtocolParameters}, protocol::SignerBuilder, - test_utils::fake_keys, + test_utils::double::fake_keys, test_utils::{MithrilFixture, MithrilFixtureBuilder, StakeDistributionGenerationMethod}, }; diff --git a/mithril-common/src/protocol/signer_builder.rs b/mithril-common/src/protocol/signer_builder.rs index 1eece99c56d..6a706546cf9 100644 --- a/mithril-common/src/protocol/signer_builder.rs +++ b/mithril-common/src/protocol/signer_builder.rs @@ -178,7 +178,7 @@ mod test { use crate::{ crypto_helper::{KesSignerStandard, ProtocolRegistrationErrorWrapper}, - test_utils::{MithrilFixtureBuilder, fake_data}, + test_utils::{MithrilFixtureBuilder, double::fake_data}, }; use super::*; diff --git a/mithril-common/src/test_utils/certificate_chain_builder.rs b/mithril-common/src/test_utils/certificate_chain_builder.rs index 9e121a84538..2c396a78acd 100644 --- a/mithril-common/src/test_utils/certificate_chain_builder.rs +++ b/mithril-common/src/test_utils/certificate_chain_builder.rs @@ -14,7 +14,7 @@ use crate::{ CardanoDbBeacon, Certificate, CertificateMetadata, CertificateSignature, Epoch, ProtocolMessage, ProtocolMessagePartKey, SignedEntityType, }, - test_utils::{MithrilFixture, MithrilFixtureBuilder, SignerFixture, fake_data}, + test_utils::{MithrilFixture, MithrilFixtureBuilder, SignerFixture, double::fake_data}, }; /// Genesis certificate processor function type. For tests only. @@ -1072,14 +1072,12 @@ mod test { #[test] fn get_latest_certificate() { - let chain_with_only_a_genesis = CertificateChainBuilder::new() - .with_total_certificates(1) - .build(); + let chain_with_only_a_genesis = + CertificateChainBuilder::new().with_total_certificates(1).build(); assert!(chain_with_only_a_genesis.latest_certificate().is_genesis()); - let chain_with_multiple_certificates = CertificateChainBuilder::new() - .with_total_certificates(10) - .build(); + let chain_with_multiple_certificates = + CertificateChainBuilder::new().with_total_certificates(10).build(); assert_eq!( chain_with_multiple_certificates.latest_certificate(), chain_with_multiple_certificates.first().unwrap() diff --git a/mithril-common/src/test_utils/double/dummies.rs b/mithril-common/src/test_utils/double/dummies.rs index f4ea1c42fc0..abb3962fc38 100644 --- a/mithril-common/src/test_utils/double/dummies.rs +++ b/mithril-common/src/test_utils/double/dummies.rs @@ -1,6 +1,6 @@ use chrono::{DateTime, Utc}; -use crate::test_utils::{double::Dummy, fake_data, fake_keys}; +use crate::test_utils::double::{Dummy, fake_data, fake_keys}; mod entities { use crate::crypto_helper::MKTreeStoreInMemory; @@ -477,8 +477,6 @@ mod messages { impl Dummy for RegisterSignerMessage { /// Return a dummy [RegisterSignerMessage] (test-only). fn dummy() -> Self { - use crate::test_utils::fake_keys; - Self { epoch: Epoch(1), party_id: "pool1m8crhnqj5k2kyszf5j2scshupystyxc887zdfrpzh6ty6eun4fx".to_string(), diff --git a/mithril-common/src/test_utils/fake_data.rs b/mithril-common/src/test_utils/double/fake_data.rs similarity index 100% rename from mithril-common/src/test_utils/fake_data.rs rename to mithril-common/src/test_utils/double/fake_data.rs diff --git a/mithril-common/src/test_utils/fake_keys.rs b/mithril-common/src/test_utils/double/fake_keys.rs similarity index 100% rename from mithril-common/src/test_utils/fake_keys.rs rename to mithril-common/src/test_utils/double/fake_keys.rs diff --git a/mithril-common/src/test_utils/double/mod.rs b/mithril-common/src/test_utils/double/mod.rs index 4563ec8d91b..35ff083fc54 100644 --- a/mithril-common/src/test_utils/double/mod.rs +++ b/mithril-common/src/test_utils/double/mod.rs @@ -3,6 +3,9 @@ //! Enable unit testing with controlled inputs and predictable behavior. mod dummies; +pub mod fake_data; +pub mod fake_keys; +pub(super) mod precomputed_kes_key; /// A trait for giving a type a dummy value. /// diff --git a/mithril-common/src/test_utils/precomputed_kes_key.rs b/mithril-common/src/test_utils/double/precomputed_kes_key.rs similarity index 100% rename from mithril-common/src/test_utils/precomputed_kes_key.rs rename to mithril-common/src/test_utils/double/precomputed_kes_key.rs diff --git a/mithril-common/src/test_utils/fixture_builder.rs b/mithril-common/src/test_utils/fixture_builder.rs index 715c3a60c3d..eb0a8055869 100644 --- a/mithril-common/src/test_utils/fixture_builder.rs +++ b/mithril-common/src/test_utils/fixture_builder.rs @@ -8,10 +8,10 @@ use crate::{ tests_setup, tests_setup::setup_temp_directory_for_signer, }, entities::{PartyId, ProtocolParameters, Stake, StakeDistribution}, - test_utils::{fake_data, mithril_fixture::MithrilFixture}, + test_utils::{double::fake_data, mithril_fixture::MithrilFixture}, }; -use super::precomputed_kes_key; +use super::double::precomputed_kes_key; /// A builder of mithril types. pub struct MithrilFixtureBuilder { diff --git a/mithril-common/src/test_utils/mod.rs b/mithril-common/src/test_utils/mod.rs index ff6e9311610..6e2e70115a1 100644 --- a/mithril-common/src/test_utils/mod.rs +++ b/mithril-common/src/test_utils/mod.rs @@ -7,8 +7,6 @@ //! pub mod double; -pub mod fake_data; -pub mod fake_keys; pub mod mock_extensions; mod cardano_transactions_builder; @@ -17,7 +15,6 @@ mod dir_eq; mod fixture_builder; mod memory_logger; mod mithril_fixture; -mod precomputed_kes_key; mod temp_dir; pub use cardano_transactions_builder::CardanoTransactionsBuilder; diff --git a/mithril-signer/src/database/tests/protocol_initializer.rs b/mithril-signer/src/database/tests/protocol_initializer.rs index 46e3231ef28..c5ccb847c8a 100644 --- a/mithril-signer/src/database/tests/protocol_initializer.rs +++ b/mithril-signer/src/database/tests/protocol_initializer.rs @@ -1,6 +1,6 @@ use std::sync::Arc; -use mithril_common::test_utils::fake_data; +use mithril_common::test_utils::double::fake_data; use mithril_common::{crypto_helper::ProtocolInitializer, entities::Epoch}; use mithril_persistence::sqlite::{ConnectionBuilder, ConnectionExtensions}; diff --git a/mithril-signer/src/entities/signer_epoch_settings.rs b/mithril-signer/src/entities/signer_epoch_settings.rs index 1a1df619ce7..490cd46f1f6 100644 --- a/mithril-signer/src/entities/signer_epoch_settings.rs +++ b/mithril-signer/src/entities/signer_epoch_settings.rs @@ -28,7 +28,7 @@ pub struct SignerEpochSettings { impl mithril_common::test_utils::double::Dummy for SignerEpochSettings { /// Create a dummy `SignerEpochSettings` fn dummy() -> SignerEpochSettings { - use mithril_common::test_utils::fake_data; + use mithril_common::test_utils::double::fake_data; // Beacon let beacon = fake_data::beacon(); diff --git a/mithril-signer/src/message_adapters/to_register_signature_message.rs b/mithril-signer/src/message_adapters/to_register_signature_message.rs index d4b0c5528ce..92fbba997f5 100644 --- a/mithril-signer/src/message_adapters/to_register_signature_message.rs +++ b/mithril-signer/src/message_adapters/to_register_signature_message.rs @@ -37,7 +37,7 @@ impl #[cfg(test)] mod tests { use mithril_common::entities::{CardanoDbBeacon, Epoch}; - use mithril_common::test_utils::fake_data; + use mithril_common::test_utils::double::fake_data; use super::*; diff --git a/mithril-signer/src/message_adapters/to_register_signer_message.rs b/mithril-signer/src/message_adapters/to_register_signer_message.rs index be4c092ae32..a50370315b7 100644 --- a/mithril-signer/src/message_adapters/to_register_signer_message.rs +++ b/mithril-signer/src/message_adapters/to_register_signer_message.rs @@ -46,7 +46,7 @@ impl TryToMessageAdapter<(Epoch, Signer), RegisterSignerMessage> #[cfg(test)] mod tests { - use mithril_common::test_utils::fake_data; + use mithril_common::test_utils::double::fake_data; use super::*; diff --git a/mithril-signer/src/runtime/runner.rs b/mithril-signer/src/runtime/runner.rs index 95021d5acf5..98053e39603 100644 --- a/mithril-signer/src/runtime/runner.rs +++ b/mithril-signer/src/runtime/runner.rs @@ -353,7 +353,10 @@ mod tests { CardanoTransactionsSignableBuilder, MithrilSignableBuilderService, MithrilStakeDistributionSignableBuilder, SignableBuilderServiceDependencies, }, - test_utils::{MithrilFixtureBuilder, double::Dummy, fake_data}, + test_utils::{ + MithrilFixtureBuilder, + double::{Dummy, fake_data}, + }, }; use mithril_era::{EraChecker, EraReader, adapters::EraReaderBootstrapAdapter}; use mithril_signed_entity_lock::SignedEntityTypeLock; diff --git a/mithril-signer/src/runtime/state_machine.rs b/mithril-signer/src/runtime/state_machine.rs index 78e86f91b04..a4a13815a1a 100644 --- a/mithril-signer/src/runtime/state_machine.rs +++ b/mithril-signer/src/runtime/state_machine.rs @@ -477,7 +477,7 @@ mod tests { use mockall::predicate; use mithril_common::entities::{ChainPoint, Epoch, ProtocolMessage, SignedEntityType}; - use mithril_common::test_utils::{double::Dummy, fake_data}; + use mithril_common::test_utils::double::{Dummy, fake_data}; use crate::runtime::runner::MockSignerRunner; use crate::services::AggregatorClientError; diff --git a/mithril-signer/src/services/aggregator_client.rs b/mithril-signer/src/services/aggregator_client.rs index d1d2fbeb1ce..c1d3a09b45c 100644 --- a/mithril-signer/src/services/aggregator_client.rs +++ b/mithril-signer/src/services/aggregator_client.rs @@ -473,7 +473,10 @@ mod tests { use mithril_common::api_version::DummyApiVersionDiscriminantSource; use mithril_common::entities::Epoch; use mithril_common::messages::TryFromMessageAdapter; - use mithril_common::test_utils::{MemoryDrainForTestInspector, double::Dummy, fake_data}; + use mithril_common::test_utils::{ + MemoryDrainForTestInspector, + double::{Dummy, fake_data}, + }; use crate::test_tools::TestLogger; diff --git a/mithril-signer/src/services/certifier.rs b/mithril-signer/src/services/certifier.rs index 87a8babbe1c..bbf78675a6a 100644 --- a/mithril-signer/src/services/certifier.rs +++ b/mithril-signer/src/services/certifier.rs @@ -156,7 +156,7 @@ mod tests { CardanoTransactionsSigningConfig, ChainPoint, Epoch, ProtocolMessagePartKey, SignedEntityTypeDiscriminants, }; - use mithril_common::test_utils::{double::Dummy, fake_data}; + use mithril_common::test_utils::double::{Dummy, fake_data}; use crate::services::{MockSignaturePublisher, MockSingleSigner}; diff --git a/mithril-signer/src/services/epoch_service.rs b/mithril-signer/src/services/epoch_service.rs index 59452f65e16..b3fe1aaf598 100644 --- a/mithril-signer/src/services/epoch_service.rs +++ b/mithril-signer/src/services/epoch_service.rs @@ -340,7 +340,7 @@ impl MithrilEpochService { /// `TEST ONLY` - Set all data to either default values, empty values, or fake values /// if no default/empty can be set. pub fn set_data_to_default_or_fake(mut self, epoch: Epoch) -> Self { - use mithril_common::test_utils::fake_data; + use mithril_common::test_utils::double::fake_data; let epoch_data = EpochData { epoch, @@ -428,7 +428,10 @@ mod tests { use tokio::sync::RwLock; use mithril_common::entities::{Epoch, StakeDistribution}; - use mithril_common::test_utils::{MithrilFixtureBuilder, double::Dummy, fake_data}; + use mithril_common::test_utils::{ + MithrilFixtureBuilder, + double::{Dummy, fake_data}, + }; use crate::database::repository::{ProtocolInitializerRepository, StakePoolStore}; use crate::database::test_helper::main_db_connection; diff --git a/mithril-signer/src/services/signature_publisher/delayer.rs b/mithril-signer/src/services/signature_publisher/delayer.rs index 01dfbdd11db..0d20383aad2 100644 --- a/mithril-signer/src/services/signature_publisher/delayer.rs +++ b/mithril-signer/src/services/signature_publisher/delayer.rs @@ -76,7 +76,7 @@ impl SignaturePublisher for SignaturePublisherDelayer { #[cfg(test)] mod tests { - use mithril_common::{entities::Epoch, test_utils::fake_data}; + use mithril_common::{entities::Epoch, test_utils::double::fake_data}; use crate::{services::MockSignaturePublisher, test_tools::TestLogger}; diff --git a/mithril-signer/src/services/signature_publisher/dmq.rs b/mithril-signer/src/services/signature_publisher/dmq.rs index 7d251efb78f..9362636a686 100644 --- a/mithril-signer/src/services/signature_publisher/dmq.rs +++ b/mithril-signer/src/services/signature_publisher/dmq.rs @@ -46,7 +46,7 @@ impl SignaturePublisher for SignaturePublisherDmq { #[cfg(test)] mod tests { - use mithril_common::test_utils::{double::Dummy, fake_data}; + use mithril_common::test_utils::double::{Dummy, fake_data}; use mithril_dmq::test::double::DmqPublisherFake; use super::*; diff --git a/mithril-signer/src/services/signature_publisher/retrier.rs b/mithril-signer/src/services/signature_publisher/retrier.rs index 78d2dc66a86..c58593d61c2 100644 --- a/mithril-signer/src/services/signature_publisher/retrier.rs +++ b/mithril-signer/src/services/signature_publisher/retrier.rs @@ -85,7 +85,7 @@ impl SignaturePublisher for SignaturePublisherRetrier { #[cfg(test)] mod tests { - use mithril_common::{entities::Epoch, test_utils::fake_data}; + use mithril_common::{entities::Epoch, test_utils::double::fake_data}; use crate::services::MockSignaturePublisher; diff --git a/mithril-signer/tests/test_extensions/certificate_handler.rs b/mithril-signer/tests/test_extensions/certificate_handler.rs index fb5a54903d5..0040d5dc455 100644 --- a/mithril-signer/tests/test_extensions/certificate_handler.rs +++ b/mithril-signer/tests/test_extensions/certificate_handler.rs @@ -10,7 +10,7 @@ use mithril_common::{ SignedEntityType, SignedEntityTypeDiscriminants, Signer, SingleSignature, TimePoint, }, messages::AggregatorFeaturesMessage, - test_utils::{double::Dummy, fake_data}, + test_utils::double::{Dummy, fake_data}, }; use mithril_ticker::{MithrilTickerService, TickerService}; @@ -170,7 +170,7 @@ mod tests { use mithril_cardano_node_chain::test::double::FakeChainObserver; use mithril_cardano_node_internal_database::test::double::DumbImmutableFileObserver; use mithril_common::entities::{BlockNumber, ChainPoint}; - use mithril_common::test_utils::fake_data; + use mithril_common::test_utils::double::fake_data; use super::*; From 8e64b7f612b7e7a598d7b15f356799722edb5d00 Mon Sep 17 00:00:00 2001 From: DJO <790521+Alenar@users.noreply.github.com> Date: Tue, 22 Jul 2025 17:27:49 +0200 Subject: [PATCH 02/15] refactor(common): rename `mithril_common::test_utils` module to `test` --- .../src/chain_observer/pallas_observer.rs | 2 +- .../src/chain_reader/pallas_chain_reader.rs | 2 +- .../src/test/double/chain_observer.rs | 2 +- .../src/digesters/cache/json_provider.rs | 2 +- .../src/digesters/cache/json_provider_builder.rs | 2 +- .../src/entities/immutable_file.rs | 2 +- .../src/entities/ledger_state_snapshot.rs | 2 +- internal/mithril-dmq/src/consumer/pallas.rs | 2 +- internal/mithril-dmq/src/message.rs | 2 +- internal/mithril-dmq/src/publisher/pallas.rs | 2 +- internal/mithril-dmq/src/test/payload.rs | 2 +- internal/mithril-era/src/adapters/bootstrap.rs | 2 +- internal/mithril-era/src/adapters/dummy.rs | 2 +- internal/mithril-era/src/adapters/file.rs | 2 +- internal/mithril-era/src/era_checker.rs | 2 +- internal/mithril-era/src/era_reader.rs | 2 +- .../repository/cardano_transaction_repository.rs | 2 +- .../src/database/version_checker.rs | 2 +- internal/mithril-persistence/src/sqlite/cleaner.rs | 2 +- .../src/sqlite/connection_builder.rs | 2 +- .../src/cardano_transactions_preloader.rs | 2 +- internal/tests/mithril-api-spec/src/apispec.rs | 2 +- .../benches/cardano_transactions_get.rs | 2 +- .../benches/cardano_transactions_import.rs | 2 +- .../src/artifact_builder/cardano_database.rs | 2 +- .../cardano_database_artifacts/ancillary.rs | 2 +- .../cardano_database_artifacts/digest.rs | 2 +- .../cardano_database_artifacts/immutable.rs | 4 ++-- .../cardano_immutable_files_full.rs | 2 +- .../artifact_builder/cardano_stake_distribution.rs | 2 +- .../src/artifact_builder/cardano_transactions.rs | 2 +- .../artifact_builder/mithril_stake_distribution.rs | 2 +- .../database/query/certificate/get_certificate.rs | 2 +- .../certificate/insert_or_replace_certificate.rs | 2 +- .../query/epoch_settings/update_epoch_settings.rs | 2 +- .../open_message/insert_or_replace_open_message.rs | 2 +- .../query/signed_entity/get_signed_entity.rs | 2 +- .../signer_registration/get_signer_registration.rs | 2 +- .../insert_or_replace_signer_registration.rs | 2 +- .../record/buffered_single_signature_record.rs | 2 +- .../src/database/record/certificate.rs | 2 +- .../src/database/record/signed_entity.rs | 4 ++-- .../src/database/record/signer_registration.rs | 2 +- .../src/database/record/single_signature.rs | 2 +- .../buffered_single_signature_repository.rs | 2 +- .../database/repository/epoch_settings_store.rs | 2 +- .../repository/immutable_file_digest_repository.rs | 2 +- .../database/repository/open_message_repository.rs | 2 +- .../src/database/repository/signed_entity_store.rs | 2 +- .../repository/signer_registration_store.rs | 2 +- mithril-aggregator/src/database/test_helper.rs | 2 +- .../src/dependency_injection/containers/serve.rs | 2 +- mithril-aggregator/src/entities/open_message.rs | 2 +- .../src/event_store/database/repository.rs | 2 +- .../src/file_uploaders/local_uploader.rs | 2 +- .../routes/artifact_routes/cardano_database.rs | 2 +- .../artifact_routes/cardano_stake_distribution.rs | 2 +- .../routes/artifact_routes/cardano_transaction.rs | 2 +- .../artifact_routes/mithril_stake_distribution.rs | 2 +- .../http_server/routes/artifact_routes/snapshot.rs | 2 +- .../src/http_server/routes/certificate_routes.rs | 2 +- .../src/http_server/routes/epoch_routes.rs | 2 +- .../src/http_server/routes/middlewares.rs | 2 +- .../src/http_server/routes/proof_routes.rs | 2 +- .../src/http_server/routes/root_routes.rs | 2 +- .../src/http_server/routes/router.rs | 2 +- .../src/http_server/routes/signatures_routes.rs | 3 +-- .../src/http_server/routes/signer_routes.rs | 2 +- .../src/http_server/routes/statistics_routes.rs | 2 +- .../src/http_server/routes/status.rs | 2 +- mithril-aggregator/src/lib.rs | 2 +- .../src/message_adapters/from_epoch_settings.rs | 2 +- .../message_adapters/from_register_signature.rs | 2 +- .../src/message_adapters/from_register_signer.rs | 2 +- .../to_cardano_transactions_proof_message.rs | 2 +- mithril-aggregator/src/multi_signer.rs | 2 +- mithril-aggregator/src/runtime/runner.rs | 2 +- mithril-aggregator/src/runtime/state_machine.rs | 2 +- .../src/services/aggregator_client.rs | 8 ++++---- .../synchronizer_service.rs | 2 +- .../src/services/certifier/buffered_certifier.rs | 2 +- .../src/services/certifier/certifier_service.rs | 2 +- mithril-aggregator/src/services/epoch_service.rs | 14 ++++++-------- mithril-aggregator/src/services/message.rs | 4 ++-- mithril-aggregator/src/services/prover.rs | 2 +- .../signable_builder/signable_seed_builder.rs | 2 +- .../src/services/signature_consumer/dmq.rs | 2 +- .../src/services/signature_consumer/fake.rs | 2 +- .../src/services/signature_processor.rs | 2 +- mithril-aggregator/src/services/signed_entity.rs | 2 +- .../src/services/signer_registration/follower.rs | 2 +- .../src/services/signer_registration/leader.rs | 2 +- .../src/services/signer_registration/verifier.rs | 2 +- .../snapshotter/compressed_archive_snapshotter.rs | 4 ++-- .../src/store/epoch_settings_storer.rs | 2 +- mithril-aggregator/src/test/double/dummies.rs | 2 +- .../src/tools/certificates_hash_migrator.rs | 2 +- mithril-aggregator/src/tools/era.rs | 2 +- mithril-aggregator/src/tools/file_archiver/api.rs | 2 +- .../src/tools/file_archiver/entities.rs | 2 +- mithril-aggregator/src/tools/file_archiver/mod.rs | 2 +- mithril-aggregator/src/tools/file_size.rs | 2 +- mithril-aggregator/src/tools/genesis.rs | 2 +- .../cardano_stake_distribution_verify_stakes.rs | 2 +- mithril-aggregator/tests/certificate_chain.rs | 2 +- mithril-aggregator/tests/create_certificate.rs | 2 +- .../tests/create_certificate_follower.rs | 4 +--- .../create_certificate_with_buffered_signatures.rs | 2 +- mithril-aggregator/tests/era_checker.rs | 2 +- mithril-aggregator/tests/genesis_to_signing.rs | 2 +- .../tests/open_message_expiration.rs | 2 +- .../tests/open_message_newer_exists.rs | 2 +- mithril-aggregator/tests/prove_transactions.rs | 2 +- .../tests/test_extensions/runtime_tester.rs | 2 +- .../tests/test_extensions/utilities.rs | 2 +- .../src/commands/cardano_db/download/v1.rs | 2 +- .../src/commands/cardano_db/download/v2.rs | 2 +- .../src/commands/cardano_db/shared_steps.rs | 2 +- .../src/utils/cardano_db_download_checker.rs | 2 +- mithril-client/src/aggregator_client.rs | 2 +- mithril-client/src/cardano_database_client/api.rs | 2 +- .../download_unpack/download_task.rs | 2 +- .../download_unpack/internal_downloader.rs | 4 ++-- .../src/cardano_database_client/fetch.rs | 2 +- .../src/cardano_database_client/proving.rs | 2 +- mithril-client/src/cardano_transaction_client.rs | 2 +- mithril-client/src/certificate_client/fetch.rs | 2 +- mithril-client/src/certificate_client/verify.rs | 4 ++-- .../verify_cache/memory_cache.rs | 2 +- mithril-client/src/file_downloader/http.rs | 2 +- mithril-client/src/lib.rs | 2 +- .../src/mithril_stake_distribution_client.rs | 2 +- mithril-client/src/snapshot_client.rs | 2 +- mithril-client/src/utils/ancillary_verifier.rs | 2 +- ...cardano_db_snapshot_list_get_download_verify.rs | 2 +- mithril-client/tests/cardano_transaction_proof.rs | 2 +- mithril-client/tests/certificate_get_list.rs | 2 +- .../extensions/fake_aggregator/cardano_db_v1.rs | 2 +- .../extensions/fake_aggregator/cardano_db_v2.rs | 2 +- .../fake_aggregator/cardano_transaction.rs | 2 +- .../extensions/fake_aggregator/certificate.rs | 2 +- .../fake_aggregator/mithril_stake_distribution.rs | 2 +- mithril-client/tests/extensions/mod.rs | 2 +- ...hril_stake_distribution_list_get_show_verify.rs | 2 +- .../snapshot_list_get_show_download_verify.rs | 2 +- .../src/certificate_chain/certificate_genesis.rs | 2 +- .../src/certificate_chain/certificate_verifier.rs | 2 +- .../fake_certificate_retriever.rs | 2 +- mithril-common/src/crypto_helper/cardano/codec.rs | 2 +- mithril-common/src/crypto_helper/cardano/opcert.rs | 2 +- mithril-common/src/crypto_helper/conversions.rs | 2 +- mithril-common/src/crypto_helper/tests_setup.rs | 2 +- .../src/crypto_helper/types/protocol_key.rs | 2 +- mithril-common/src/entities/certificate.rs | 2 +- .../src/entities/mithril_stake_distribution.rs | 2 +- .../src/entities/signed_entity_config.rs | 2 +- mithril-common/src/entities/signed_entity_type.rs | 2 +- mithril-common/src/entities/signer.rs | 2 +- mithril-common/src/entities/single_signature.rs | 4 ++-- mithril-common/src/entities/supported_era.rs | 2 +- mithril-common/src/lib.rs | 2 +- mithril-common/src/logging.rs | 2 +- .../src/messages/cardano_transactions_proof.rs | 2 +- .../src/messages/mithril_stake_distribution.rs | 2 +- mithril-common/src/messages/snapshot.rs | 2 +- mithril-common/src/protocol/multi_signer.rs | 4 ++-- mithril-common/src/protocol/signer_builder.rs | 4 ++-- mithril-common/src/protocol/single_signer.rs | 2 +- .../src/signable_builder/cardano_transactions.rs | 2 +- .../signable_builder/signable_builder_service.rs | 2 +- .../cardano_transactions_builder.rs | 4 ++-- .../certificate_chain_builder.rs | 8 ++++---- mithril-common/src/{test_utils => test}/dir_eq.rs | 10 +++++----- .../src/{test_utils => test}/double/dummies.rs | 2 +- .../src/{test_utils => test}/double/fake_data.rs | 2 +- .../src/{test_utils => test}/double/fake_keys.rs | 0 .../src/{test_utils => test}/double/mod.rs | 2 +- .../double/precomputed_kes_key.rs | 0 .../src/{test_utils => test}/fixture_builder.rs | 2 +- .../src/{test_utils => test}/memory_logger.rs | 0 .../src/{test_utils => test}/mithril_fixture.rs | 0 .../src/{test_utils => test}/mock_extensions.rs | 2 +- mithril-common/src/{test_utils => test}/mod.rs | 8 ++++---- .../src/{test_utils => test}/temp_dir.rs | 12 ++++++------ mithril-relay/src/relay/aggregator.rs | 2 +- mithril-relay/src/relay/signer.rs | 2 +- mithril-relay/tests/register_signer_signature.rs | 2 +- .../repository/signed_beacon_repository.rs | 2 +- .../src/database/tests/protocol_initializer.rs | 2 +- mithril-signer/src/dependency_injection/builder.rs | 4 ++-- .../src/entities/signer_epoch_settings.rs | 4 ++-- mithril-signer/src/lib.rs | 2 +- .../src/message_adapters/from_epoch_settings.rs | 2 +- .../to_register_signature_message.rs | 2 +- .../message_adapters/to_register_signer_message.rs | 2 +- mithril-signer/src/runtime/runner.rs | 2 +- mithril-signer/src/runtime/state_machine.rs | 2 +- mithril-signer/src/services/aggregator_client.rs | 4 ++-- .../importer/importer_with_vacuum.rs | 2 +- .../cardano_transactions/preloader_checker.rs | 2 +- mithril-signer/src/services/certifier.rs | 2 +- mithril-signer/src/services/epoch_service.rs | 4 ++-- .../signable_builder/signable_seed_builder.rs | 2 +- .../src/services/signature_publisher/delayer.rs | 2 +- .../src/services/signature_publisher/dmq.rs | 2 +- .../src/services/signature_publisher/retrier.rs | 2 +- mithril-signer/src/services/single_signer.rs | 2 +- mithril-signer/src/services/upkeep_service.rs | 2 +- .../create_cardano_transaction_single_signature.rs | 2 +- ...create_immutable_files_full_single_signature.rs | 2 +- mithril-signer/tests/era_switch.rs | 2 +- .../tests/test_extensions/certificate_handler.rs | 4 ++-- .../tests/test_extensions/state_machine_tester.rs | 2 +- .../src/bin/load-aggregator/main.rs | 2 +- .../src/stress_test/aggregator_helpers.rs | 2 +- .../src/stress_test/fake_chain.rs | 2 +- .../src/stress_test/payload_builder.rs | 2 +- .../mithril-end-to-end/src/utils/file_utils.rs | 2 +- 218 files changed, 252 insertions(+), 257 deletions(-) rename mithril-common/src/{test_utils => test}/cardano_transactions_builder.rs (98%) rename mithril-common/src/{test_utils => test}/certificate_chain_builder.rs (99%) rename mithril-common/src/{test_utils => test}/dir_eq.rs (96%) rename mithril-common/src/{test_utils => test}/double/dummies.rs (99%) rename mithril-common/src/{test_utils => test}/double/fake_data.rs (99%) rename mithril-common/src/{test_utils => test}/double/fake_keys.rs (100%) rename mithril-common/src/{test_utils => test}/double/mod.rs (95%) rename mithril-common/src/{test_utils => test}/double/precomputed_kes_key.rs (100%) rename mithril-common/src/{test_utils => test}/fixture_builder.rs (99%) rename mithril-common/src/{test_utils => test}/memory_logger.rs (100%) rename mithril-common/src/{test_utils => test}/mithril_fixture.rs (100%) rename mithril-common/src/{test_utils => test}/mock_extensions.rs (96%) rename mithril-common/src/{test_utils => test}/mod.rs (96%) rename mithril-common/src/{test_utils => test}/temp_dir.rs (95%) diff --git a/internal/cardano-node/mithril-cardano-node-chain/src/chain_observer/pallas_observer.rs b/internal/cardano-node/mithril-cardano-node-chain/src/chain_observer/pallas_observer.rs index 47505a3132d..e6983138d0e 100644 --- a/internal/cardano-node/mithril-cardano-node-chain/src/chain_observer/pallas_observer.rs +++ b/internal/cardano-node/mithril-cardano-node-chain/src/chain_observer/pallas_observer.rs @@ -529,7 +529,7 @@ mod tests { use tokio::net::UnixListener; use mithril_common::crypto_helper::ColdKeyGenerator; - use mithril_common::test_utils::TempDir; + use mithril_common::test::TempDir; use super::*; diff --git a/internal/cardano-node/mithril-cardano-node-chain/src/chain_reader/pallas_chain_reader.rs b/internal/cardano-node/mithril-cardano-node-chain/src/chain_reader/pallas_chain_reader.rs index 66f44941588..a1181162f55 100644 --- a/internal/cardano-node/mithril-cardano-node-chain/src/chain_reader/pallas_chain_reader.rs +++ b/internal/cardano-node/mithril-cardano-node-chain/src/chain_reader/pallas_chain_reader.rs @@ -160,7 +160,7 @@ mod tests { use std::fs; use tokio::net::UnixListener; - use mithril_common::{current_function, entities::BlockNumber, test_utils::TempDir}; + use mithril_common::{current_function, entities::BlockNumber, test::TempDir}; use crate::test::TestLogger; diff --git a/internal/cardano-node/mithril-cardano-node-chain/src/test/double/chain_observer.rs b/internal/cardano-node/mithril-cardano-node-chain/src/test/double/chain_observer.rs index 00843c5e92f..803675aa78f 100644 --- a/internal/cardano-node/mithril-cardano-node-chain/src/test/double/chain_observer.rs +++ b/internal/cardano-node/mithril-cardano-node-chain/src/test/double/chain_observer.rs @@ -212,7 +212,7 @@ impl ChainObserver for FakeChainObserver { #[cfg(test)] mod tests { - use mithril_common::test_utils::double::{Dummy, fake_data}; + use mithril_common::test::double::{Dummy, fake_data}; use super::*; diff --git a/internal/cardano-node/mithril-cardano-node-internal-database/src/digesters/cache/json_provider.rs b/internal/cardano-node/mithril-cardano-node-internal-database/src/digesters/cache/json_provider.rs index 240f1c1cc6d..9c11a1a0632 100644 --- a/internal/cardano-node/mithril-cardano-node-internal-database/src/digesters/cache/json_provider.rs +++ b/internal/cardano-node/mithril-cardano-node-internal-database/src/digesters/cache/json_provider.rs @@ -109,7 +109,7 @@ impl ImmutableFileDigestCacheProvider for JsonImmutableFileDigestCacheProvider { mod tests { use std::{collections::BTreeMap, path::PathBuf}; - use mithril_common::test_utils::TempDir; + use mithril_common::test::TempDir; use crate::digesters::cache::{ ImmutableFileDigestCacheProvider, JsonImmutableFileDigestCacheProvider, diff --git a/internal/cardano-node/mithril-cardano-node-internal-database/src/digesters/cache/json_provider_builder.rs b/internal/cardano-node/mithril-cardano-node-internal-database/src/digesters/cache/json_provider_builder.rs index 9b317df8a09..561c277da06 100644 --- a/internal/cardano-node/mithril-cardano-node-internal-database/src/digesters/cache/json_provider_builder.rs +++ b/internal/cardano-node/mithril-cardano-node-internal-database/src/digesters/cache/json_provider_builder.rs @@ -86,7 +86,7 @@ impl<'a> JsonImmutableFileDigestCacheProviderBuilder<'a> { mod tests { use std::path::PathBuf; - use mithril_common::test_utils::TempDir; + use mithril_common::test::TempDir; use crate::digesters::cache::JsonImmutableFileDigestCacheProviderBuilder; diff --git a/internal/cardano-node/mithril-cardano-node-internal-database/src/entities/immutable_file.rs b/internal/cardano-node/mithril-cardano-node-internal-database/src/entities/immutable_file.rs index 51ffdc734b5..09f9eed3c3e 100644 --- a/internal/cardano-node/mithril-cardano-node-internal-database/src/entities/immutable_file.rs +++ b/internal/cardano-node/mithril-cardano-node-internal-database/src/entities/immutable_file.rs @@ -201,7 +201,7 @@ mod tests { use std::io::prelude::*; use mithril_common::temp_dir_create; - use mithril_common::test_utils::TempDir; + use mithril_common::test::TempDir; use super::*; diff --git a/internal/cardano-node/mithril-cardano-node-internal-database/src/entities/ledger_state_snapshot.rs b/internal/cardano-node/mithril-cardano-node-internal-database/src/entities/ledger_state_snapshot.rs index f48b15a903d..4d995a8be5b 100644 --- a/internal/cardano-node/mithril-cardano-node-internal-database/src/entities/ledger_state_snapshot.rs +++ b/internal/cardano-node/mithril-cardano-node-internal-database/src/entities/ledger_state_snapshot.rs @@ -191,7 +191,7 @@ mod tests { use std::fs::{File, create_dir}; use std::io::prelude::*; - use mithril_common::test_utils::temp_dir_create; + use mithril_common::test::temp_dir_create; use super::*; diff --git a/internal/mithril-dmq/src/consumer/pallas.rs b/internal/mithril-dmq/src/consumer/pallas.rs index ef59e37c6eb..bb2cc0f5bc9 100644 --- a/internal/mithril-dmq/src/consumer/pallas.rs +++ b/internal/mithril-dmq/src/consumer/pallas.rs @@ -144,7 +144,7 @@ mod tests { use std::{fs, future, time::Duration, vec}; - use mithril_common::{crypto_helper::TryToBytes, current_function, test_utils::TempDir}; + use mithril_common::{crypto_helper::TryToBytes, current_function, test::TempDir}; use pallas_network::{ facades::DmqServer, miniprotocols::{localmsgnotification, localmsgsubmission::DmqMsg}, diff --git a/internal/mithril-dmq/src/message.rs b/internal/mithril-dmq/src/message.rs index 08de36ae2c0..d7d3b89b56b 100644 --- a/internal/mithril-dmq/src/message.rs +++ b/internal/mithril-dmq/src/message.rs @@ -94,7 +94,7 @@ mod tests { use mithril_common::{ crypto_helper::{KesSignerFake, TryToBytes}, entities::{BlockNumber, ChainPoint, TimePoint}, - test_utils::double::Dummy, + test::double::Dummy, }; use super::*; diff --git a/internal/mithril-dmq/src/publisher/pallas.rs b/internal/mithril-dmq/src/publisher/pallas.rs index 55f8329584b..3295fcfd024 100644 --- a/internal/mithril-dmq/src/publisher/pallas.rs +++ b/internal/mithril-dmq/src/publisher/pallas.rs @@ -93,7 +93,7 @@ mod tests { use mithril_common::{ crypto_helper::KesSignerFake, current_function, - test_utils::{TempDir, double::Dummy}, + test::{TempDir, double::Dummy}, }; use crate::{test::payload::DmqMessageTestPayload, test_tools::TestLogger}; diff --git a/internal/mithril-dmq/src/test/payload.rs b/internal/mithril-dmq/src/test/payload.rs index 6fd5098d515..d43b5b9d52f 100644 --- a/internal/mithril-dmq/src/test/payload.rs +++ b/internal/mithril-dmq/src/test/payload.rs @@ -3,7 +3,7 @@ use std::fmt::Debug; use mithril_common::{ StdResult, crypto_helper::{TryFromBytes, TryToBytes}, - test_utils::double::Dummy, + test::double::Dummy, }; /// A test message payload for the DMQ. diff --git a/internal/mithril-era/src/adapters/bootstrap.rs b/internal/mithril-era/src/adapters/bootstrap.rs index ca3b0c1e38f..11ac02ea7ca 100644 --- a/internal/mithril-era/src/adapters/bootstrap.rs +++ b/internal/mithril-era/src/adapters/bootstrap.rs @@ -22,7 +22,7 @@ impl EraReaderAdapter for BootstrapAdapter { #[cfg(test)] mod tests { - use mithril_common::test_utils::double::Dummy; + use mithril_common::test::double::Dummy; use super::*; diff --git a/internal/mithril-era/src/adapters/dummy.rs b/internal/mithril-era/src/adapters/dummy.rs index 1968496a84e..6bfdda65844 100644 --- a/internal/mithril-era/src/adapters/dummy.rs +++ b/internal/mithril-era/src/adapters/dummy.rs @@ -40,7 +40,7 @@ impl EraReaderAdapter for DummyAdapter { #[cfg(test)] mod tests { use mithril_common::entities::{Epoch, SupportedEra}; - use mithril_common::test_utils::double::Dummy; + use mithril_common::test::double::Dummy; use super::*; diff --git a/internal/mithril-era/src/adapters/file.rs b/internal/mithril-era/src/adapters/file.rs index 4d4de67b093..746590ff12c 100644 --- a/internal/mithril-era/src/adapters/file.rs +++ b/internal/mithril-era/src/adapters/file.rs @@ -30,7 +30,7 @@ impl EraReaderAdapter for FileAdapter { #[cfg(test)] mod tests { use mithril_common::entities::{Epoch, SupportedEra}; - use mithril_common::test_utils::{TempDir, double::Dummy}; + use mithril_common::test::{TempDir, double::Dummy}; use super::*; diff --git a/internal/mithril-era/src/era_checker.rs b/internal/mithril-era/src/era_checker.rs index 828aae208da..92417325bde 100644 --- a/internal/mithril-era/src/era_checker.rs +++ b/internal/mithril-era/src/era_checker.rs @@ -55,7 +55,7 @@ impl ApiVersionDiscriminantSource for EraChecker { #[cfg(test)] mod tests { - use mithril_common::test_utils::double::Dummy; + use mithril_common::test::double::Dummy; use super::*; diff --git a/internal/mithril-era/src/era_reader.rs b/internal/mithril-era/src/era_reader.rs index 691bf69390b..bdd673887f0 100644 --- a/internal/mithril-era/src/era_reader.rs +++ b/internal/mithril-era/src/era_reader.rs @@ -176,7 +176,7 @@ impl EraReader { #[cfg(test)] mod tests { - use mithril_common::test_utils::double::Dummy; + use mithril_common::test::double::Dummy; use super::super::adapters::EraReaderDummyAdapter as DummyAdapter; use super::*; diff --git a/internal/mithril-persistence/src/database/repository/cardano_transaction_repository.rs b/internal/mithril-persistence/src/database/repository/cardano_transaction_repository.rs index cec8b7b93f3..e2050e89f67 100644 --- a/internal/mithril-persistence/src/database/repository/cardano_transaction_repository.rs +++ b/internal/mithril-persistence/src/database/repository/cardano_transaction_repository.rs @@ -325,7 +325,7 @@ impl BlockRangeRootRetriever for CardanoTransactionRepositor #[cfg(test)] mod tests { - use mithril_common::test_utils::CardanoTransactionsBuilder; + use mithril_common::test::CardanoTransactionsBuilder; use crate::database::query::GetBlockRangeRootQuery; use crate::database::test_helper::cardano_tx_db_connection; diff --git a/internal/mithril-persistence/src/database/version_checker.rs b/internal/mithril-persistence/src/database/version_checker.rs index 186e65f1c27..3e5f2ffe94e 100644 --- a/internal/mithril-persistence/src/database/version_checker.rs +++ b/internal/mithril-persistence/src/database/version_checker.rs @@ -269,7 +269,7 @@ impl Eq for SqlMigration {} #[cfg(test)] mod tests { use anyhow::Context; - use mithril_common::test_utils::TempDir; + use mithril_common::test::TempDir; use mithril_common::{StdResult, current_function}; use sqlite::{Connection, ConnectionThreadSafe}; use std::path::PathBuf; diff --git a/internal/mithril-persistence/src/sqlite/cleaner.rs b/internal/mithril-persistence/src/sqlite/cleaner.rs index 67586412331..19fc2ae0b1f 100644 --- a/internal/mithril-persistence/src/sqlite/cleaner.rs +++ b/internal/mithril-persistence/src/sqlite/cleaner.rs @@ -95,7 +95,7 @@ mod tests { use std::ops::Range; use std::path::Path; - use mithril_common::test_utils::TempDir; + use mithril_common::test::TempDir; use crate::sqlite::{ConnectionBuilder, ConnectionOptions, SqliteConnection}; diff --git a/internal/mithril-persistence/src/sqlite/connection_builder.rs b/internal/mithril-persistence/src/sqlite/connection_builder.rs index 77469157e6d..582142c7fb9 100644 --- a/internal/mithril-persistence/src/sqlite/connection_builder.rs +++ b/internal/mithril-persistence/src/sqlite/connection_builder.rs @@ -144,7 +144,7 @@ impl ConnectionBuilder { mod tests { use sqlite::Value; - use mithril_common::test_utils::TempDir; + use mithril_common::test::TempDir; use crate::sqlite::ConnectionOptions::ForceDisableForeignKeys; diff --git a/internal/signed-entity/mithril-signed-entity-preloader/src/cardano_transactions_preloader.rs b/internal/signed-entity/mithril-signed-entity-preloader/src/cardano_transactions_preloader.rs index 9cf2f04f759..f480ffeae5d 100644 --- a/internal/signed-entity/mithril-signed-entity-preloader/src/cardano_transactions_preloader.rs +++ b/internal/signed-entity/mithril-signed-entity-preloader/src/cardano_transactions_preloader.rs @@ -128,7 +128,7 @@ mod tests { use mithril_cardano_node_chain::test::double::FakeChainObserver; use mithril_common::entities::{BlockNumber, ChainPoint, TimePoint}; - use mithril_common::test_utils::double::Dummy; + use mithril_common::test::double::Dummy; use crate::test_tools::TestLogger; diff --git a/internal/tests/mithril-api-spec/src/apispec.rs b/internal/tests/mithril-api-spec/src/apispec.rs index b0cb3fa3c4a..fabe5ff99b0 100644 --- a/internal/tests/mithril-api-spec/src/apispec.rs +++ b/internal/tests/mithril-api-spec/src/apispec.rs @@ -343,7 +343,7 @@ mod tests { use mithril_common::entities; use mithril_common::messages::{AggregatorFeaturesMessage, SignerMessagePart}; - use mithril_common::test_utils::{ + use mithril_common::test::{ TempDir, double::{Dummy, fake_data}, }; diff --git a/mithril-aggregator/benches/cardano_transactions_get.rs b/mithril-aggregator/benches/cardano_transactions_get.rs index f7b3aa525be..ab1efa132bd 100644 --- a/mithril-aggregator/benches/cardano_transactions_get.rs +++ b/mithril-aggregator/benches/cardano_transactions_get.rs @@ -5,7 +5,7 @@ use sqlite::ConnectionThreadSafe; use mithril_aggregator::services::TransactionStore; use mithril_common::entities::{BlockNumber, CardanoTransaction, SlotNumber}; -use mithril_common::test_utils::TempDir; +use mithril_common::test::TempDir; use mithril_persistence::database::repository::CardanoTransactionRepository; use mithril_persistence::sqlite::{ConnectionBuilder, SqliteConnectionPool}; diff --git a/mithril-aggregator/benches/cardano_transactions_import.rs b/mithril-aggregator/benches/cardano_transactions_import.rs index a36af17452e..4e5a66d0472 100644 --- a/mithril-aggregator/benches/cardano_transactions_import.rs +++ b/mithril-aggregator/benches/cardano_transactions_import.rs @@ -3,7 +3,7 @@ use sqlite::ConnectionThreadSafe; use std::sync::Arc; use mithril_common::entities::{BlockNumber, CardanoTransaction, SlotNumber}; -use mithril_common::test_utils::TempDir; +use mithril_common::test::TempDir; use mithril_persistence::database::repository::CardanoTransactionRepository; use mithril_persistence::sqlite::{ConnectionBuilder, SqliteConnectionPool}; diff --git a/mithril-aggregator/src/artifact_builder/cardano_database.rs b/mithril-aggregator/src/artifact_builder/cardano_database.rs index 2099701d73d..49ded872526 100644 --- a/mithril-aggregator/src/artifact_builder/cardano_database.rs +++ b/mithril-aggregator/src/artifact_builder/cardano_database.rs @@ -112,7 +112,7 @@ mod tests { ImmutablesLocation, MultiFilesUri, ProtocolMessage, ProtocolMessagePartKey, TemplateUri, }, - test_utils::{ + test::{ TempDir, double::{fake_data, fake_keys}, }, diff --git a/mithril-aggregator/src/artifact_builder/cardano_database_artifacts/ancillary.rs b/mithril-aggregator/src/artifact_builder/cardano_database_artifacts/ancillary.rs index 31a60961d92..94166994b64 100644 --- a/mithril-aggregator/src/artifact_builder/cardano_database_artifacts/ancillary.rs +++ b/mithril-aggregator/src/artifact_builder/cardano_database_artifacts/ancillary.rs @@ -206,7 +206,7 @@ impl AncillaryArtifactBuilder { mod tests { use std::path::PathBuf; - use mithril_common::test_utils::{TempDir, assert_equivalent, double::Dummy}; + use mithril_common::test::{TempDir, assert_equivalent, double::Dummy}; use crate::services::{DumbSnapshotter, MockSnapshotter}; use crate::test_tools::TestLogger; diff --git a/mithril-aggregator/src/artifact_builder/cardano_database_artifacts/digest.rs b/mithril-aggregator/src/artifact_builder/cardano_database_artifacts/digest.rs index f63382bebd4..8bb515c1fc0 100644 --- a/mithril-aggregator/src/artifact_builder/cardano_database_artifacts/digest.rs +++ b/mithril-aggregator/src/artifact_builder/cardano_database_artifacts/digest.rs @@ -299,7 +299,7 @@ mod tests { current_function, entities::{CardanoDbBeacon, CompressionAlgorithm}, messages::{CardanoDatabaseDigestListItemMessage, CardanoDatabaseDigestListMessage}, - test_utils::{TempDir, assert_equivalent, double::Dummy}, + test::{TempDir, assert_equivalent, double::Dummy}, }; use crate::{ diff --git a/mithril-aggregator/src/artifact_builder/cardano_database_artifacts/immutable.rs b/mithril-aggregator/src/artifact_builder/cardano_database_artifacts/immutable.rs index 81874bc5708..a57445777d5 100644 --- a/mithril-aggregator/src/artifact_builder/cardano_database_artifacts/immutable.rs +++ b/mithril-aggregator/src/artifact_builder/cardano_database_artifacts/immutable.rs @@ -281,7 +281,7 @@ mod tests { use mithril_cardano_node_internal_database::test::DummyCardanoDbBuilder; use mithril_common::{ entities::TemplateUri, - test_utils::{TempDir, assert_equivalent, equivalent_to}, + test::{TempDir, assert_equivalent, equivalent_to}, }; use crate::services::ancillary_signer::MockAncillarySigner; @@ -853,7 +853,7 @@ mod tests { } mod batch_upload { - use mithril_common::test_utils::TempDir; + use mithril_common::test::TempDir; use crate::file_uploaders::FileUploadRetryPolicy; use crate::tools::url_sanitizer::SanitizedUrlWithTrailingSlash; diff --git a/mithril-aggregator/src/artifact_builder/cardano_immutable_files_full.rs b/mithril-aggregator/src/artifact_builder/cardano_immutable_files_full.rs index 79693f87005..8fe5dcf5d41 100644 --- a/mithril-aggregator/src/artifact_builder/cardano_immutable_files_full.rs +++ b/mithril-aggregator/src/artifact_builder/cardano_immutable_files_full.rs @@ -206,7 +206,7 @@ mod tests { use anyhow::anyhow; use tempfile::NamedTempFile; - use mithril_common::{entities::CompressionAlgorithm, test_utils::double::fake_data}; + use mithril_common::{entities::CompressionAlgorithm, test::double::fake_data}; use crate::{ DumbUploader, file_uploaders::MockFileUploader, services::DumbSnapshotter, diff --git a/mithril-aggregator/src/artifact_builder/cardano_stake_distribution.rs b/mithril-aggregator/src/artifact_builder/cardano_stake_distribution.rs index 39b00b0ca41..f26253458a4 100644 --- a/mithril-aggregator/src/artifact_builder/cardano_stake_distribution.rs +++ b/mithril-aggregator/src/artifact_builder/cardano_stake_distribution.rs @@ -43,7 +43,7 @@ impl ArtifactBuilder for CardanoStakeDistributi #[cfg(test)] mod tests { - use mithril_common::{entities::StakeDistribution, test_utils::double::fake_data}; + use mithril_common::{entities::StakeDistribution, test::double::fake_data}; use mockall::{mock, predicate::eq}; use super::*; diff --git a/mithril-aggregator/src/artifact_builder/cardano_transactions.rs b/mithril-aggregator/src/artifact_builder/cardano_transactions.rs index 83ece810522..1aa5f823a86 100644 --- a/mithril-aggregator/src/artifact_builder/cardano_transactions.rs +++ b/mithril-aggregator/src/artifact_builder/cardano_transactions.rs @@ -58,7 +58,7 @@ impl ArtifactBuilder #[cfg(test)] mod tests { - use mithril_common::{entities::ProtocolMessage, test_utils::double::fake_data}; + use mithril_common::{entities::ProtocolMessage, test::double::fake_data}; use crate::services::MockProverService; diff --git a/mithril-aggregator/src/artifact_builder/mithril_stake_distribution.rs b/mithril-aggregator/src/artifact_builder/mithril_stake_distribution.rs index c80721ff709..3e703a70a8e 100644 --- a/mithril-aggregator/src/artifact_builder/mithril_stake_distribution.rs +++ b/mithril-aggregator/src/artifact_builder/mithril_stake_distribution.rs @@ -40,7 +40,7 @@ impl ArtifactBuilder for MithrilStakeDistributi mod tests { use mithril_common::{ crypto_helper::ProtocolParameters, - test_utils::double::{Dummy, fake_data}, + test::double::{Dummy, fake_data}, }; use std::sync::Arc; use tokio::sync::RwLock; diff --git a/mithril-aggregator/src/database/query/certificate/get_certificate.rs b/mithril-aggregator/src/database/query/certificate/get_certificate.rs index 8808cd57218..697ef75f3b1 100644 --- a/mithril-aggregator/src/database/query/certificate/get_certificate.rs +++ b/mithril-aggregator/src/database/query/certificate/get_certificate.rs @@ -61,7 +61,7 @@ impl Query for GetCertificateRecordQuery { mod tests { use mithril_common::crypto_helper::ProtocolParameters; use mithril_common::crypto_helper::tests_setup::setup_certificate_chain; - use mithril_common::test_utils::CertificateChainBuilder; + use mithril_common::test::CertificateChainBuilder; use mithril_persistence::sqlite::ConnectionExtensions; diff --git a/mithril-aggregator/src/database/query/certificate/insert_or_replace_certificate.rs b/mithril-aggregator/src/database/query/certificate/insert_or_replace_certificate.rs index f5f94fc27c7..0c28cce6b21 100644 --- a/mithril-aggregator/src/database/query/certificate/insert_or_replace_certificate.rs +++ b/mithril-aggregator/src/database/query/certificate/insert_or_replace_certificate.rs @@ -40,7 +40,7 @@ mod tests { use mithril_common::crypto_helper::tests_setup::setup_certificate_chain; use mithril_common::entities::Epoch; - use mithril_common::test_utils::double::fake_data; + use mithril_common::test::double::fake_data; use mithril_persistence::sqlite::ConnectionExtensions; use crate::database::query::{GetCertificateRecordQuery, InsertCertificateRecordQuery}; diff --git a/mithril-aggregator/src/database/query/epoch_settings/update_epoch_settings.rs b/mithril-aggregator/src/database/query/epoch_settings/update_epoch_settings.rs index f24eacd06ec..b20211f22f2 100644 --- a/mithril-aggregator/src/database/query/epoch_settings/update_epoch_settings.rs +++ b/mithril-aggregator/src/database/query/epoch_settings/update_epoch_settings.rs @@ -53,7 +53,7 @@ impl Query for UpdateEpochSettingsQuery { #[cfg(test)] mod tests { use mithril_common::entities::{BlockNumber, CardanoTransactionsSigningConfig}; - use mithril_common::test_utils::double::fake_data; + use mithril_common::test::double::fake_data; use mithril_persistence::sqlite::ConnectionExtensions; use crate::database::query::GetEpochSettingsQuery; diff --git a/mithril-aggregator/src/database/query/open_message/insert_or_replace_open_message.rs b/mithril-aggregator/src/database/query/open_message/insert_or_replace_open_message.rs index b5f35588ba3..3fc3158f4fa 100644 --- a/mithril-aggregator/src/database/query/open_message/insert_or_replace_open_message.rs +++ b/mithril-aggregator/src/database/query/open_message/insert_or_replace_open_message.rs @@ -34,7 +34,7 @@ impl Query for InsertOrReplaceOpenMessageQuery { #[cfg(test)] mod tests { - use mithril_common::test_utils::double::Dummy; + use mithril_common::test::double::Dummy; use mithril_persistence::sqlite::ConnectionExtensions; use crate::database::query::GetOpenMessageQuery; diff --git a/mithril-aggregator/src/database/query/signed_entity/get_signed_entity.rs b/mithril-aggregator/src/database/query/signed_entity/get_signed_entity.rs index 6ba7ed951a1..99f25dcfe00 100644 --- a/mithril-aggregator/src/database/query/signed_entity/get_signed_entity.rs +++ b/mithril-aggregator/src/database/query/signed_entity/get_signed_entity.rs @@ -96,7 +96,7 @@ mod tests { use chrono::DateTime; use mithril_common::{ entities::{CardanoDbBeacon, SignedEntityType}, - test_utils::double::fake_data, + test::double::fake_data, }; use mithril_persistence::sqlite::ConnectionExtensions; use sqlite::ConnectionThreadSafe; diff --git a/mithril-aggregator/src/database/query/signer_registration/get_signer_registration.rs b/mithril-aggregator/src/database/query/signer_registration/get_signer_registration.rs index d5b66ea2ec0..d2e02f7d6c0 100644 --- a/mithril-aggregator/src/database/query/signer_registration/get_signer_registration.rs +++ b/mithril-aggregator/src/database/query/signer_registration/get_signer_registration.rs @@ -59,7 +59,7 @@ mod tests { use chrono::{DateTime, Utc}; use mithril_common::entities::SignerWithStake; - use mithril_common::test_utils::MithrilFixtureBuilder; + use mithril_common::test::MithrilFixtureBuilder; use mithril_persistence::sqlite::ConnectionExtensions; use crate::database::test_helper::{insert_signer_registrations, main_db_connection}; diff --git a/mithril-aggregator/src/database/query/signer_registration/insert_or_replace_signer_registration.rs b/mithril-aggregator/src/database/query/signer_registration/insert_or_replace_signer_registration.rs index 916a0154016..8f9d50effdf 100644 --- a/mithril-aggregator/src/database/query/signer_registration/insert_or_replace_signer_registration.rs +++ b/mithril-aggregator/src/database/query/signer_registration/insert_or_replace_signer_registration.rs @@ -63,7 +63,7 @@ impl Query for InsertOrReplaceSignerRegistrationRecordQuery { #[cfg(test)] mod tests { use mithril_common::entities::Epoch; - use mithril_common::test_utils::MithrilFixtureBuilder; + use mithril_common::test::MithrilFixtureBuilder; use mithril_persistence::sqlite::ConnectionExtensions; use crate::database::test_helper::main_db_connection; diff --git a/mithril-aggregator/src/database/record/buffered_single_signature_record.rs b/mithril-aggregator/src/database/record/buffered_single_signature_record.rs index 91d81a5a3ac..acff5acc0c3 100644 --- a/mithril-aggregator/src/database/record/buffered_single_signature_record.rs +++ b/mithril-aggregator/src/database/record/buffered_single_signature_record.rs @@ -176,7 +176,7 @@ mod tests { use mithril_common::entities::SignedEntityTypeDiscriminants::{ CardanoTransactions, MithrilStakeDistribution, }; - use mithril_common::test_utils::double::fake_data; + use mithril_common::test::double::fake_data; use super::*; diff --git a/mithril-aggregator/src/database/record/certificate.rs b/mithril-aggregator/src/database/record/certificate.rs index 32fc0b0f9ec..d05d82b62f5 100644 --- a/mithril-aggregator/src/database/record/certificate.rs +++ b/mithril-aggregator/src/database/record/certificate.rs @@ -12,7 +12,7 @@ use mithril_common::messages::{ #[cfg(test)] use mithril_common::{ entities::{CardanoDbBeacon, ImmutableFileNumber}, - test_utils::double::{fake_data, fake_keys}, + test::double::{fake_data, fake_keys}, }; use mithril_persistence::{ database::Hydrator, diff --git a/mithril-aggregator/src/database/record/signed_entity.rs b/mithril-aggregator/src/database/record/signed_entity.rs index 89a976638b0..76f3a4af294 100644 --- a/mithril-aggregator/src/database/record/signed_entity.rs +++ b/mithril-aggregator/src/database/record/signed_entity.rs @@ -101,7 +101,7 @@ impl SignedEntityRecord { } pub(crate) fn fake_records(number_if_records: usize) -> Vec { - use mithril_common::test_utils::double::fake_data; + use mithril_common::test::double::fake_data; let snapshots = fake_data::snapshots(number_if_records as u64); (0..number_if_records) @@ -435,7 +435,7 @@ impl SqLiteEntity for SignedEntityRecord { #[cfg(test)] mod tests { - use mithril_common::test_utils::double::fake_data; + use mithril_common::test::double::fake_data; use super::*; diff --git a/mithril-aggregator/src/database/record/signer_registration.rs b/mithril-aggregator/src/database/record/signer_registration.rs index 275e40b78ff..59bd9925db5 100644 --- a/mithril-aggregator/src/database/record/signer_registration.rs +++ b/mithril-aggregator/src/database/record/signer_registration.rs @@ -172,7 +172,7 @@ impl SqLiteEntity for SignerRegistrationRecord { #[cfg(test)] mod tests { - use mithril_common::test_utils::MithrilFixtureBuilder; + use mithril_common::test::MithrilFixtureBuilder; use super::*; diff --git a/mithril-aggregator/src/database/record/single_signature.rs b/mithril-aggregator/src/database/record/single_signature.rs index 58711b8a2a4..6fc03592463 100644 --- a/mithril-aggregator/src/database/record/single_signature.rs +++ b/mithril-aggregator/src/database/record/single_signature.rs @@ -133,7 +133,7 @@ impl SqLiteEntity for SingleSignatureRecord { #[cfg(test)] mod tests { - use mithril_common::test_utils::double::fake_data; + use mithril_common::test::double::fake_data; use super::*; diff --git a/mithril-aggregator/src/database/repository/buffered_single_signature_repository.rs b/mithril-aggregator/src/database/repository/buffered_single_signature_repository.rs index 6913bef3a77..dcc49c3ae74 100644 --- a/mithril-aggregator/src/database/repository/buffered_single_signature_repository.rs +++ b/mithril-aggregator/src/database/repository/buffered_single_signature_repository.rs @@ -104,7 +104,7 @@ mod tests { use mithril_common::entities::SignedEntityTypeDiscriminants::{ CardanoTransactions, MithrilStakeDistribution, }; - use mithril_common::test_utils::double::fake_keys; + use mithril_common::test::double::fake_keys; use crate::database::record::{BufferedSingleSignatureRecord, strip_buffered_sigs_date}; use crate::database::test_helper::{insert_buffered_single_signatures, main_db_connection}; diff --git a/mithril-aggregator/src/database/repository/epoch_settings_store.rs b/mithril-aggregator/src/database/repository/epoch_settings_store.rs index 1a32f54947d..8949657149a 100644 --- a/mithril-aggregator/src/database/repository/epoch_settings_store.rs +++ b/mithril-aggregator/src/database/repository/epoch_settings_store.rs @@ -92,7 +92,7 @@ impl EpochPruningTask for EpochSettingsStore { #[cfg(test)] mod tests { - use mithril_common::test_utils::double::Dummy; + use mithril_common::test::double::Dummy; use crate::database::test_helper::{insert_epoch_settings, main_db_connection}; diff --git a/mithril-aggregator/src/database/repository/immutable_file_digest_repository.rs b/mithril-aggregator/src/database/repository/immutable_file_digest_repository.rs index bd1e9742220..3ca6008ddfd 100644 --- a/mithril-aggregator/src/database/repository/immutable_file_digest_repository.rs +++ b/mithril-aggregator/src/database/repository/immutable_file_digest_repository.rs @@ -139,7 +139,7 @@ mod tests { } mod repository { - use mithril_common::test_utils::assert_equivalent; + use mithril_common::test::assert_equivalent; use super::*; diff --git a/mithril-aggregator/src/database/repository/open_message_repository.rs b/mithril-aggregator/src/database/repository/open_message_repository.rs index 0d6aa6a2ba6..eb51730f466 100644 --- a/mithril-aggregator/src/database/repository/open_message_repository.rs +++ b/mithril-aggregator/src/database/repository/open_message_repository.rs @@ -140,7 +140,7 @@ impl OpenMessageStorer for OpenMessageRepository { #[cfg(test)] mod tests { use mithril_common::entities::{BlockNumber, CardanoDbBeacon}; - use mithril_common::test_utils::double::Dummy; + use mithril_common::test::double::Dummy; use crate::database::record::SingleSignatureRecord; use crate::database::test_helper::{ diff --git a/mithril-aggregator/src/database/repository/signed_entity_store.rs b/mithril-aggregator/src/database/repository/signed_entity_store.rs index ea21b36eb02..72bdd8229df 100644 --- a/mithril-aggregator/src/database/repository/signed_entity_store.rs +++ b/mithril-aggregator/src/database/repository/signed_entity_store.rs @@ -166,7 +166,7 @@ mod tests { use mithril_common::{ entities::{Epoch, MithrilStakeDistribution, Snapshot}, signable_builder::SignedEntity, - test_utils::double::fake_data, + test::double::fake_data, }; use crate::database::test_helper::{insert_signed_entities, main_db_connection}; diff --git a/mithril-aggregator/src/database/repository/signer_registration_store.rs b/mithril-aggregator/src/database/repository/signer_registration_store.rs index 1a9497fd6b9..a74e31ee299 100644 --- a/mithril-aggregator/src/database/repository/signer_registration_store.rs +++ b/mithril-aggregator/src/database/repository/signer_registration_store.rs @@ -142,7 +142,7 @@ mod tests { use crate::database::test_helper::{insert_signer_registrations, main_db_connection}; use mithril_common::entities::{Epoch, PartyId, Signer, SignerWithStake}; - use mithril_common::test_utils::double::fake_keys; + use mithril_common::test::double::fake_keys; use std::collections::HashMap; use std::sync::Arc; diff --git a/mithril-aggregator/src/database/test_helper.rs b/mithril-aggregator/src/database/test_helper.rs index 7c8aebe06a7..68ae6dba06f 100644 --- a/mithril-aggregator/src/database/test_helper.rs +++ b/mithril-aggregator/src/database/test_helper.rs @@ -6,7 +6,7 @@ use uuid::Uuid; use mithril_common::entities::{ BlockNumber, CardanoTransactionsSigningConfig, ProtocolParameters, SignerWithStake, }; -use mithril_common::{StdError, StdResult, entities::Epoch, test_utils::double::fake_keys}; +use mithril_common::{StdError, StdResult, entities::Epoch, test::double::fake_keys}; use mithril_persistence::sqlite::{ ConnectionBuilder, ConnectionExtensions, ConnectionOptions, Query, SqliteConnection, }; diff --git a/mithril-aggregator/src/dependency_injection/containers/serve.rs b/mithril-aggregator/src/dependency_injection/containers/serve.rs index 000902c84ca..913d6b69923 100644 --- a/mithril-aggregator/src/dependency_injection/containers/serve.rs +++ b/mithril-aggregator/src/dependency_injection/containers/serve.rs @@ -10,7 +10,7 @@ use mithril_common::{ StakeDistribution, }, signable_builder::SignableBuilderService, - test_utils::MithrilFixture, + test::MithrilFixture, }; use mithril_era::{EraChecker, EraReader}; diff --git a/mithril-aggregator/src/entities/open_message.rs b/mithril-aggregator/src/entities/open_message.rs index 53c895a7c3b..4f4ae482875 100644 --- a/mithril-aggregator/src/entities/open_message.rs +++ b/mithril-aggregator/src/entities/open_message.rs @@ -85,7 +85,7 @@ mod test { use mithril_common::{ entities::{Epoch, ProtocolMessage, SignedEntityType}, - test_utils::double::{Dummy, fake_data}, + test::double::{Dummy, fake_data}, }; use crate::database::record::{OpenMessageRecord, OpenMessageWithSingleSignaturesRecord}; diff --git a/mithril-aggregator/src/event_store/database/repository.rs b/mithril-aggregator/src/event_store/database/repository.rs index 2575db56876..22346b0f260 100644 --- a/mithril-aggregator/src/event_store/database/repository.rs +++ b/mithril-aggregator/src/event_store/database/repository.rs @@ -437,7 +437,7 @@ mod tests { use crate::event_store::database::test_helper::event_store_db_connection; use mithril_common::entities::{SignerWithStake, Stake}; - use mithril_common::{StdResult, test_utils::double::fake_data}; + use mithril_common::{StdResult, test::double::fake_data}; use sqlite::ConnectionThreadSafe; use super::{EventMessage, EventPersister}; diff --git a/mithril-aggregator/src/file_uploaders/local_uploader.rs b/mithril-aggregator/src/file_uploaders/local_uploader.rs index 54f023d3687..a1be0236daa 100644 --- a/mithril-aggregator/src/file_uploaders/local_uploader.rs +++ b/mithril-aggregator/src/file_uploaders/local_uploader.rs @@ -92,7 +92,7 @@ mod tests { use std::path::{Path, PathBuf}; use std::time::Duration; - use mithril_common::test_utils::TempDir; + use mithril_common::test::TempDir; use crate::test_tools::TestLogger; diff --git a/mithril-aggregator/src/http_server/routes/artifact_routes/cardano_database.rs b/mithril-aggregator/src/http_server/routes/artifact_routes/cardano_database.rs index 60f782a476f..6e1f5301b70 100644 --- a/mithril-aggregator/src/http_server/routes/artifact_routes/cardano_database.rs +++ b/mithril-aggregator/src/http_server/routes/artifact_routes/cardano_database.rs @@ -182,7 +182,7 @@ mod tests { CardanoDatabaseDigestListItemMessage, CardanoDatabaseSnapshotListItemMessage, CardanoDatabaseSnapshotMessage, }; - use mithril_common::test_utils::double::Dummy; + use mithril_common::test::double::Dummy; use mithril_common::{MITHRIL_CLIENT_TYPE_HEADER, MITHRIL_ORIGIN_TAG_HEADER}; use mithril_persistence::sqlite::HydrationError; diff --git a/mithril-aggregator/src/http_server/routes/artifact_routes/cardano_stake_distribution.rs b/mithril-aggregator/src/http_server/routes/artifact_routes/cardano_stake_distribution.rs index f4e2f34d4aa..2867cbb0174 100644 --- a/mithril-aggregator/src/http_server/routes/artifact_routes/cardano_stake_distribution.rs +++ b/mithril-aggregator/src/http_server/routes/artifact_routes/cardano_stake_distribution.rs @@ -170,7 +170,7 @@ pub mod tests { use mithril_common::{ MITHRIL_CLIENT_TYPE_HEADER, MITHRIL_ORIGIN_TAG_HEADER, messages::{CardanoStakeDistributionListItemMessage, CardanoStakeDistributionMessage}, - test_utils::double::Dummy, + test::double::Dummy, }; use crate::{initialize_dependencies, services::MockMessageService}; diff --git a/mithril-aggregator/src/http_server/routes/artifact_routes/cardano_transaction.rs b/mithril-aggregator/src/http_server/routes/artifact_routes/cardano_transaction.rs index a5c254d5679..60dcd0b3568 100644 --- a/mithril-aggregator/src/http_server/routes/artifact_routes/cardano_transaction.rs +++ b/mithril-aggregator/src/http_server/routes/artifact_routes/cardano_transaction.rs @@ -108,7 +108,7 @@ pub mod tests { use mithril_common::{ MITHRIL_CLIENT_TYPE_HEADER, MITHRIL_ORIGIN_TAG_HEADER, messages::{CardanoTransactionSnapshotListItemMessage, CardanoTransactionSnapshotMessage}, - test_utils::double::Dummy, + test::double::Dummy, }; use mithril_persistence::sqlite::HydrationError; diff --git a/mithril-aggregator/src/http_server/routes/artifact_routes/mithril_stake_distribution.rs b/mithril-aggregator/src/http_server/routes/artifact_routes/mithril_stake_distribution.rs index 7dfedbf533b..89b46b0861e 100644 --- a/mithril-aggregator/src/http_server/routes/artifact_routes/mithril_stake_distribution.rs +++ b/mithril-aggregator/src/http_server/routes/artifact_routes/mithril_stake_distribution.rs @@ -108,7 +108,7 @@ pub mod tests { use mithril_common::{ MITHRIL_CLIENT_TYPE_HEADER, MITHRIL_ORIGIN_TAG_HEADER, messages::{MithrilStakeDistributionListItemMessage, MithrilStakeDistributionMessage}, - test_utils::double::Dummy, + test::double::Dummy, }; use mithril_persistence::sqlite::HydrationError; diff --git a/mithril-aggregator/src/http_server/routes/artifact_routes/snapshot.rs b/mithril-aggregator/src/http_server/routes/artifact_routes/snapshot.rs index c2e753851b5..5b90e4d23db 100644 --- a/mithril-aggregator/src/http_server/routes/artifact_routes/snapshot.rs +++ b/mithril-aggregator/src/http_server/routes/artifact_routes/snapshot.rs @@ -215,7 +215,7 @@ mod tests { MITHRIL_CLIENT_TYPE_HEADER, MITHRIL_ORIGIN_TAG_HEADER, entities::{CardanoDbBeacon, SignedEntityType, Snapshot}, messages::{SnapshotListItemMessage, SnapshotMessage}, - test_utils::double::{Dummy, fake_data}, + test::double::{Dummy, fake_data}, }; use mithril_persistence::sqlite::HydrationError; diff --git a/mithril-aggregator/src/http_server/routes/certificate_routes.rs b/mithril-aggregator/src/http_server/routes/certificate_routes.rs index fddab0ddcb3..a8678174f06 100644 --- a/mithril-aggregator/src/http_server/routes/certificate_routes.rs +++ b/mithril-aggregator/src/http_server/routes/certificate_routes.rs @@ -140,7 +140,7 @@ mod tests { use mithril_api_spec::APISpec; use mithril_common::{ MITHRIL_CLIENT_TYPE_HEADER, MITHRIL_ORIGIN_TAG_HEADER, messages::CertificateMessage, - test_utils::double::fake_data, + test::double::fake_data, }; use crate::{initialize_dependencies, services::MockMessageService}; diff --git a/mithril-aggregator/src/http_server/routes/epoch_routes.rs b/mithril-aggregator/src/http_server/routes/epoch_routes.rs index 2cb525a90e7..52f6cca873e 100644 --- a/mithril-aggregator/src/http_server/routes/epoch_routes.rs +++ b/mithril-aggregator/src/http_server/routes/epoch_routes.rs @@ -67,7 +67,7 @@ mod tests { use mithril_api_spec::APISpec; use mithril_common::messages::EpochSettingsMessage; - use mithril_common::test_utils::double::Dummy; + use mithril_common::test::double::Dummy; use crate::{initialize_dependencies, services::MockMessageService}; diff --git a/mithril-aggregator/src/http_server/routes/middlewares.rs b/mithril-aggregator/src/http_server/routes/middlewares.rs index 5dde0112d0e..85c3aa0eae9 100644 --- a/mithril-aggregator/src/http_server/routes/middlewares.rs +++ b/mithril-aggregator/src/http_server/routes/middlewares.rs @@ -218,7 +218,7 @@ mod tests { test::request, }; - use mithril_common::test_utils::double::Dummy; + use mithril_common::test::double::Dummy; use crate::http_server::routes::reply; use crate::initialize_dependencies; diff --git a/mithril-aggregator/src/http_server/routes/proof_routes.rs b/mithril-aggregator/src/http_server/routes/proof_routes.rs index b340b65d98e..5bb97cedb1e 100644 --- a/mithril-aggregator/src/http_server/routes/proof_routes.rs +++ b/mithril-aggregator/src/http_server/routes/proof_routes.rs @@ -164,7 +164,7 @@ mod tests { MITHRIL_CLIENT_TYPE_HEADER, MITHRIL_ORIGIN_TAG_HEADER, entities::{BlockNumber, CardanoTransactionsSetProof, CardanoTransactionsSnapshot}, signable_builder::SignedEntity, - test_utils::{ + test::{ assert_equivalent, double::{Dummy, fake_data}, }, diff --git a/mithril-aggregator/src/http_server/routes/root_routes.rs b/mithril-aggregator/src/http_server/routes/root_routes.rs index 3dbf68f5da8..c5ca9954c28 100644 --- a/mithril-aggregator/src/http_server/routes/root_routes.rs +++ b/mithril-aggregator/src/http_server/routes/root_routes.rs @@ -91,7 +91,7 @@ mod tests { use mithril_common::messages::{ AggregatorCapabilities, AggregatorFeaturesMessage, CardanoTransactionsProverCapabilities, }; - use mithril_common::test_utils::double::Dummy; + use mithril_common::test::double::Dummy; use crate::http_server::routes::router::RouterConfig; use crate::initialize_dependencies; diff --git a/mithril-aggregator/src/http_server/routes/router.rs b/mithril-aggregator/src/http_server/routes/router.rs index 1eb45116364..e19d92585bc 100644 --- a/mithril-aggregator/src/http_server/routes/router.rs +++ b/mithril-aggregator/src/http_server/routes/router.rs @@ -9,7 +9,7 @@ use crate::tools::url_sanitizer::SanitizedUrlWithTrailingSlash; use mithril_common::api_version::APIVersionProvider; use mithril_common::entities::SignedEntityTypeDiscriminants; #[cfg(test)] -use mithril_common::test_utils::double::Dummy; +use mithril_common::test::double::Dummy; use mithril_common::{ CardanoNetwork, MITHRIL_API_VERSION_HEADER, MITHRIL_CLIENT_TYPE_HEADER, MITHRIL_ORIGIN_TAG_HEADER, diff --git a/mithril-aggregator/src/http_server/routes/signatures_routes.rs b/mithril-aggregator/src/http_server/routes/signatures_routes.rs index d4153aab547..87b9e31dfe4 100644 --- a/mithril-aggregator/src/http_server/routes/signatures_routes.rs +++ b/mithril-aggregator/src/http_server/routes/signatures_routes.rs @@ -127,8 +127,7 @@ mod tests { use mithril_api_spec::APISpec; use mithril_common::{ - entities::SignedEntityType, messages::RegisterSignatureMessageHttp, - test_utils::double::Dummy, + entities::SignedEntityType, messages::RegisterSignatureMessageHttp, test::double::Dummy, }; use crate::{ diff --git a/mithril-aggregator/src/http_server/routes/signer_routes.rs b/mithril-aggregator/src/http_server/routes/signer_routes.rs index 51ec6864e3b..f45e8166ebe 100644 --- a/mithril-aggregator/src/http_server/routes/signer_routes.rs +++ b/mithril-aggregator/src/http_server/routes/signer_routes.rs @@ -271,7 +271,7 @@ mod tests { crypto_helper::ProtocolRegistrationError, entities::Epoch, messages::RegisterSignerMessage, - test_utils::{ + test::{ MithrilFixtureBuilder, double::{Dummy, fake_data}, }, diff --git a/mithril-aggregator/src/http_server/routes/statistics_routes.rs b/mithril-aggregator/src/http_server/routes/statistics_routes.rs index 7a3d7ed3b2c..1d79e5574bf 100644 --- a/mithril-aggregator/src/http_server/routes/statistics_routes.rs +++ b/mithril-aggregator/src/http_server/routes/statistics_routes.rs @@ -233,7 +233,7 @@ mod tests { CardanoDatabaseImmutableFilesRestoredMessage, SnapshotDownloadMessage, }; use mithril_common::{ - MITHRIL_CLIENT_TYPE_HEADER, MITHRIL_ORIGIN_TAG_HEADER, temp_dir, test_utils::double::Dummy, + MITHRIL_CLIENT_TYPE_HEADER, MITHRIL_ORIGIN_TAG_HEADER, temp_dir, test::double::Dummy, }; use crate::ServeCommandDependenciesContainer; diff --git a/mithril-aggregator/src/http_server/routes/status.rs b/mithril-aggregator/src/http_server/routes/status.rs index 66563356c23..30b9c47094d 100644 --- a/mithril-aggregator/src/http_server/routes/status.rs +++ b/mithril-aggregator/src/http_server/routes/status.rs @@ -115,7 +115,7 @@ mod tests { use mithril_api_spec::APISpec; use mithril_common::{ entities::{Epoch, ProtocolParameters, Stake}, - test_utils::{ + test::{ MithrilFixtureBuilder, double::{Dummy, fake_data}, }, diff --git a/mithril-aggregator/src/lib.rs b/mithril-aggregator/src/lib.rs index e1d0fe37b65..f45df0e37da 100644 --- a/mithril-aggregator/src/lib.rs +++ b/mithril-aggregator/src/lib.rs @@ -79,7 +79,7 @@ pub(crate) mod test_tools { use slog_async::Async; use slog_term::{CompactFormat, PlainDecorator}; - use mithril_common::test_utils::{MemoryDrainForTest, MemoryDrainForTestInspector}; + use mithril_common::test::{MemoryDrainForTest, MemoryDrainForTestInspector}; pub struct TestLogger; diff --git a/mithril-aggregator/src/message_adapters/from_epoch_settings.rs b/mithril-aggregator/src/message_adapters/from_epoch_settings.rs index f3fb7d2410b..685a45fe691 100644 --- a/mithril-aggregator/src/message_adapters/from_epoch_settings.rs +++ b/mithril-aggregator/src/message_adapters/from_epoch_settings.rs @@ -32,7 +32,7 @@ impl TryFromMessageAdapter #[cfg(test)] mod tests { - use mithril_common::test_utils::double::Dummy; + use mithril_common::test::double::Dummy; use super::*; diff --git a/mithril-aggregator/src/message_adapters/from_register_signature.rs b/mithril-aggregator/src/message_adapters/from_register_signature.rs index 6b232f4747b..7b948484ac5 100644 --- a/mithril-aggregator/src/message_adapters/from_register_signature.rs +++ b/mithril-aggregator/src/message_adapters/from_register_signature.rs @@ -28,7 +28,7 @@ impl TryFromMessageAdapter #[cfg(test)] mod tests { - use mithril_common::test_utils::double::Dummy; + use mithril_common::test::double::Dummy; use super::*; diff --git a/mithril-aggregator/src/message_adapters/from_register_signer.rs b/mithril-aggregator/src/message_adapters/from_register_signer.rs index 5694d8dc868..47bb2d5995c 100644 --- a/mithril-aggregator/src/message_adapters/from_register_signer.rs +++ b/mithril-aggregator/src/message_adapters/from_register_signer.rs @@ -39,7 +39,7 @@ impl TryFromMessageAdapter for FromRegisterSigner #[cfg(test)] mod tests { - use mithril_common::test_utils::double::Dummy; + use mithril_common::test::double::Dummy; use super::*; diff --git a/mithril-aggregator/src/message_adapters/to_cardano_transactions_proof_message.rs b/mithril-aggregator/src/message_adapters/to_cardano_transactions_proof_message.rs index 518debb414a..b9da5212d01 100644 --- a/mithril-aggregator/src/message_adapters/to_cardano_transactions_proof_message.rs +++ b/mithril-aggregator/src/message_adapters/to_cardano_transactions_proof_message.rs @@ -60,7 +60,7 @@ fn try_adapt_set_proof_message( #[cfg(test)] mod tests { use mithril_common::crypto_helper::MKProof; - use mithril_common::test_utils::double::Dummy; + use mithril_common::test::double::Dummy; use super::*; diff --git a/mithril-aggregator/src/multi_signer.rs b/mithril-aggregator/src/multi_signer.rs index f06669054e1..499851facef 100644 --- a/mithril-aggregator/src/multi_signer.rs +++ b/mithril-aggregator/src/multi_signer.rs @@ -146,7 +146,7 @@ mod tests { use mithril_common::crypto_helper::tests_setup::*; use mithril_common::entities::{CardanoDbBeacon, Epoch, SignedEntityType, SignerWithStake}; use mithril_common::protocol::ToMessage; - use mithril_common::test_utils::{ + use mithril_common::test::{ MithrilFixtureBuilder, double::{Dummy, fake_data}, }; diff --git a/mithril-aggregator/src/runtime/runner.rs b/mithril-aggregator/src/runtime/runner.rs index 86237b66a67..b2426b7dfd1 100644 --- a/mithril-aggregator/src/runtime/runner.rs +++ b/mithril-aggregator/src/runtime/runner.rs @@ -549,7 +549,7 @@ pub mod tests { }, signable_builder::SignableBuilderService, temp_dir, - test_utils::{ + test::{ MithrilFixtureBuilder, double::{Dummy, fake_data}, }, diff --git a/mithril-aggregator/src/runtime/state_machine.rs b/mithril-aggregator/src/runtime/state_machine.rs index 27e72a52b2d..420cb120b4e 100644 --- a/mithril-aggregator/src/runtime/state_machine.rs +++ b/mithril-aggregator/src/runtime/state_machine.rs @@ -387,7 +387,7 @@ mod tests { use mockall::predicate; use std::time::Duration; - use mithril_common::test_utils::double::{Dummy, fake_data}; + use mithril_common::test::double::{Dummy, fake_data}; use crate::entities::OpenMessage; use crate::test_tools::TestLogger; diff --git a/mithril-aggregator/src/services/aggregator_client.rs b/mithril-aggregator/src/services/aggregator_client.rs index 302163bdf84..0fe0f8b7251 100644 --- a/mithril-aggregator/src/services/aggregator_client.rs +++ b/mithril-aggregator/src/services/aggregator_client.rs @@ -383,7 +383,7 @@ impl RemoteCertificateRetriever for AggregatorHTTPClient { pub(crate) mod dumb { use tokio::sync::RwLock; - use mithril_common::test_utils::double::Dummy; + use mithril_common::test::double::Dummy; use super::*; @@ -423,7 +423,7 @@ mod tests { use mithril_common::api_version::DummyApiVersionDiscriminantSource; use mithril_common::messages::CertificateListItemMessage; - use mithril_common::test_utils::double::Dummy; + use mithril_common::test::double::Dummy; use crate::test_tools::TestLogger; @@ -813,7 +813,7 @@ mod tests { mod warn_if_api_version_mismatch { use std::collections::HashMap; - use mithril_common::test_utils::MemoryDrainForTestInspector; + use mithril_common::test::MemoryDrainForTestInspector; use super::*; @@ -1006,7 +1006,7 @@ mod tests { } mod remote_certificate_retriever { - use mithril_common::test_utils::double::fake_data; + use mithril_common::test::double::fake_data; use super::*; diff --git a/mithril-aggregator/src/services/certificate_chain_synchronizer/synchronizer_service.rs b/mithril-aggregator/src/services/certificate_chain_synchronizer/synchronizer_service.rs index 62949a3eb27..2a5ea803af1 100644 --- a/mithril-aggregator/src/services/certificate_chain_synchronizer/synchronizer_service.rs +++ b/mithril-aggregator/src/services/certificate_chain_synchronizer/synchronizer_service.rs @@ -227,7 +227,7 @@ mod tests { use mithril_common::certificate_chain::{ FakeCertificaterRetriever, MithrilCertificateVerifier, }; - use mithril_common::test_utils::{ + use mithril_common::test::{ CertificateChainBuilder, CertificateChainFixture, double::{fake_data, fake_keys}, mock_extensions::MockBuilder, diff --git a/mithril-aggregator/src/services/certifier/buffered_certifier.rs b/mithril-aggregator/src/services/certifier/buffered_certifier.rs index d5134e8a700..7ff36038bc5 100644 --- a/mithril-aggregator/src/services/certifier/buffered_certifier.rs +++ b/mithril-aggregator/src/services/certifier/buffered_certifier.rs @@ -191,7 +191,7 @@ mod tests { CardanoTransactions, MithrilStakeDistribution, }; use mithril_common::entities::SingleSignatureAuthenticationStatus; - use mithril_common::test_utils::double::{Dummy, fake_data}; + use mithril_common::test::double::{Dummy, fake_data}; use crate::database::repository::BufferedSingleSignatureRepository; use crate::database::test_helper::main_db_connection; diff --git a/mithril-aggregator/src/services/certifier/certifier_service.rs b/mithril-aggregator/src/services/certifier/certifier_service.rs index 4aef9316f62..79a37cf579c 100644 --- a/mithril-aggregator/src/services/certifier/certifier_service.rs +++ b/mithril-aggregator/src/services/certifier/certifier_service.rs @@ -419,7 +419,7 @@ mod tests { use mithril_common::{ entities::{CardanoDbBeacon, ProtocolMessagePartKey}, temp_dir, - test_utils::{MithrilFixture, MithrilFixtureBuilder, double::fake_data}, + test::{MithrilFixture, MithrilFixtureBuilder, double::fake_data}, }; use tokio::sync::RwLock; diff --git a/mithril-aggregator/src/services/epoch_service.rs b/mithril-aggregator/src/services/epoch_service.rs index da9d49fc1cc..3b2e30b674b 100644 --- a/mithril-aggregator/src/services/epoch_service.rs +++ b/mithril-aggregator/src/services/epoch_service.rs @@ -560,7 +560,7 @@ pub(crate) struct FakeEpochServiceBuilder { #[cfg(test)] impl FakeEpochServiceBuilder { pub fn dummy(epoch: Epoch) -> Self { - use mithril_common::test_utils::double::{Dummy, fake_data}; + use mithril_common::test::double::{Dummy, fake_data}; let signers = fake_data::signers_with_stakes(3); Self { @@ -635,12 +635,9 @@ impl FakeEpochServiceBuilder { #[cfg(test)] impl FakeEpochService { - pub fn from_fixture( - epoch: Epoch, - fixture: &mithril_common::test_utils::MithrilFixture, - ) -> Self { + pub fn from_fixture(epoch: Epoch, fixture: &mithril_common::test::MithrilFixture) -> Self { use mithril_common::entities::CardanoTransactionsSigningConfig; - use mithril_common::test_utils::double::Dummy; + use mithril_common::test::double::Dummy; let current_epoch_settings = AggregatorEpochSettings { protocol_parameters: fixture.protocol_parameters(), @@ -836,15 +833,16 @@ impl EpochService for FakeEpochService { #[cfg(test)] mod tests { + use mockall::predicate::eq; + use mithril_cardano_node_chain::test::double::FakeChainObserver; use mithril_common::entities::{ BlockNumber, CardanoTransactionsSigningConfig, Stake, StakeDistribution, SupportedEra, }; - use mithril_common::test_utils::{ + use mithril_common::test::{ MithrilFixture, MithrilFixtureBuilder, StakeDistributionGenerationMethod, double::{Dummy, fake_data}, }; - use mockall::predicate::eq; use crate::store::{FakeEpochSettingsStorer, MockVerificationKeyStorer}; use crate::test::mocks::MockStakeStore; diff --git a/mithril-aggregator/src/services/message.rs b/mithril-aggregator/src/services/message.rs index be66312e184..e5ddeac1ea5 100644 --- a/mithril-aggregator/src/services/message.rs +++ b/mithril-aggregator/src/services/message.rs @@ -342,7 +342,7 @@ impl MessageService for MithrilMessageService { #[cfg(test)] mod tests { use mithril_common::entities::{BlockNumber, Certificate, SignedEntityType}; - use mithril_common::test_utils::double::{Dummy, fake_data}; + use mithril_common::test::double::{Dummy, fake_data}; use tokio::sync::RwLock; use crate::database::record::SignedEntityRecord; @@ -437,7 +437,7 @@ mod tests { mod epoch_settings { use mithril_common::{ entities::{CardanoTransactionsSigningConfig, ProtocolParameters}, - test_utils::MithrilFixtureBuilder, + test::MithrilFixtureBuilder, }; use crate::{entities::AggregatorEpochSettings, services::FakeEpochServiceBuilder}; diff --git a/mithril-aggregator/src/services/prover.rs b/mithril-aggregator/src/services/prover.rs index ebe20d9385b..7c8615a9bce 100644 --- a/mithril-aggregator/src/services/prover.rs +++ b/mithril-aggregator/src/services/prover.rs @@ -213,7 +213,7 @@ mod tests { MKMap, MKMapNode, MKTreeNode, MKTreeStoreInMemory, MKTreeStorer, }; use mithril_common::entities::CardanoTransaction; - use mithril_common::test_utils::CardanoTransactionsBuilder; + use mithril_common::test::CardanoTransactionsBuilder; use mockall::mock; use mockall::predicate::eq; diff --git a/mithril-aggregator/src/services/signable_builder/signable_seed_builder.rs b/mithril-aggregator/src/services/signable_builder/signable_seed_builder.rs index 92f332ce6bd..2f474796058 100644 --- a/mithril-aggregator/src/services/signable_builder/signable_seed_builder.rs +++ b/mithril-aggregator/src/services/signable_builder/signable_seed_builder.rs @@ -58,7 +58,7 @@ impl SignableSeedBuilder for AggregatorSignableSeedBuilder { mod tests { use mithril_common::{ entities::Epoch, - test_utils::{MithrilFixture, MithrilFixtureBuilder, double::Dummy}, + test::{MithrilFixture, MithrilFixtureBuilder, double::Dummy}, }; use crate::{entities::AggregatorEpochSettings, services::FakeEpochServiceBuilder}; diff --git a/mithril-aggregator/src/services/signature_consumer/dmq.rs b/mithril-aggregator/src/services/signature_consumer/dmq.rs index 8704b964683..1bdf0b771cf 100644 --- a/mithril-aggregator/src/services/signature_consumer/dmq.rs +++ b/mithril-aggregator/src/services/signature_consumer/dmq.rs @@ -57,7 +57,7 @@ impl SignatureConsumer for SignatureConsumerDmq { mod tests { use mithril_common::{ crypto_helper::ProtocolSingleSignature, - test_utils::double::{Dummy, fake_keys}, + test::double::{Dummy, fake_keys}, }; use mithril_dmq::test::double::DmqConsumerFake; diff --git a/mithril-aggregator/src/services/signature_consumer/fake.rs b/mithril-aggregator/src/services/signature_consumer/fake.rs index b6464d27b02..9381195cd97 100644 --- a/mithril-aggregator/src/services/signature_consumer/fake.rs +++ b/mithril-aggregator/src/services/signature_consumer/fake.rs @@ -46,7 +46,7 @@ impl SignatureConsumer for FakeSignatureConsumer { mod tests { use super::*; - use mithril_common::{entities::Epoch, test_utils::double::fake_data}; + use mithril_common::{entities::Epoch, test::double::fake_data}; #[tokio::test] async fn fake_signature_consumer_returns_signature_batches_in_expected_order() { diff --git a/mithril-aggregator/src/services/signature_processor.rs b/mithril-aggregator/src/services/signature_processor.rs index 155cba3e8fd..d05ca95fbbb 100644 --- a/mithril-aggregator/src/services/signature_processor.rs +++ b/mithril-aggregator/src/services/signature_processor.rs @@ -99,7 +99,7 @@ mod tests { use anyhow::anyhow; use mithril_common::{ entities::{Epoch, SignedEntityType}, - test_utils::double::fake_data, + test::double::fake_data, }; use mockall::predicate::eq; use tokio::{ diff --git a/mithril-aggregator/src/services/signed_entity.rs b/mithril-aggregator/src/services/signed_entity.rs index 51490774a64..c2a7aa1fd2d 100644 --- a/mithril-aggregator/src/services/signed_entity.rs +++ b/mithril-aggregator/src/services/signed_entity.rs @@ -504,7 +504,7 @@ mod tests { use mithril_common::{ entities::{CardanoTransactionsSnapshot, Epoch, StakeDistribution}, signable_builder, - test_utils::double::fake_data, + test::double::fake_data, }; use mithril_metric::CounterValue; use serde::{Serialize, de::DeserializeOwned}; diff --git a/mithril-aggregator/src/services/signer_registration/follower.rs b/mithril-aggregator/src/services/signer_registration/follower.rs index 6b5d2b2816d..2a5e8109781 100644 --- a/mithril-aggregator/src/services/signer_registration/follower.rs +++ b/mithril-aggregator/src/services/signer_registration/follower.rs @@ -180,7 +180,7 @@ mod tests { use mithril_common::messages::{ EpochSettingsMessage, SignerMessagePart, TryFromMessageAdapter, }; - use mithril_common::test_utils::{MithrilFixtureBuilder, double::Dummy}; + use mithril_common::test::{MithrilFixtureBuilder, double::Dummy}; use crate::{ database::{repository::SignerRegistrationStore, test_helper::main_db_connection}, diff --git a/mithril-aggregator/src/services/signer_registration/leader.rs b/mithril-aggregator/src/services/signer_registration/leader.rs index c5978332610..b3609d6d7d3 100644 --- a/mithril-aggregator/src/services/signer_registration/leader.rs +++ b/mithril-aggregator/src/services/signer_registration/leader.rs @@ -150,7 +150,7 @@ mod tests { use mithril_common::{ entities::{Epoch, Signer, SignerWithStake}, - test_utils::MithrilFixtureBuilder, + test::MithrilFixtureBuilder, }; use crate::{ diff --git a/mithril-aggregator/src/services/signer_registration/verifier.rs b/mithril-aggregator/src/services/signer_registration/verifier.rs index e2d8cffc042..2f08b7e14f2 100644 --- a/mithril-aggregator/src/services/signer_registration/verifier.rs +++ b/mithril-aggregator/src/services/signer_registration/verifier.rs @@ -82,7 +82,7 @@ mod tests { use mithril_cardano_node_chain::test::double::FakeChainObserver; use mithril_common::{ entities::TimePoint, - test_utils::{MithrilFixtureBuilder, double::Dummy}, + test::{MithrilFixtureBuilder, double::Dummy}, }; use super::*; diff --git a/mithril-aggregator/src/services/snapshotter/compressed_archive_snapshotter.rs b/mithril-aggregator/src/services/snapshotter/compressed_archive_snapshotter.rs index 6e33446782e..bf970e48291 100644 --- a/mithril-aggregator/src/services/snapshotter/compressed_archive_snapshotter.rs +++ b/mithril-aggregator/src/services/snapshotter/compressed_archive_snapshotter.rs @@ -325,7 +325,7 @@ mod tests { use std::sync::Arc; use mithril_cardano_node_internal_database::test::DummyCardanoDbBuilder; - use mithril_common::test_utils::assert_equivalent; + use mithril_common::test::assert_equivalent; use mithril_common::{assert_dir_eq, current_function, temp_dir_create}; use crate::services::ancillary_signer::MockAncillarySigner; @@ -523,7 +523,7 @@ mod tests { } mod snapshot_ancillary { - use mithril_common::test_utils::double::fake_keys; + use mithril_common::test::double::fake_keys; use super::*; diff --git a/mithril-aggregator/src/store/epoch_settings_storer.rs b/mithril-aggregator/src/store/epoch_settings_storer.rs index f322c86ca42..54f645956b8 100644 --- a/mithril-aggregator/src/store/epoch_settings_storer.rs +++ b/mithril-aggregator/src/store/epoch_settings_storer.rs @@ -111,7 +111,7 @@ impl EpochPruningTask for FakeEpochSettingsStorer { #[cfg(test)] mod tests { use mithril_common::entities::CardanoTransactionsSigningConfig; - use mithril_common::test_utils::double::Dummy; + use mithril_common::test::double::Dummy; use super::*; diff --git a/mithril-aggregator/src/test/double/dummies.rs b/mithril-aggregator/src/test/double/dummies.rs index 2dd218e70d0..f56092afbac 100644 --- a/mithril-aggregator/src/test/double/dummies.rs +++ b/mithril-aggregator/src/test/double/dummies.rs @@ -1,7 +1,7 @@ use chrono::Utc; use uuid::Uuid; -use mithril_common::test_utils::double::{Dummy, fake_data}; +use mithril_common::test::double::{Dummy, fake_data}; mod record { use mithril_common::entities::{ProtocolMessage, SignedEntityType}; diff --git a/mithril-aggregator/src/tools/certificates_hash_migrator.rs b/mithril-aggregator/src/tools/certificates_hash_migrator.rs index da4fa368e85..4cb2d8d682d 100644 --- a/mithril-aggregator/src/tools/certificates_hash_migrator.rs +++ b/mithril-aggregator/src/tools/certificates_hash_migrator.rs @@ -216,7 +216,7 @@ mod test { Epoch, ImmutableFileNumber, SignedEntityConfig, SignedEntityType, SignedEntityTypeDiscriminants as Type, TimePoint, }; - use mithril_common::test_utils::double::Dummy; + use mithril_common::test::double::Dummy; use mithril_persistence::sqlite::{ConnectionBuilder, ConnectionOptions, SqliteConnection}; use crate::database::record::{CertificateRecord, SignedEntityRecord}; diff --git a/mithril-aggregator/src/tools/era.rs b/mithril-aggregator/src/tools/era.rs index 92730ee0dd6..98947fac662 100644 --- a/mithril-aggregator/src/tools/era.rs +++ b/mithril-aggregator/src/tools/era.rs @@ -78,7 +78,7 @@ impl EraTools { mod tests { use mithril_common::{ crypto_helper::{EraMarkersVerifierSecretKey, EraMarkersVerifierVerificationKey}, - test_utils::TempDir, + test::TempDir, }; use std::fs::read_to_string; diff --git a/mithril-aggregator/src/tools/file_archiver/api.rs b/mithril-aggregator/src/tools/file_archiver/api.rs index ca9ad5f9ddb..469c6c63a6e 100644 --- a/mithril-aggregator/src/tools/file_archiver/api.rs +++ b/mithril-aggregator/src/tools/file_archiver/api.rs @@ -292,7 +292,7 @@ impl FileArchiver { mod tests { use std::fs::File; - use mithril_common::test_utils::assert_equivalent; + use mithril_common::test::assert_equivalent; use crate::tools::file_archiver::appender::{AppenderDirAll, AppenderFile}; use crate::tools::file_archiver::test_tools::*; diff --git a/mithril-aggregator/src/tools/file_archiver/entities.rs b/mithril-aggregator/src/tools/file_archiver/entities.rs index 35a03f9bc06..91dfbcb1cec 100644 --- a/mithril-aggregator/src/tools/file_archiver/entities.rs +++ b/mithril-aggregator/src/tools/file_archiver/entities.rs @@ -95,7 +95,7 @@ impl FileArchive { } #[cfg(test)] -impl mithril_common::test_utils::double::Dummy for FileArchive { +impl mithril_common::test::double::Dummy for FileArchive { fn dummy() -> Self { Self { filepath: PathBuf::from("archive.tar.gz"), diff --git a/mithril-aggregator/src/tools/file_archiver/mod.rs b/mithril-aggregator/src/tools/file_archiver/mod.rs index f365d850649..024f937f9a0 100644 --- a/mithril-aggregator/src/tools/file_archiver/mod.rs +++ b/mithril-aggregator/src/tools/file_archiver/mod.rs @@ -10,7 +10,7 @@ pub(crate) mod test_tools { use std::fs::File; use std::path::{Path, PathBuf}; - use mithril_common::test_utils::TempDir; + use mithril_common::test::TempDir; pub fn get_test_directory(dir_name: &str) -> PathBuf { TempDir::create("file_archiver", dir_name) diff --git a/mithril-aggregator/src/tools/file_size.rs b/mithril-aggregator/src/tools/file_size.rs index 8bb08363f6a..d53be02d65b 100644 --- a/mithril-aggregator/src/tools/file_size.rs +++ b/mithril-aggregator/src/tools/file_size.rs @@ -73,7 +73,7 @@ mod tests { use std::io::Write; use mithril_common::current_function; - use mithril_common::test_utils::TempDir; + use mithril_common::test::TempDir; use super::*; diff --git a/mithril-aggregator/src/tools/genesis.rs b/mithril-aggregator/src/tools/genesis.rs index 09d78c5ff69..c8ec03c93c8 100644 --- a/mithril-aggregator/src/tools/genesis.rs +++ b/mithril-aggregator/src/tools/genesis.rs @@ -206,7 +206,7 @@ mod tests { ProtocolGenesisSecretKey, ProtocolGenesisSigner, ProtocolGenesisVerificationKey, ProtocolGenesisVerifier, }, - test_utils::{MithrilFixtureBuilder, TempDir, double::fake_data}, + test::{MithrilFixtureBuilder, TempDir, double::fake_data}, }; use std::{fs::read_to_string, path::PathBuf}; diff --git a/mithril-aggregator/tests/cardano_stake_distribution_verify_stakes.rs b/mithril-aggregator/tests/cardano_stake_distribution_verify_stakes.rs index 07421c11fef..002bb085125 100644 --- a/mithril-aggregator/tests/cardano_stake_distribution_verify_stakes.rs +++ b/mithril-aggregator/tests/cardano_stake_distribution_verify_stakes.rs @@ -9,7 +9,7 @@ use mithril_common::{ SignedEntityTypeDiscriminants, SlotNumber, StakeDistribution, StakeDistributionParty, TimePoint, }, - test_utils::MithrilFixtureBuilder, + test::MithrilFixtureBuilder, }; use test_extensions::ExpectedMetrics; use test_extensions::{ExpectedCertificate, RuntimeTester, utilities::get_test_dir}; diff --git a/mithril-aggregator/tests/certificate_chain.rs b/mithril-aggregator/tests/certificate_chain.rs index c2632ead7e6..82a4d9afda5 100644 --- a/mithril-aggregator/tests/certificate_chain.rs +++ b/mithril-aggregator/tests/certificate_chain.rs @@ -8,7 +8,7 @@ use mithril_common::{ TimePoint, }, temp_dir, - test_utils::MithrilFixtureBuilder, + test::MithrilFixtureBuilder, }; use test_extensions::{ ExpectedCertificate, ExpectedMetrics, RuntimeTester, utilities::get_test_dir, diff --git a/mithril-aggregator/tests/create_certificate.rs b/mithril-aggregator/tests/create_certificate.rs index b68a6c5cdf8..e9abe023d4e 100644 --- a/mithril-aggregator/tests/create_certificate.rs +++ b/mithril-aggregator/tests/create_certificate.rs @@ -8,7 +8,7 @@ use mithril_common::{ StakeDistributionParty, TimePoint, }, temp_dir, - test_utils::MithrilFixtureBuilder, + test::MithrilFixtureBuilder, }; use test_extensions::{ ExpectedCertificate, ExpectedMetrics, RuntimeTester, utilities::get_test_dir, diff --git a/mithril-aggregator/tests/create_certificate_follower.rs b/mithril-aggregator/tests/create_certificate_follower.rs index 3ded9df4bed..16a4fb6dbd0 100644 --- a/mithril-aggregator/tests/create_certificate_follower.rs +++ b/mithril-aggregator/tests/create_certificate_follower.rs @@ -9,9 +9,7 @@ use mithril_common::{ SignedEntityTypeDiscriminants, SlotNumber, StakeDistributionParty, TimePoint, }, temp_dir, - test_utils::{ - MithrilFixture, MithrilFixtureBuilder, StakeDistributionGenerationMethod, TempDir, - }, + test::{MithrilFixture, MithrilFixtureBuilder, StakeDistributionGenerationMethod, TempDir}, }; use test_extensions::{ExpectedCertificate, RuntimeTester, utilities::get_test_dir}; diff --git a/mithril-aggregator/tests/create_certificate_with_buffered_signatures.rs b/mithril-aggregator/tests/create_certificate_with_buffered_signatures.rs index 82163ef3adf..dcfab8aa15c 100644 --- a/mithril-aggregator/tests/create_certificate_with_buffered_signatures.rs +++ b/mithril-aggregator/tests/create_certificate_with_buffered_signatures.rs @@ -8,7 +8,7 @@ use mithril_common::{ TimePoint, }, temp_dir, - test_utils::MithrilFixtureBuilder, + test::MithrilFixtureBuilder, }; use test_extensions::{ ExpectedCertificate, ExpectedMetrics, RuntimeTester, utilities::get_test_dir, diff --git a/mithril-aggregator/tests/era_checker.rs b/mithril-aggregator/tests/era_checker.rs index 091e6ee7e36..72fb79e4582 100644 --- a/mithril-aggregator/tests/era_checker.rs +++ b/mithril-aggregator/tests/era_checker.rs @@ -5,7 +5,7 @@ use mithril_common::{ BlockNumber, ChainPoint, Epoch, ProtocolParameters, SlotNumber, SupportedEra, TimePoint, }, temp_dir, - test_utils::{MithrilFixtureBuilder, double::Dummy}, + test::{MithrilFixtureBuilder, double::Dummy}, }; use mithril_era::EraMarker; diff --git a/mithril-aggregator/tests/genesis_to_signing.rs b/mithril-aggregator/tests/genesis_to_signing.rs index 8c8e6677483..dd6a01c8f87 100644 --- a/mithril-aggregator/tests/genesis_to_signing.rs +++ b/mithril-aggregator/tests/genesis_to_signing.rs @@ -4,7 +4,7 @@ use mithril_aggregator::ServeCommandConfiguration; use mithril_common::{ entities::{BlockNumber, ChainPoint, Epoch, ProtocolParameters, SlotNumber, TimePoint}, temp_dir, - test_utils::MithrilFixtureBuilder, + test::MithrilFixtureBuilder, }; use test_extensions::{ExpectedCertificate, RuntimeTester, utilities::get_test_dir}; diff --git a/mithril-aggregator/tests/open_message_expiration.rs b/mithril-aggregator/tests/open_message_expiration.rs index ecbdd059ac3..ad7a88ae29d 100644 --- a/mithril-aggregator/tests/open_message_expiration.rs +++ b/mithril-aggregator/tests/open_message_expiration.rs @@ -9,7 +9,7 @@ use mithril_common::{ SignedEntityTypeDiscriminants, SlotNumber, TimePoint, }, temp_dir, - test_utils::MithrilFixtureBuilder, + test::MithrilFixtureBuilder, }; use test_extensions::{ ExpectedCertificate, ExpectedMetrics, RuntimeTester, utilities::get_test_dir, diff --git a/mithril-aggregator/tests/open_message_newer_exists.rs b/mithril-aggregator/tests/open_message_newer_exists.rs index a215a3ab967..7d487a1f914 100644 --- a/mithril-aggregator/tests/open_message_newer_exists.rs +++ b/mithril-aggregator/tests/open_message_newer_exists.rs @@ -7,7 +7,7 @@ use mithril_common::{ SignedEntityTypeDiscriminants, SlotNumber, StakeDistributionParty, TimePoint, }, temp_dir, - test_utils::MithrilFixtureBuilder, + test::MithrilFixtureBuilder, }; use test_extensions::{ ExpectedCertificate, ExpectedMetrics, RuntimeTester, utilities::get_test_dir, diff --git a/mithril-aggregator/tests/prove_transactions.rs b/mithril-aggregator/tests/prove_transactions.rs index 564a0bf748b..d0192289a1c 100644 --- a/mithril-aggregator/tests/prove_transactions.rs +++ b/mithril-aggregator/tests/prove_transactions.rs @@ -5,7 +5,7 @@ use mithril_common::{ ProtocolParameters, SignedEntityType, SignedEntityTypeDiscriminants, SlotNumber, TimePoint, }, temp_dir, - test_utils::MithrilFixtureBuilder, + test::MithrilFixtureBuilder, }; use test_extensions::{ ExpectedCertificate, ExpectedMetrics, RuntimeTester, utilities::get_test_dir, diff --git a/mithril-aggregator/tests/test_extensions/runtime_tester.rs b/mithril-aggregator/tests/test_extensions/runtime_tester.rs index 6c974186e59..640ba881658 100644 --- a/mithril-aggregator/tests/test_extensions/runtime_tester.rs +++ b/mithril-aggregator/tests/test_extensions/runtime_tester.rs @@ -29,7 +29,7 @@ use mithril_common::{ SingleSignatureAuthenticationStatus, SlotNumber, StakeDistribution, SupportedEra, TimePoint, }, - test_utils::{ + test::{ MithrilFixture, MithrilFixtureBuilder, SignerFixture, StakeDistributionGenerationMethod, double::Dummy, }, diff --git a/mithril-aggregator/tests/test_extensions/utilities.rs b/mithril-aggregator/tests/test_extensions/utilities.rs index c6921470b6a..efa842d9793 100644 --- a/mithril-aggregator/tests/test_extensions/utilities.rs +++ b/mithril-aggregator/tests/test_extensions/utilities.rs @@ -1,4 +1,4 @@ -use mithril_common::test_utils::TempDir; +use mithril_common::test::TempDir; use slog_scope::debug; use std::{ path::PathBuf, diff --git a/mithril-client-cli/src/commands/cardano_db/download/v1.rs b/mithril-client-cli/src/commands/cardano_db/download/v1.rs index 62c82b0c9c9..dc6197d14b9 100644 --- a/mithril-client-cli/src/commands/cardano_db/download/v1.rs +++ b/mithril-client-cli/src/commands/cardano_db/download/v1.rs @@ -236,7 +236,7 @@ mod tests { MithrilCertificateMetadata, common::{CardanoDbBeacon, ProtocolMessagePartKey, SignedEntityType}, }; - use mithril_common::test_utils::{TempDir, double::Dummy}; + use mithril_common::test::{TempDir, double::Dummy}; use super::*; diff --git a/mithril-client-cli/src/commands/cardano_db/download/v2.rs b/mithril-client-cli/src/commands/cardano_db/download/v2.rs index 9ea00495701..9c604b8a281 100644 --- a/mithril-client-cli/src/commands/cardano_db/download/v2.rs +++ b/mithril-client-cli/src/commands/cardano_db/download/v2.rs @@ -283,7 +283,7 @@ impl PreparedCardanoDbV2Download { #[cfg(test)] mod tests { use mithril_client::common::{AncillaryMessagePart, DigestsMessagePart, ImmutablesMessagePart}; - use mithril_common::test_utils::double::Dummy; + use mithril_common::test::double::Dummy; use super::*; diff --git a/mithril-client-cli/src/commands/cardano_db/shared_steps.rs b/mithril-client-cli/src/commands/cardano_db/shared_steps.rs index 85fb03a9f43..5efdd3e675d 100644 --- a/mithril-client-cli/src/commands/cardano_db/shared_steps.rs +++ b/mithril-client-cli/src/commands/cardano_db/shared_steps.rs @@ -221,7 +221,7 @@ mod tests { MithrilCertificateMetadata, common::{CardanoDbBeacon, ProtocolMessagePartKey, SignedEntityType}, }; - use mithril_common::test_utils::{TempDir, double::Dummy}; + use mithril_common::test::{TempDir, double::Dummy}; use crate::utils::ProgressOutputType; diff --git a/mithril-client-cli/src/utils/cardano_db_download_checker.rs b/mithril-client-cli/src/utils/cardano_db_download_checker.rs index ac7dcb61791..d3a9fc48630 100644 --- a/mithril-client-cli/src/utils/cardano_db_download_checker.rs +++ b/mithril-client-cli/src/utils/cardano_db_download_checker.rs @@ -176,7 +176,7 @@ impl CardanoDbDownloadChecker { #[cfg(test)] mod test { - use mithril_common::test_utils::TempDir; + use mithril_common::test::TempDir; use super::*; diff --git a/mithril-client/src/aggregator_client.rs b/mithril-client/src/aggregator_client.rs index c8dbf9fc5b1..66f3f818ba5 100644 --- a/mithril-client/src/aggregator_client.rs +++ b/mithril-client/src/aggregator_client.rs @@ -877,7 +877,7 @@ mod tests { mod warn_if_api_version_mismatch { use http::response::Builder as HttpResponseBuilder; - use mithril_common::test_utils::MemoryDrainForTestInspector; + use mithril_common::test::MemoryDrainForTestInspector; use super::*; diff --git a/mithril-client/src/cardano_database_client/api.rs b/mithril-client/src/cardano_database_client/api.rs index a5bd0cbf5b5..3f643e3fa49 100644 --- a/mithril-client/src/cardano_database_client/api.rs +++ b/mithril-client/src/cardano_database_client/api.rs @@ -249,7 +249,7 @@ pub(crate) mod test_dependency_injector { } mod tests { - use mithril_common::test_utils::double::Dummy; + use mithril_common::test::double::Dummy; use mockall::predicate; use crate::aggregator_client::AggregatorRequest; diff --git a/mithril-client/src/cardano_database_client/download_unpack/download_task.rs b/mithril-client/src/cardano_database_client/download_unpack/download_task.rs index 3b2121e3fd3..0dd25d53ac9 100644 --- a/mithril-client/src/cardano_database_client/download_unpack/download_task.rs +++ b/mithril-client/src/cardano_database_client/download_unpack/download_task.rs @@ -162,7 +162,7 @@ pub struct LocationToDownload { #[cfg(test)] mod tests { use mithril_common::entities::FileUri; - use mithril_common::test_utils::{assert_dir_eq, double::fake_keys, temp_dir_create}; + use mithril_common::test::{assert_dir_eq, double::fake_keys, temp_dir_create}; use crate::file_downloader::MockFileDownloaderBuilder; use crate::test_utils::TestLogger; diff --git a/mithril-client/src/cardano_database_client/download_unpack/internal_downloader.rs b/mithril-client/src/cardano_database_client/download_unpack/internal_downloader.rs index c3c9f8ce93f..3764338fb36 100644 --- a/mithril-client/src/cardano_database_client/download_unpack/internal_downloader.rs +++ b/mithril-client/src/cardano_database_client/download_unpack/internal_downloader.rs @@ -275,7 +275,7 @@ mod tests { use mithril_common::{ entities::{CardanoDbBeacon, Epoch, MultiFilesUri, TemplateUri}, messages::CardanoDatabaseSnapshotMessage as CardanoDatabaseSnapshot, - test_utils::{double::Dummy, temp_dir_create}, + test::{double::Dummy, temp_dir_create}, }; use crate::cardano_database_client::CardanoDatabaseClientDependencyInjector; @@ -532,7 +532,7 @@ mod tests { } mod building_download_tasks { - use mithril_common::{entities::CompressionAlgorithm, test_utils::double::fake_keys}; + use mithril_common::{entities::CompressionAlgorithm, test::double::fake_keys}; use crate::file_downloader::MockFileDownloader; diff --git a/mithril-client/src/cardano_database_client/fetch.rs b/mithril-client/src/cardano_database_client/fetch.rs index e667340ae9f..16bafbcc739 100644 --- a/mithril-client/src/cardano_database_client/fetch.rs +++ b/mithril-client/src/cardano_database_client/fetch.rs @@ -66,7 +66,7 @@ mod tests { use mockall::predicate::eq; use mithril_common::entities::{CardanoDbBeacon, Epoch}; - use mithril_common::test_utils::double::Dummy; + use mithril_common::test::double::Dummy; use crate::cardano_database_client::CardanoDatabaseClientDependencyInjector; diff --git a/mithril-client/src/cardano_database_client/proving.rs b/mithril-client/src/cardano_database_client/proving.rs index 711811c9cf0..ff8be6882d4 100644 --- a/mithril-client/src/cardano_database_client/proving.rs +++ b/mithril-client/src/cardano_database_client/proving.rs @@ -180,7 +180,7 @@ mod tests { use mithril_common::{ entities::{CardanoDbBeacon, Epoch, HexEncodedDigest}, messages::CardanoDatabaseDigestListItemMessage, - test_utils::{TempDir, double::Dummy}, + test::{TempDir, double::Dummy}, }; use crate::{ diff --git a/mithril-client/src/cardano_transaction_client.rs b/mithril-client/src/cardano_transaction_client.rs index c488ba55c0f..d048f4c5268 100644 --- a/mithril-client/src/cardano_transaction_client.rs +++ b/mithril-client/src/cardano_transaction_client.rs @@ -164,7 +164,7 @@ mod tests { use chrono::{DateTime, Utc}; use mockall::predicate::eq; - use mithril_common::test_utils::double::Dummy; + use mithril_common::test::double::Dummy; use crate::aggregator_client::{AggregatorClientError, MockAggregatorClient}; use crate::common::{BlockNumber, Epoch}; diff --git a/mithril-client/src/certificate_client/fetch.rs b/mithril-client/src/certificate_client/fetch.rs index 28fa0c6988b..7c8b00b4b55 100644 --- a/mithril-client/src/certificate_client/fetch.rs +++ b/mithril-client/src/certificate_client/fetch.rs @@ -105,7 +105,7 @@ impl CertificateRetriever for InternalCertificateRetriever { #[cfg(test)] mod tests { - use mithril_common::test_utils::double::{Dummy, fake_data}; + use mithril_common::test::double::{Dummy, fake_data}; use crate::certificate_client::tests_utils::CertificateClientTestBuilder; diff --git a/mithril-client/src/certificate_client/verify.rs b/mithril-client/src/certificate_client/verify.rs index 30f498d994d..3d0913ed97a 100644 --- a/mithril-client/src/certificate_client/verify.rs +++ b/mithril-client/src/certificate_client/verify.rs @@ -244,7 +244,7 @@ impl CertificateVerifier for MithrilCertificateVerifier { #[cfg(test)] mod tests { - use mithril_common::test_utils::CertificateChainBuilder; + use mithril_common::test::CertificateChainBuilder; use crate::certificate_client::tests_utils::CertificateClientTestBuilder; use crate::feedback::StackFeedbackReceiver; @@ -321,7 +321,7 @@ mod tests { #[cfg(feature = "unstable")] mod cache { use chrono::TimeDelta; - use mithril_common::test_utils::CertificateChainingMethod; + use mithril_common::test::CertificateChainingMethod; use mockall::predicate::eq; use crate::aggregator_client::MockAggregatorClient; diff --git a/mithril-client/src/certificate_client/verify_cache/memory_cache.rs b/mithril-client/src/certificate_client/verify_cache/memory_cache.rs index 078347ba7dd..edee4932a93 100644 --- a/mithril-client/src/certificate_client/verify_cache/memory_cache.rs +++ b/mithril-client/src/certificate_client/verify_cache/memory_cache.rs @@ -161,7 +161,7 @@ pub(crate) mod test_tools { #[cfg(test)] mod tests { use mithril_common::entities::Certificate; - use mithril_common::test_utils::double::fake_data; + use mithril_common::test::double::fake_data; use super::*; diff --git a/mithril-client/src/file_downloader/http.rs b/mithril-client/src/file_downloader/http.rs index e51243faf46..83750375ca4 100644 --- a/mithril-client/src/file_downloader/http.rs +++ b/mithril-client/src/file_downloader/http.rs @@ -242,7 +242,7 @@ mod tests { use httpmock::MockServer; - use mithril_common::{entities::FileUri, test_utils::TempDir}; + use mithril_common::{entities::FileUri, test::TempDir}; use crate::{ feedback::{MithrilEvent, MithrilEventCardanoDatabase, StackFeedbackReceiver}, diff --git a/mithril-client/src/lib.rs b/mithril-client/src/lib.rs index 15ea396668a..ca116c7934d 100644 --- a/mithril-client/src/lib.rs +++ b/mithril-client/src/lib.rs @@ -151,7 +151,7 @@ pub(crate) mod test_utils { use slog_async::Async; use slog_term::{CompactFormat, PlainDecorator}; - use mithril_common::test_utils::{MemoryDrainForTest, MemoryDrainForTestInspector}; + use mithril_common::test::{MemoryDrainForTest, MemoryDrainForTestInspector}; pub struct TestLogger; diff --git a/mithril-client/src/mithril_stake_distribution_client.rs b/mithril-client/src/mithril_stake_distribution_client.rs index 9cdc0b49c87..5f5ccc169df 100644 --- a/mithril-client/src/mithril_stake_distribution_client.rs +++ b/mithril-client/src/mithril_stake_distribution_client.rs @@ -95,7 +95,7 @@ impl MithrilStakeDistributionClient { #[cfg(test)] mod tests { use chrono::{DateTime, Utc}; - use mithril_common::test_utils::double::fake_data; + use mithril_common::test::double::fake_data; use crate::MithrilSigner; use crate::aggregator_client::MockAggregatorClient; diff --git a/mithril-client/src/snapshot_client.rs b/mithril-client/src/snapshot_client.rs index 138b781e56a..7177b62b163 100644 --- a/mithril-client/src/snapshot_client.rs +++ b/mithril-client/src/snapshot_client.rs @@ -481,7 +481,7 @@ mod tests { }; use mithril_cardano_node_internal_database::IMMUTABLE_DIR; - use mithril_common::test_utils::double::{Dummy, fake_keys}; + use mithril_common::test::double::{Dummy, fake_keys}; use mithril_common::{assert_dir_eq, crypto_helper::ManifestSigner, temp_dir_create}; use super::*; diff --git a/mithril-client/src/utils/ancillary_verifier.rs b/mithril-client/src/utils/ancillary_verifier.rs index adb0106b5a2..173a7d8659a 100644 --- a/mithril-client/src/utils/ancillary_verifier.rs +++ b/mithril-client/src/utils/ancillary_verifier.rs @@ -131,7 +131,7 @@ mod tests { use std::collections::BTreeMap; use mithril_common::entities::SignableManifest; - use mithril_common::{crypto_helper::ManifestSigner, test_utils::double::fake_keys}; + use mithril_common::{crypto_helper::ManifestSigner, test::double::fake_keys}; use super::*; diff --git a/mithril-client/tests/cardano_db_snapshot_list_get_download_verify.rs b/mithril-client/tests/cardano_db_snapshot_list_get_download_verify.rs index dd94341c738..6058fd96af4 100644 --- a/mithril-client/tests/cardano_db_snapshot_list_get_download_verify.rs +++ b/mithril-client/tests/cardano_db_snapshot_list_get_download_verify.rs @@ -11,7 +11,7 @@ use mithril_client::{ cardano_database_client::{DownloadUnpackOptions, ImmutableFileRange}, feedback::SlogFeedbackReceiver, }; -use mithril_common::{crypto_helper::ManifestSigner, test_utils::double::fake_keys}; +use mithril_common::{crypto_helper::ManifestSigner, test::double::fake_keys}; use crate::extensions::fake_aggregator::{ CardanoDatabaseSnapshotV2Fixture, FakeAggregator, FakeCertificateVerifier, diff --git a/mithril-client/tests/cardano_transaction_proof.rs b/mithril-client/tests/cardano_transaction_proof.rs index 9220e879e90..c1da74e7b6c 100644 --- a/mithril-client/tests/cardano_transaction_proof.rs +++ b/mithril-client/tests/cardano_transaction_proof.rs @@ -1,7 +1,7 @@ mod extensions; use mithril_client::{ClientBuilder, MessageBuilder, aggregator_client::AggregatorRequest}; -use mithril_common::test_utils::double::fake_keys; +use mithril_common::test::double::fake_keys; use crate::extensions::fake_aggregator::{FakeAggregator, FakeCertificateVerifier}; diff --git a/mithril-client/tests/certificate_get_list.rs b/mithril-client/tests/certificate_get_list.rs index 49343777bca..46453c5c8db 100644 --- a/mithril-client/tests/certificate_get_list.rs +++ b/mithril-client/tests/certificate_get_list.rs @@ -1,7 +1,7 @@ mod extensions; use mithril_client::{ClientBuilder, aggregator_client::AggregatorRequest}; -use mithril_common::test_utils::double::fake_keys; +use mithril_common::test::double::fake_keys; use crate::extensions::fake_aggregator::FakeAggregator; diff --git a/mithril-client/tests/extensions/fake_aggregator/cardano_db_v1.rs b/mithril-client/tests/extensions/fake_aggregator/cardano_db_v1.rs index 797dfb1e2d9..cc86198f47e 100644 --- a/mithril-client/tests/extensions/fake_aggregator/cardano_db_v1.rs +++ b/mithril-client/tests/extensions/fake_aggregator/cardano_db_v1.rs @@ -7,7 +7,7 @@ use mithril_cardano_node_internal_database::test::DummyCardanoDb; use mithril_client::{MessageBuilder, MithrilCertificate, Snapshot, SnapshotListItem}; use mithril_common::crypto_helper::ManifestVerifierSecretKey; use mithril_common::entities::{CardanoDbBeacon, CompressionAlgorithm, SignedEntityType}; -use mithril_common::test_utils::double::{Dummy, fake_data}; +use mithril_common::test::double::{Dummy, fake_data}; use crate::extensions::{routes, snapshot_archives}; diff --git a/mithril-client/tests/extensions/fake_aggregator/cardano_db_v2.rs b/mithril-client/tests/extensions/fake_aggregator/cardano_db_v2.rs index 572cc1595ed..f05e188f4f5 100644 --- a/mithril-client/tests/extensions/fake_aggregator/cardano_db_v2.rs +++ b/mithril-client/tests/extensions/fake_aggregator/cardano_db_v2.rs @@ -17,7 +17,7 @@ use mithril_client::{ CardanoDatabaseSnapshot, CardanoDatabaseSnapshotListItem, MithrilCertificate, }; use mithril_common::crypto_helper::ManifestVerifierSecretKey; -use mithril_common::test_utils::double::{Dummy, fake_data}; +use mithril_common::test::double::{Dummy, fake_data}; use crate::extensions::{routes, snapshot_archives}; diff --git a/mithril-client/tests/extensions/fake_aggregator/cardano_transaction.rs b/mithril-client/tests/extensions/fake_aggregator/cardano_transaction.rs index d55c4fd5073..44dc9aac79c 100644 --- a/mithril-client/tests/extensions/fake_aggregator/cardano_transaction.rs +++ b/mithril-client/tests/extensions/fake_aggregator/cardano_transaction.rs @@ -1,7 +1,7 @@ use mithril_client::common::{BlockNumber, ProtocolMessagePartKey}; use mithril_client::{CardanoTransactionsProofs, CardanoTransactionsSetProof, MithrilCertificate}; use mithril_common::crypto_helper::{MKProof, ProtocolMkProof}; -use mithril_common::test_utils::double::Dummy; +use mithril_common::test::double::Dummy; use crate::extensions::routes; diff --git a/mithril-client/tests/extensions/fake_aggregator/certificate.rs b/mithril-client/tests/extensions/fake_aggregator/certificate.rs index 3794e5a8df9..8ca4cf68df0 100644 --- a/mithril-client/tests/extensions/fake_aggregator/certificate.rs +++ b/mithril-client/tests/extensions/fake_aggregator/certificate.rs @@ -1,5 +1,5 @@ use mithril_client::{MithrilCertificate, MithrilCertificateListItem}; -use mithril_common::test_utils::double::Dummy; +use mithril_common::test::double::Dummy; use crate::extensions::routes; diff --git a/mithril-client/tests/extensions/fake_aggregator/mithril_stake_distribution.rs b/mithril-client/tests/extensions/fake_aggregator/mithril_stake_distribution.rs index 3a28e2750a5..5706769d85c 100644 --- a/mithril-client/tests/extensions/fake_aggregator/mithril_stake_distribution.rs +++ b/mithril-client/tests/extensions/fake_aggregator/mithril_stake_distribution.rs @@ -1,7 +1,7 @@ use mithril_client::{ MessageBuilder, MithrilCertificate, MithrilStakeDistribution, MithrilStakeDistributionListItem, }; -use mithril_common::test_utils::double::Dummy; +use mithril_common::test::double::Dummy; use crate::extensions::routes; diff --git a/mithril-client/tests/extensions/mod.rs b/mithril-client/tests/extensions/mod.rs index 8e7d65495af..ef039448e5e 100644 --- a/mithril-client/tests/extensions/mod.rs +++ b/mithril-client/tests/extensions/mod.rs @@ -8,7 +8,7 @@ mod routes; #[cfg(feature = "fs")] mod snapshot_archives; -use mithril_common::test_utils::TempDir; +use mithril_common::test::TempDir; use std::path::PathBuf; pub fn get_test_dir(subdir_name: &str) -> PathBuf { diff --git a/mithril-client/tests/mithril_stake_distribution_list_get_show_verify.rs b/mithril-client/tests/mithril_stake_distribution_list_get_show_verify.rs index 134b223421d..736f2578bac 100644 --- a/mithril-client/tests/mithril_stake_distribution_list_get_show_verify.rs +++ b/mithril-client/tests/mithril_stake_distribution_list_get_show_verify.rs @@ -1,7 +1,7 @@ mod extensions; use mithril_client::{ClientBuilder, MessageBuilder, aggregator_client::AggregatorRequest}; -use mithril_common::test_utils::double::fake_keys; +use mithril_common::test::double::fake_keys; use crate::extensions::fake_aggregator::{FakeAggregator, FakeCertificateVerifier}; diff --git a/mithril-client/tests/snapshot_list_get_show_download_verify.rs b/mithril-client/tests/snapshot_list_get_show_download_verify.rs index 823f44d07e2..abc030c3437 100644 --- a/mithril-client/tests/snapshot_list_get_show_download_verify.rs +++ b/mithril-client/tests/snapshot_list_get_show_download_verify.rs @@ -7,7 +7,7 @@ use mithril_client::aggregator_client::AggregatorRequest; use mithril_client::feedback::SlogFeedbackReceiver; use mithril_client::{ClientBuilder, MessageBuilder}; use mithril_common::crypto_helper::ManifestSigner; -use mithril_common::test_utils::double::fake_keys; +use mithril_common::test::double::fake_keys; use crate::extensions::fake_aggregator::{FakeAggregator, FakeCertificateVerifier}; diff --git a/mithril-common/src/certificate_chain/certificate_genesis.rs b/mithril-common/src/certificate_chain/certificate_genesis.rs index ee6bc96bb2a..f75207878c5 100644 --- a/mithril-common/src/certificate_chain/certificate_genesis.rs +++ b/mithril-common/src/certificate_chain/certificate_genesis.rs @@ -111,7 +111,7 @@ impl CertificateGenesisProducer { mod tests { use super::*; - use crate::{entities::ProtocolMessagePartKey, test_utils::MithrilFixtureBuilder}; + use crate::{entities::ProtocolMessagePartKey, test::MithrilFixtureBuilder}; #[test] fn test_create_genesis_protocol_message_has_expected_keys_and_values() { diff --git a/mithril-common/src/certificate_chain/certificate_verifier.rs b/mithril-common/src/certificate_chain/certificate_verifier.rs index 4f308ec49a3..fc28d0d5079 100644 --- a/mithril-common/src/certificate_chain/certificate_verifier.rs +++ b/mithril-common/src/certificate_chain/certificate_verifier.rs @@ -429,7 +429,7 @@ mod tests { use crate::certificate_chain::{CertificateRetrieverError, FakeCertificaterRetriever}; use crate::crypto_helper::{ProtocolClerk, tests_setup::*}; - use crate::test_utils::{ + use crate::test::{ CertificateChainBuilder, CertificateChainBuilderContext, MithrilFixtureBuilder, TestLogger, }; diff --git a/mithril-common/src/certificate_chain/fake_certificate_retriever.rs b/mithril-common/src/certificate_chain/fake_certificate_retriever.rs index 6d9aa1f8c8d..4bf1d7aca76 100644 --- a/mithril-common/src/certificate_chain/fake_certificate_retriever.rs +++ b/mithril-common/src/certificate_chain/fake_certificate_retriever.rs @@ -44,7 +44,7 @@ impl CertificateRetriever for FakeCertificaterRetriever { #[cfg(test)] mod tests { - use crate::test_utils::double::fake_data; + use crate::test::double::fake_data; use super::*; diff --git a/mithril-common/src/crypto_helper/cardano/codec.rs b/mithril-common/src/crypto_helper/cardano/codec.rs index d0518619012..976c43757c9 100644 --- a/mithril-common/src/crypto_helper/cardano/codec.rs +++ b/mithril-common/src/crypto_helper/cardano/codec.rs @@ -180,7 +180,7 @@ impl<'a> TryFrom<&'a mut Sum6KesBytes> for Sum6Kes<'a> { #[cfg(test)] mod test { use super::*; - use crate::test_utils::TempDir; + use crate::test::TempDir; #[test] fn compat_with_shelly_format() { diff --git a/mithril-common/src/crypto_helper/cardano/opcert.rs b/mithril-common/src/crypto_helper/cardano/opcert.rs index d2fbabfbf52..dd62c5c95e8 100644 --- a/mithril-common/src/crypto_helper/cardano/opcert.rs +++ b/mithril-common/src/crypto_helper/cardano/opcert.rs @@ -179,7 +179,7 @@ impl<'de> Deserialize<'de> for OpCert { mod tests { use super::*; use crate::crypto_helper::cardano::ColdKeyGenerator; - use crate::test_utils::TempDir; + use crate::test::TempDir; use kes_summed_ed25519::{kes::Sum6Kes, traits::KesSk}; use std::path::PathBuf; diff --git a/mithril-common/src/crypto_helper/conversions.rs b/mithril-common/src/crypto_helper/conversions.rs index 7d067635b51..2ed9716a2d5 100644 --- a/mithril-common/src/crypto_helper/conversions.rs +++ b/mithril-common/src/crypto_helper/conversions.rs @@ -30,7 +30,7 @@ impl From<&entities::SignerWithStake> for (types::ProtocolPartyId, types::Protoc #[cfg(test)] pub mod tests { - use crate::test_utils::MithrilFixtureBuilder; + use crate::test::MithrilFixtureBuilder; use super::*; diff --git a/mithril-common/src/crypto_helper/tests_setup.rs b/mithril-common/src/crypto_helper/tests_setup.rs index a2a8eefb6c7..231e3009fc1 100644 --- a/mithril-common/src/crypto_helper/tests_setup.rs +++ b/mithril-common/src/crypto_helper/tests_setup.rs @@ -7,7 +7,7 @@ use rand_core::SeedableRng; use crate::{ crypto_helper::{KesSigner, cardano::KesSignerStandard}, entities::{ProtocolMessage, ProtocolMessagePartKey, SignerWithStake, Stake}, - test_utils::{CertificateChainBuilder, CertificateChainFixture, SignerFixture, TempDir}, + test::{CertificateChainBuilder, CertificateChainFixture, SignerFixture, TempDir}, }; use super::{OpCert, SerDeShelleyFileFormat, types::*}; diff --git a/mithril-common/src/crypto_helper/types/protocol_key.rs b/mithril-common/src/crypto_helper/types/protocol_key.rs index 55928b2f580..aa4fed3961e 100644 --- a/mithril-common/src/crypto_helper/types/protocol_key.rs +++ b/mithril-common/src/crypto_helper/types/protocol_key.rs @@ -287,7 +287,7 @@ macro_rules! impl_codec_and_type_conversions_for_protocol_key { mod test { use crate::{ crypto_helper::ProtocolKey, - test_utils::{TempDir, double::fake_keys}, + test::{TempDir, double::fake_keys}, }; use mithril_stm::VerificationKeyProofOfPossession; use serde::{Deserialize, Serialize}; diff --git a/mithril-common/src/entities/certificate.rs b/mithril-common/src/entities/certificate.rs index cebc7d1076e..7114941f552 100644 --- a/mithril-common/src/entities/certificate.rs +++ b/mithril-common/src/entities/certificate.rs @@ -171,7 +171,7 @@ mod tests { ProtocolMessagePartKey, ProtocolParameters, certificate_metadata::StakeDistributionParty, }, - test_utils::double::fake_keys, + test::double::fake_keys, }; use super::*; diff --git a/mithril-common/src/entities/mithril_stake_distribution.rs b/mithril-common/src/entities/mithril_stake_distribution.rs index b628acb49b3..e842f58908e 100644 --- a/mithril-common/src/entities/mithril_stake_distribution.rs +++ b/mithril-common/src/entities/mithril_stake_distribution.rs @@ -56,7 +56,7 @@ impl MithrilStakeDistribution { #[cfg(test)] mod tests { - use crate::test_utils::{MithrilFixtureBuilder, double::fake_data}; + use crate::test::{MithrilFixtureBuilder, double::fake_data}; use super::*; diff --git a/mithril-common/src/entities/signed_entity_config.rs b/mithril-common/src/entities/signed_entity_config.rs index fcee7673696..4abc6cfacc0 100644 --- a/mithril-common/src/entities/signed_entity_config.rs +++ b/mithril-common/src/entities/signed_entity_config.rs @@ -157,7 +157,7 @@ mod tests { use crate::entities::{ CardanoDbBeacon, ChainPoint, Epoch, SignedEntityType, SlotNumber, TimePoint, }; - use crate::test_utils::{double::Dummy, double::fake_data}; + use crate::test::{double::Dummy, double::fake_data}; use super::*; diff --git a/mithril-common/src/entities/signed_entity_type.rs b/mithril-common/src/entities/signed_entity_type.rs index 5f3c0ed82eb..d36ce7bca4f 100644 --- a/mithril-common/src/entities/signed_entity_type.rs +++ b/mithril-common/src/entities/signed_entity_type.rs @@ -248,7 +248,7 @@ Accepted values are (case-sensitive): {}."#, mod tests { use digest::Digest; - use crate::test_utils::assert_same_json; + use crate::test::assert_same_json; use super::*; diff --git a/mithril-common/src/entities/signer.rs b/mithril-common/src/entities/signer.rs index 8d95bf7158b..973a294a3e6 100644 --- a/mithril-common/src/entities/signer.rs +++ b/mithril-common/src/entities/signer.rs @@ -264,7 +264,7 @@ impl Debug for SignerWithStake { #[cfg(test)] mod tests { - use crate::test_utils::{MithrilFixtureBuilder, double::fake_keys}; + use crate::test::{MithrilFixtureBuilder, double::fake_keys}; use super::*; diff --git a/mithril-common/src/entities/single_signature.rs b/mithril-common/src/entities/single_signature.rs index 48e1b86ce19..6a72a80f905 100644 --- a/mithril-common/src/entities/single_signature.rs +++ b/mithril-common/src/entities/single_signature.rs @@ -67,7 +67,7 @@ impl SingleSignature { /// Create a fake [SingleSignature] with valid cryptographic data for testing purposes. pub fn fake, TMessage: Into>(party_id: TPartyId, message: TMessage) -> Self { use crate::entities::{ProtocolParameters}; - use crate::test_utils::{MithrilFixtureBuilder, StakeDistributionGenerationMethod}; + use crate::test::{MithrilFixtureBuilder, StakeDistributionGenerationMethod}; let party_id = party_id.into(); let message = message.into(); @@ -110,7 +110,7 @@ impl Debug for SingleSignature { #[cfg(test)] mod tests { use super::*; - use crate::{crypto_helper::tests_setup::setup_message, test_utils::MithrilFixtureBuilder}; + use crate::{crypto_helper::tests_setup::setup_message, test::MithrilFixtureBuilder}; #[test] fn single_signatures_should_convert_to_protocol_signatures() { diff --git a/mithril-common/src/entities/supported_era.rs b/mithril-common/src/entities/supported_era.rs index 60a42ac024a..e6d6f1fd746 100644 --- a/mithril-common/src/entities/supported_era.rs +++ b/mithril-common/src/entities/supported_era.rs @@ -23,7 +23,7 @@ impl SupportedEra { mod tests { use std::str::FromStr; - use crate::test_utils::double::Dummy; + use crate::test::double::Dummy; use super::*; diff --git a/mithril-common/src/lib.rs b/mithril-common/src/lib.rs index a8a7ebe3c04..faffd90afc1 100644 --- a/mithril-common/src/lib.rs +++ b/mithril-common/src/lib.rs @@ -29,7 +29,7 @@ pub mod protocol; pub mod signable_builder; cfg_test_tools! { - pub mod test_utils; + pub mod test; } pub use entities::{CardanoNetwork, MagicId}; diff --git a/mithril-common/src/logging.rs b/mithril-common/src/logging.rs index 3f74170fff7..69ead26deb3 100644 --- a/mithril-common/src/logging.rs +++ b/mithril-common/src/logging.rs @@ -36,7 +36,7 @@ fn component_name() -> &'static str { #[cfg(test)] mod tests { use super::*; - use crate::test_utils::TestLogger; + use crate::test::TestLogger; use slog::info; struct TestStruct; diff --git a/mithril-common/src/messages/cardano_transactions_proof.rs b/mithril-common/src/messages/cardano_transactions_proof.rs index a3b926b87bb..a5aae890fbb 100644 --- a/mithril-common/src/messages/cardano_transactions_proof.rs +++ b/mithril-common/src/messages/cardano_transactions_proof.rs @@ -189,7 +189,7 @@ mod tests { CardanoTransactionsSignableBuilder, MockBlockRangeRootRetriever, MockTransactionsImporter, SignableBuilder, }; - use crate::test_utils::double::Dummy; + use crate::test::double::Dummy; use super::*; diff --git a/mithril-common/src/messages/mithril_stake_distribution.rs b/mithril-common/src/messages/mithril_stake_distribution.rs index 5b84999e542..51d97f79659 100644 --- a/mithril-common/src/messages/mithril_stake_distribution.rs +++ b/mithril-common/src/messages/mithril_stake_distribution.rs @@ -31,7 +31,7 @@ pub struct MithrilStakeDistributionMessage { #[cfg(test)] mod tests { - use crate::test_utils::double::fake_data; + use crate::test::double::fake_data; use super::*; diff --git a/mithril-common/src/messages/snapshot.rs b/mithril-common/src/messages/snapshot.rs index ff6ba8abcaa..065656e4881 100644 --- a/mithril-common/src/messages/snapshot.rs +++ b/mithril-common/src/messages/snapshot.rs @@ -52,7 +52,7 @@ impl SnapshotMessage { #[cfg(test)] mod tests { use crate::entities::Epoch; - use crate::test_utils::double::Dummy; + use crate::test::double::Dummy; use super::*; diff --git a/mithril-common/src/protocol/multi_signer.rs b/mithril-common/src/protocol/multi_signer.rs index f7e48e3e0b4..8760007dbf4 100644 --- a/mithril-common/src/protocol/multi_signer.rs +++ b/mithril-common/src/protocol/multi_signer.rs @@ -94,8 +94,8 @@ mod test { use crate::{ entities::{ProtocolMessage, ProtocolMessagePartKey, ProtocolParameters}, protocol::SignerBuilder, - test_utils::double::fake_keys, - test_utils::{MithrilFixture, MithrilFixtureBuilder, StakeDistributionGenerationMethod}, + test::double::fake_keys, + test::{MithrilFixture, MithrilFixtureBuilder, StakeDistributionGenerationMethod}, }; use super::*; diff --git a/mithril-common/src/protocol/signer_builder.rs b/mithril-common/src/protocol/signer_builder.rs index 6a706546cf9..ed6a67bfdc5 100644 --- a/mithril-common/src/protocol/signer_builder.rs +++ b/mithril-common/src/protocol/signer_builder.rs @@ -178,7 +178,7 @@ mod test { use crate::{ crypto_helper::{KesSignerStandard, ProtocolRegistrationErrorWrapper}, - test_utils::{MithrilFixtureBuilder, double::fake_data}, + test::{MithrilFixtureBuilder, double::fake_data}, }; use super::*; @@ -207,7 +207,7 @@ mod test { let fixture_with_another_stake_distribution = MithrilFixtureBuilder::default() .with_signers(1) .with_stake_distribution( - crate::test_utils::StakeDistributionGenerationMethod::RandomDistribution { + crate::test::StakeDistributionGenerationMethod::RandomDistribution { seed: [4u8; 32], min_stake: 1, }, diff --git a/mithril-common/src/protocol/single_signer.rs b/mithril-common/src/protocol/single_signer.rs index f02be138e18..3c43349e945 100644 --- a/mithril-common/src/protocol/single_signer.rs +++ b/mithril-common/src/protocol/single_signer.rs @@ -53,7 +53,7 @@ mod test { crypto_helper::{KesSigner, KesSignerStandard}, entities::ProtocolMessage, protocol::SignerBuilder, - test_utils::MithrilFixtureBuilder, + test::MithrilFixtureBuilder, }; #[test] diff --git a/mithril-common/src/signable_builder/cardano_transactions.rs b/mithril-common/src/signable_builder/cardano_transactions.rs index d7289169712..378d2e3ed57 100644 --- a/mithril-common/src/signable_builder/cardano_transactions.rs +++ b/mithril-common/src/signable_builder/cardano_transactions.rs @@ -96,7 +96,7 @@ mod tests { use crate::{ crypto_helper::MKTreeStoreInMemory, entities::CardanoTransaction, - test_utils::CardanoTransactionsBuilder, + test::CardanoTransactionsBuilder, }; use super::*; diff --git a/mithril-common/src/signable_builder/signable_builder_service.rs b/mithril-common/src/signable_builder/signable_builder_service.rs index 8170689f619..2513f960cc4 100644 --- a/mithril-common/src/signable_builder/signable_builder_service.rs +++ b/mithril-common/src/signable_builder/signable_builder_service.rs @@ -181,7 +181,7 @@ mod tests { StdResult, entities::{BlockNumber, Epoch, ProtocolMessage}, signable_builder::{Beacon as Beaconnable, MockSignableSeedBuilder, SignableBuilder}, - test_utils::TestLogger, + test::TestLogger, }; use async_trait::async_trait; diff --git a/mithril-common/src/test_utils/cardano_transactions_builder.rs b/mithril-common/src/test/cardano_transactions_builder.rs similarity index 98% rename from mithril-common/src/test_utils/cardano_transactions_builder.rs rename to mithril-common/src/test/cardano_transactions_builder.rs index 94216c036b5..6c5c82f4524 100644 --- a/mithril-common/src/test_utils/cardano_transactions_builder.rs +++ b/mithril-common/src/test/cardano_transactions_builder.rs @@ -8,7 +8,7 @@ use crate::entities::{BlockNumber, BlockRange, CardanoTransaction, SlotNumber}; /// /// ``` /// use mithril_common::entities::{BlockNumber, CardanoTransaction, SlotNumber}; -/// use mithril_common::test_utils::CardanoTransactionsBuilder; +/// use mithril_common::test::CardanoTransactionsBuilder; /// /// let txs = CardanoTransactionsBuilder::new() /// .max_transactions_per_block(3) @@ -35,7 +35,7 @@ use crate::entities::{BlockNumber, BlockRange, CardanoTransaction, SlotNumber}; /// /// ``` /// use mithril_common::entities::{BlockNumber, CardanoTransaction, SlotNumber}; -/// use mithril_common::test_utils::CardanoTransactionsBuilder; +/// use mithril_common::test::CardanoTransactionsBuilder; /// /// let txs = CardanoTransactionsBuilder::new() /// .max_transactions_per_block(3) diff --git a/mithril-common/src/test_utils/certificate_chain_builder.rs b/mithril-common/src/test/certificate_chain_builder.rs similarity index 99% rename from mithril-common/src/test_utils/certificate_chain_builder.rs rename to mithril-common/src/test/certificate_chain_builder.rs index 2c396a78acd..c64851c00c6 100644 --- a/mithril-common/src/test_utils/certificate_chain_builder.rs +++ b/mithril-common/src/test/certificate_chain_builder.rs @@ -14,7 +14,7 @@ use crate::{ CardanoDbBeacon, Certificate, CertificateMetadata, CertificateSignature, Epoch, ProtocolMessage, ProtocolMessagePartKey, SignedEntityType, }, - test_utils::{MithrilFixture, MithrilFixtureBuilder, SignerFixture, double::fake_data}, + test::{MithrilFixture, MithrilFixtureBuilder, SignerFixture, double::fake_data}, }; /// Genesis certificate processor function type. For tests only. @@ -169,7 +169,7 @@ impl CertificateChainFixture { /// /// ``` /// use mithril_common::crypto_helper::ProtocolParameters; -/// use mithril_common::test_utils::CertificateChainBuilder; +/// use mithril_common::test::CertificateChainBuilder; /// /// let certificate_chain_fixture = CertificateChainBuilder::new() /// .with_total_certificates(5) @@ -184,7 +184,7 @@ impl CertificateChainFixture { /// ``` /// use std::cmp::min; /// use mithril_common::crypto_helper::ProtocolParameters; -/// use mithril_common::test_utils::CertificateChainBuilder; +/// use mithril_common::test::CertificateChainBuilder; /// /// let certificate_chain_fixture = CertificateChainBuilder::new() /// .with_total_certificates(5) @@ -205,7 +205,7 @@ impl CertificateChainFixture { /// ``` /// use mithril_common::entities::Epoch; /// use mithril_common::crypto_helper::ProtocolParameters; -/// use mithril_common::test_utils::CertificateChainBuilder; +/// use mithril_common::test::CertificateChainBuilder; /// /// let certificate_chain_fixture = CertificateChainBuilder::new() /// .with_total_certificates(5) diff --git a/mithril-common/src/test_utils/dir_eq.rs b/mithril-common/src/test/dir_eq.rs similarity index 96% rename from mithril-common/src/test_utils/dir_eq.rs rename to mithril-common/src/test/dir_eq.rs index ea1c91d5278..59bb852bda8 100644 --- a/mithril-common/src/test_utils/dir_eq.rs +++ b/mithril-common/src/test/dir_eq.rs @@ -139,7 +139,7 @@ impl From<&str> for DirStructure { /// /// Example: /// ```no_run -/// # use mithril_common::test_utils::assert_dir_eq; +/// # use mithril_common::test::assert_dir_eq; /// # use std::path::PathBuf; /// # let path = PathBuf::new(); /// assert_dir_eq!( @@ -155,11 +155,11 @@ impl From<&str> for DirStructure { #[macro_export] macro_rules! assert_dir_eq { ($dir: expr, $expected_structure: expr) => { - $crate::test_utils::assert_dir_eq!($dir, $expected_structure, ""); + $crate::test::assert_dir_eq!($dir, $expected_structure, ""); }; ($dir: expr, $expected_structure: expr, $($arg:tt)+) => { - let actual = $crate::test_utils::DirStructure::from_path($dir); - let expected = $crate::test_utils::DirStructure::from($expected_structure); + let actual = $crate::test::DirStructure::from_path($dir); + let expected = $crate::test::DirStructure::from($expected_structure); let comment = format!($($arg)+); assert!( actual == expected, @@ -177,7 +177,7 @@ pub use assert_dir_eq; mod tests { use std::fs::{File, create_dir}; - use crate::test_utils::temp_dir_create; + use crate::test::temp_dir_create; use super::*; diff --git a/mithril-common/src/test_utils/double/dummies.rs b/mithril-common/src/test/double/dummies.rs similarity index 99% rename from mithril-common/src/test_utils/double/dummies.rs rename to mithril-common/src/test/double/dummies.rs index abb3962fc38..5733a225d47 100644 --- a/mithril-common/src/test_utils/double/dummies.rs +++ b/mithril-common/src/test/double/dummies.rs @@ -1,6 +1,6 @@ use chrono::{DateTime, Utc}; -use crate::test_utils::double::{Dummy, fake_data, fake_keys}; +use crate::test::double::{Dummy, fake_data, fake_keys}; mod entities { use crate::crypto_helper::MKTreeStoreInMemory; diff --git a/mithril-common/src/test_utils/double/fake_data.rs b/mithril-common/src/test/double/fake_data.rs similarity index 99% rename from mithril-common/src/test_utils/double/fake_data.rs rename to mithril-common/src/test/double/fake_data.rs index a19084a5950..a3d5429ac24 100644 --- a/mithril-common/src/test_utils/double/fake_data.rs +++ b/mithril-common/src/test/double/fake_data.rs @@ -11,7 +11,7 @@ use crate::entities::{ ImmutablesLocations, LotteryIndex, ProtocolMessage, ProtocolMessagePartKey, SignedEntityType, SingleSignature, SlotNumber, StakeDistribution, StakeDistributionParty, }; -use crate::test_utils::{MithrilFixtureBuilder, double::Dummy}; +use crate::test::{MithrilFixtureBuilder, double::Dummy}; use super::fake_keys; diff --git a/mithril-common/src/test_utils/double/fake_keys.rs b/mithril-common/src/test/double/fake_keys.rs similarity index 100% rename from mithril-common/src/test_utils/double/fake_keys.rs rename to mithril-common/src/test/double/fake_keys.rs diff --git a/mithril-common/src/test_utils/double/mod.rs b/mithril-common/src/test/double/mod.rs similarity index 95% rename from mithril-common/src/test_utils/double/mod.rs rename to mithril-common/src/test/double/mod.rs index 35ff083fc54..492ba28fb1f 100644 --- a/mithril-common/src/test_utils/double/mod.rs +++ b/mithril-common/src/test/double/mod.rs @@ -18,7 +18,7 @@ pub(super) mod precomputed_kes_key; /// /// # Example /// ``` -/// use mithril_common::test_utils::double::Dummy; +/// use mithril_common::test::double::Dummy; /// /// struct MyType(String); /// diff --git a/mithril-common/src/test_utils/double/precomputed_kes_key.rs b/mithril-common/src/test/double/precomputed_kes_key.rs similarity index 100% rename from mithril-common/src/test_utils/double/precomputed_kes_key.rs rename to mithril-common/src/test/double/precomputed_kes_key.rs diff --git a/mithril-common/src/test_utils/fixture_builder.rs b/mithril-common/src/test/fixture_builder.rs similarity index 99% rename from mithril-common/src/test_utils/fixture_builder.rs rename to mithril-common/src/test/fixture_builder.rs index eb0a8055869..e1136c03fdd 100644 --- a/mithril-common/src/test_utils/fixture_builder.rs +++ b/mithril-common/src/test/fixture_builder.rs @@ -8,7 +8,7 @@ use crate::{ tests_setup, tests_setup::setup_temp_directory_for_signer, }, entities::{PartyId, ProtocolParameters, Stake, StakeDistribution}, - test_utils::{double::fake_data, mithril_fixture::MithrilFixture}, + test::{double::fake_data, mithril_fixture::MithrilFixture}, }; use super::double::precomputed_kes_key; diff --git a/mithril-common/src/test_utils/memory_logger.rs b/mithril-common/src/test/memory_logger.rs similarity index 100% rename from mithril-common/src/test_utils/memory_logger.rs rename to mithril-common/src/test/memory_logger.rs diff --git a/mithril-common/src/test_utils/mithril_fixture.rs b/mithril-common/src/test/mithril_fixture.rs similarity index 100% rename from mithril-common/src/test_utils/mithril_fixture.rs rename to mithril-common/src/test/mithril_fixture.rs diff --git a/mithril-common/src/test_utils/mock_extensions.rs b/mithril-common/src/test/mock_extensions.rs similarity index 96% rename from mithril-common/src/test_utils/mock_extensions.rs rename to mithril-common/src/test/mock_extensions.rs index 26a858a9208..ce1d72d4d43 100644 --- a/mithril-common/src/test_utils/mock_extensions.rs +++ b/mithril-common/src/test/mock_extensions.rs @@ -17,7 +17,7 @@ impl MockBuilder { /// /// The type must be specified either: /// ``` - /// use mithril_common::test_utils::mock_extensions::MockBuilder; + /// use mithril_common::test::mock_extensions::MockBuilder; /// # #[derive(Default)] struct MockType {}; /// /// // from the builder generic diff --git a/mithril-common/src/test_utils/mod.rs b/mithril-common/src/test/mod.rs similarity index 96% rename from mithril-common/src/test_utils/mod.rs rename to mithril-common/src/test/mod.rs index 6e2e70115a1..e26a17be671 100644 --- a/mithril-common/src/test_utils/mod.rs +++ b/mithril-common/src/test/mod.rs @@ -70,8 +70,8 @@ where #[macro_export] macro_rules! assert_equivalent_macro { ( $expected:expr, $actual:expr ) => {{ - let expected = $crate::test_utils::as_sorted_vec($expected); - let actual = $crate::test_utils::as_sorted_vec($actual); + let expected = $crate::test::as_sorted_vec($expected); + let actual = $crate::test::as_sorted_vec($actual); assert_eq!(expected, actual); }}; } @@ -108,7 +108,7 @@ pub fn format_current_function_path(f: T) -> String { macro_rules! current_function { () => {{ fn f() {} - let name = $crate::test_utils::format_current_function_module(f); + let name = $crate::test::format_current_function_module(f); // The index found is the beginning of the '..', this is why we add 2. let function_name_index = name.rfind("::").map(|index| index + 2).unwrap_or(0); @@ -123,7 +123,7 @@ macro_rules! current_function_path { () => {{ fn f() {} - std::path::PathBuf::from($crate::test_utils::format_current_function_path(f)) + std::path::PathBuf::from($crate::test::format_current_function_path(f)) }}; } pub use current_function_path; diff --git a/mithril-common/src/test_utils/temp_dir.rs b/mithril-common/src/test/temp_dir.rs similarity index 95% rename from mithril-common/src/test_utils/temp_dir.rs rename to mithril-common/src/test/temp_dir.rs index 1f06939c43c..328f9037344 100644 --- a/mithril-common/src/test_utils/temp_dir.rs +++ b/mithril-common/src/test/temp_dir.rs @@ -82,7 +82,7 @@ impl TempDir { /// /// Equivalent to: /// ``` - /// # use crate::mithril_common::test_utils::TempDir; + /// # use crate::mithril_common::test::TempDir; /// TempDir::new("module", "name").build(); /// ``` pub fn create, N: Into>(module: M, name: N) -> PathBuf { @@ -94,7 +94,7 @@ impl TempDir { /// /// Equivalent to: /// ``` - /// # use crate::mithril_common::test_utils::TempDir; + /// # use crate::mithril_common::test::TempDir; /// TempDir::new("module", "name").generate_shorter_path().build(); /// ``` pub fn create_with_short_path, N: Into>(module: M, name: N) -> PathBuf { @@ -117,10 +117,10 @@ impl TempDir { macro_rules! temp_dir { () => {{ fn f() {} - let current_function_path = $crate::test_utils::format_current_function_path(f); + let current_function_path = $crate::test::format_current_function_path(f); let current_function_path = current_function_path.replace("/tests/", "/"); - $crate::test_utils::TempDir::new(current_function_path, "").build_path() + $crate::test::TempDir::new(current_function_path, "").build_path() }}; } pub use temp_dir; @@ -130,10 +130,10 @@ pub use temp_dir; macro_rules! temp_dir_create { () => {{ fn f() {} - let current_function_path = $crate::test_utils::format_current_function_path(f); + let current_function_path = $crate::test::format_current_function_path(f); let current_function_path = current_function_path.replace("/tests/", "/"); - $crate::test_utils::TempDir::new(current_function_path, "").build() + $crate::test::TempDir::new(current_function_path, "").build() }}; } pub use temp_dir_create; diff --git a/mithril-relay/src/relay/aggregator.rs b/mithril-relay/src/relay/aggregator.rs index 0d25c4c829f..bc958f67978 100644 --- a/mithril-relay/src/relay/aggregator.rs +++ b/mithril-relay/src/relay/aggregator.rs @@ -154,7 +154,7 @@ impl AggregatorRelay { #[cfg(test)] mod tests { use httpmock::MockServer; - use mithril_common::test_utils::double::Dummy; + use mithril_common::test::double::Dummy; use crate::test_tools::TestLogger; diff --git a/mithril-relay/src/relay/signer.rs b/mithril-relay/src/relay/signer.rs index 8b429ee6cf3..c1bdb20b206 100644 --- a/mithril-relay/src/relay/signer.rs +++ b/mithril-relay/src/relay/signer.rs @@ -398,7 +398,7 @@ mod tests { Method::{GET, POST}, MockServer, }; - use mithril_common::test_utils::double::Dummy; + use mithril_common::test::double::Dummy; use tokio::sync::mpsc::error::TryRecvError; use crate::{repeater, test_tools::TestLogger}; diff --git a/mithril-relay/tests/register_signer_signature.rs b/mithril-relay/tests/register_signer_signature.rs index 7c58670c008..24e4d4d5801 100644 --- a/mithril-relay/tests/register_signer_signature.rs +++ b/mithril-relay/tests/register_signer_signature.rs @@ -2,7 +2,7 @@ use std::{sync::Arc, time::Duration}; use libp2p::{Multiaddr, gossipsub}; use mithril_common::messages::{RegisterSignatureMessageHttp, RegisterSignerMessage}; -use mithril_common::test_utils::double::Dummy; +use mithril_common::test::double::Dummy; use mithril_relay::{ PassiveRelay, SignerRelay, SignerRelayMode, p2p::{BroadcastMessage, PeerBehaviourEvent, PeerEvent}, diff --git a/mithril-signer/src/database/repository/signed_beacon_repository.rs b/mithril-signer/src/database/repository/signed_beacon_repository.rs index 8848ef86795..d8e43d877ff 100644 --- a/mithril-signer/src/database/repository/signed_beacon_repository.rs +++ b/mithril-signer/src/database/repository/signed_beacon_repository.rs @@ -90,7 +90,7 @@ mod tests { use mithril_common::entities::{ BlockNumber, Epoch, SignedEntityConfig, SignedEntityTypeDiscriminants, TimePoint, }; - use mithril_common::test_utils::double::Dummy; + use mithril_common::test::double::Dummy; use mithril_persistence::sqlite::ConnectionExtensions; use crate::database::query::GetSignedBeaconQuery; diff --git a/mithril-signer/src/database/tests/protocol_initializer.rs b/mithril-signer/src/database/tests/protocol_initializer.rs index c5ccb847c8a..f41179fe914 100644 --- a/mithril-signer/src/database/tests/protocol_initializer.rs +++ b/mithril-signer/src/database/tests/protocol_initializer.rs @@ -1,6 +1,6 @@ use std::sync::Arc; -use mithril_common::test_utils::double::fake_data; +use mithril_common::test::double::fake_data; use mithril_common::{crypto_helper::ProtocolInitializer, entities::Epoch}; use mithril_persistence::sqlite::{ConnectionBuilder, ConnectionExtensions}; diff --git a/mithril-signer/src/dependency_injection/builder.rs b/mithril-signer/src/dependency_injection/builder.rs index 78ccc696f7b..65980f6cff0 100644 --- a/mithril-signer/src/dependency_injection/builder.rs +++ b/mithril-signer/src/dependency_injection/builder.rs @@ -507,8 +507,8 @@ mod tests { use mithril_cardano_node_chain::test::double::FakeChainObserver; use mithril_cardano_node_internal_database::test::double::DumbImmutableFileObserver; - use mithril_common::test_utils::double::Dummy; - use mithril_common::{entities::TimePoint, test_utils::TempDir}; + use mithril_common::test::double::Dummy; + use mithril_common::{entities::TimePoint, test::TempDir}; use crate::test_tools::TestLogger; diff --git a/mithril-signer/src/entities/signer_epoch_settings.rs b/mithril-signer/src/entities/signer_epoch_settings.rs index 490cd46f1f6..c128febf297 100644 --- a/mithril-signer/src/entities/signer_epoch_settings.rs +++ b/mithril-signer/src/entities/signer_epoch_settings.rs @@ -25,10 +25,10 @@ pub struct SignerEpochSettings { } #[cfg(test)] -impl mithril_common::test_utils::double::Dummy for SignerEpochSettings { +impl mithril_common::test::double::Dummy for SignerEpochSettings { /// Create a dummy `SignerEpochSettings` fn dummy() -> SignerEpochSettings { - use mithril_common::test_utils::double::fake_data; + use mithril_common::test::double::fake_data; // Beacon let beacon = fake_data::beacon(); diff --git a/mithril-signer/src/lib.rs b/mithril-signer/src/lib.rs index cc54072d6e7..f84b5299ef7 100644 --- a/mithril-signer/src/lib.rs +++ b/mithril-signer/src/lib.rs @@ -48,7 +48,7 @@ pub(crate) mod test_tools { use slog_async::Async; use slog_term::{CompactFormat, PlainDecorator}; - use mithril_common::test_utils::{MemoryDrainForTest, MemoryDrainForTestInspector}; + use mithril_common::test::{MemoryDrainForTest, MemoryDrainForTestInspector}; pub struct TestLogger; impl TestLogger { diff --git a/mithril-signer/src/message_adapters/from_epoch_settings.rs b/mithril-signer/src/message_adapters/from_epoch_settings.rs index d9cb5a61a5f..5c8d8d764cc 100644 --- a/mithril-signer/src/message_adapters/from_epoch_settings.rs +++ b/mithril-signer/src/message_adapters/from_epoch_settings.rs @@ -29,7 +29,7 @@ impl TryFromMessageAdapter for FromEp #[cfg(test)] mod tests { - use mithril_common::test_utils::double::Dummy; + use mithril_common::test::double::Dummy; use super::*; diff --git a/mithril-signer/src/message_adapters/to_register_signature_message.rs b/mithril-signer/src/message_adapters/to_register_signature_message.rs index 92fbba997f5..07b4b90840c 100644 --- a/mithril-signer/src/message_adapters/to_register_signature_message.rs +++ b/mithril-signer/src/message_adapters/to_register_signature_message.rs @@ -37,7 +37,7 @@ impl #[cfg(test)] mod tests { use mithril_common::entities::{CardanoDbBeacon, Epoch}; - use mithril_common::test_utils::double::fake_data; + use mithril_common::test::double::fake_data; use super::*; diff --git a/mithril-signer/src/message_adapters/to_register_signer_message.rs b/mithril-signer/src/message_adapters/to_register_signer_message.rs index a50370315b7..87de5b83978 100644 --- a/mithril-signer/src/message_adapters/to_register_signer_message.rs +++ b/mithril-signer/src/message_adapters/to_register_signer_message.rs @@ -46,7 +46,7 @@ impl TryToMessageAdapter<(Epoch, Signer), RegisterSignerMessage> #[cfg(test)] mod tests { - use mithril_common::test_utils::double::fake_data; + use mithril_common::test::double::fake_data; use super::*; diff --git a/mithril-signer/src/runtime/runner.rs b/mithril-signer/src/runtime/runner.rs index 98053e39603..f9baee012fa 100644 --- a/mithril-signer/src/runtime/runner.rs +++ b/mithril-signer/src/runtime/runner.rs @@ -353,7 +353,7 @@ mod tests { CardanoTransactionsSignableBuilder, MithrilSignableBuilderService, MithrilStakeDistributionSignableBuilder, SignableBuilderServiceDependencies, }, - test_utils::{ + test::{ MithrilFixtureBuilder, double::{Dummy, fake_data}, }, diff --git a/mithril-signer/src/runtime/state_machine.rs b/mithril-signer/src/runtime/state_machine.rs index a4a13815a1a..fb543e9006c 100644 --- a/mithril-signer/src/runtime/state_machine.rs +++ b/mithril-signer/src/runtime/state_machine.rs @@ -477,7 +477,7 @@ mod tests { use mockall::predicate; use mithril_common::entities::{ChainPoint, Epoch, ProtocolMessage, SignedEntityType}; - use mithril_common::test_utils::double::{Dummy, fake_data}; + use mithril_common::test::double::{Dummy, fake_data}; use crate::runtime::runner::MockSignerRunner; use crate::services::AggregatorClientError; diff --git a/mithril-signer/src/services/aggregator_client.rs b/mithril-signer/src/services/aggregator_client.rs index c1d3a09b45c..0ab757dd185 100644 --- a/mithril-signer/src/services/aggregator_client.rs +++ b/mithril-signer/src/services/aggregator_client.rs @@ -380,7 +380,7 @@ impl AggregatorClient for AggregatorHTTPClient { #[cfg(test)] pub(crate) mod dumb { - use mithril_common::test_utils::double::Dummy; + use mithril_common::test::double::Dummy; use tokio::sync::RwLock; use super::*; @@ -473,7 +473,7 @@ mod tests { use mithril_common::api_version::DummyApiVersionDiscriminantSource; use mithril_common::entities::Epoch; use mithril_common::messages::TryFromMessageAdapter; - use mithril_common::test_utils::{ + use mithril_common::test::{ MemoryDrainForTestInspector, double::{Dummy, fake_data}, }; diff --git a/mithril-signer/src/services/cardano_transactions/importer/importer_with_vacuum.rs b/mithril-signer/src/services/cardano_transactions/importer/importer_with_vacuum.rs index b0a4eac4e05..1b15cbdea04 100644 --- a/mithril-signer/src/services/cardano_transactions/importer/importer_with_vacuum.rs +++ b/mithril-signer/src/services/cardano_transactions/importer/importer_with_vacuum.rs @@ -55,7 +55,7 @@ mod tests { use mockall::mock; use sqlite::Connection; - use mithril_common::test_utils::TempDir; + use mithril_common::test::TempDir; use mithril_persistence::sqlite::SqliteConnection; use crate::test_tools::TestLogger; diff --git a/mithril-signer/src/services/cardano_transactions/preloader_checker.rs b/mithril-signer/src/services/cardano_transactions/preloader_checker.rs index cf118cf3fe9..5343eb171ea 100644 --- a/mithril-signer/src/services/cardano_transactions/preloader_checker.rs +++ b/mithril-signer/src/services/cardano_transactions/preloader_checker.rs @@ -43,7 +43,7 @@ mod tests { use mithril_common::{ entities::SignedEntityTypeDiscriminants, messages::AggregatorFeaturesMessage, - test_utils::double::Dummy, + test::double::Dummy, }; use crate::services::{AggregatorClientError, MockAggregatorClient}; diff --git a/mithril-signer/src/services/certifier.rs b/mithril-signer/src/services/certifier.rs index bbf78675a6a..8d100e4b9aa 100644 --- a/mithril-signer/src/services/certifier.rs +++ b/mithril-signer/src/services/certifier.rs @@ -156,7 +156,7 @@ mod tests { CardanoTransactionsSigningConfig, ChainPoint, Epoch, ProtocolMessagePartKey, SignedEntityTypeDiscriminants, }; - use mithril_common::test_utils::double::{Dummy, fake_data}; + use mithril_common::test::double::{Dummy, fake_data}; use crate::services::{MockSignaturePublisher, MockSingleSigner}; diff --git a/mithril-signer/src/services/epoch_service.rs b/mithril-signer/src/services/epoch_service.rs index b3fe1aaf598..e56cd1b4ea0 100644 --- a/mithril-signer/src/services/epoch_service.rs +++ b/mithril-signer/src/services/epoch_service.rs @@ -340,7 +340,7 @@ impl MithrilEpochService { /// `TEST ONLY` - Set all data to either default values, empty values, or fake values /// if no default/empty can be set. pub fn set_data_to_default_or_fake(mut self, epoch: Epoch) -> Self { - use mithril_common::test_utils::double::fake_data; + use mithril_common::test::double::fake_data; let epoch_data = EpochData { epoch, @@ -428,7 +428,7 @@ mod tests { use tokio::sync::RwLock; use mithril_common::entities::{Epoch, StakeDistribution}; - use mithril_common::test_utils::{ + use mithril_common::test::{ MithrilFixtureBuilder, double::{Dummy, fake_data}, }; diff --git a/mithril-signer/src/services/signable_builder/signable_seed_builder.rs b/mithril-signer/src/services/signable_builder/signable_seed_builder.rs index a32315922e6..33d6f14387a 100644 --- a/mithril-signer/src/services/signable_builder/signable_seed_builder.rs +++ b/mithril-signer/src/services/signable_builder/signable_seed_builder.rs @@ -107,7 +107,7 @@ impl SignableSeedBuilder for SignerSignableSeedBuilder { mod tests { use mithril_common::{ - entities::Epoch, entities::ProtocolParameters, test_utils::MithrilFixtureBuilder, + entities::Epoch, entities::ProtocolParameters, test::MithrilFixtureBuilder, }; use crate::{ diff --git a/mithril-signer/src/services/signature_publisher/delayer.rs b/mithril-signer/src/services/signature_publisher/delayer.rs index 0d20383aad2..901cfc91001 100644 --- a/mithril-signer/src/services/signature_publisher/delayer.rs +++ b/mithril-signer/src/services/signature_publisher/delayer.rs @@ -76,7 +76,7 @@ impl SignaturePublisher for SignaturePublisherDelayer { #[cfg(test)] mod tests { - use mithril_common::{entities::Epoch, test_utils::double::fake_data}; + use mithril_common::{entities::Epoch, test::double::fake_data}; use crate::{services::MockSignaturePublisher, test_tools::TestLogger}; diff --git a/mithril-signer/src/services/signature_publisher/dmq.rs b/mithril-signer/src/services/signature_publisher/dmq.rs index 9362636a686..68c8ea5f61b 100644 --- a/mithril-signer/src/services/signature_publisher/dmq.rs +++ b/mithril-signer/src/services/signature_publisher/dmq.rs @@ -46,7 +46,7 @@ impl SignaturePublisher for SignaturePublisherDmq { #[cfg(test)] mod tests { - use mithril_common::test_utils::double::{Dummy, fake_data}; + use mithril_common::test::double::{Dummy, fake_data}; use mithril_dmq::test::double::DmqPublisherFake; use super::*; diff --git a/mithril-signer/src/services/signature_publisher/retrier.rs b/mithril-signer/src/services/signature_publisher/retrier.rs index c58593d61c2..bd0f47a76fd 100644 --- a/mithril-signer/src/services/signature_publisher/retrier.rs +++ b/mithril-signer/src/services/signature_publisher/retrier.rs @@ -85,7 +85,7 @@ impl SignaturePublisher for SignaturePublisherRetrier { #[cfg(test)] mod tests { - use mithril_common::{entities::Epoch, test_utils::double::fake_data}; + use mithril_common::{entities::Epoch, test::double::fake_data}; use crate::services::MockSignaturePublisher; diff --git a/mithril-signer/src/services/single_signer.rs b/mithril-signer/src/services/single_signer.rs index f2d3c7a4344..4cb916af955 100644 --- a/mithril-signer/src/services/single_signer.rs +++ b/mithril-signer/src/services/single_signer.rs @@ -173,7 +173,7 @@ mod tests { use crate::test_tools::TestLogger; use mithril_common::crypto_helper::ProtocolClerk; use mithril_common::entities::{Epoch, ProtocolMessagePartKey}; - use mithril_common::test_utils::MithrilFixtureBuilder; + use mithril_common::test::MithrilFixtureBuilder; use mithril_persistence::store::StakeStorer; use super::*; diff --git a/mithril-signer/src/services/upkeep_service.rs b/mithril-signer/src/services/upkeep_service.rs index aa1f8dd7fc5..958e726a754 100644 --- a/mithril-signer/src/services/upkeep_service.rs +++ b/mithril-signer/src/services/upkeep_service.rs @@ -143,7 +143,7 @@ mod tests { use mockall::predicate::eq; use mithril_common::entities::SignedEntityTypeDiscriminants; - use mithril_common::test_utils::TempDir; + use mithril_common::test::TempDir; use crate::database::test_helper::{ cardano_tx_db_connection, cardano_tx_db_file_connection, main_db_connection, diff --git a/mithril-signer/tests/create_cardano_transaction_single_signature.rs b/mithril-signer/tests/create_cardano_transaction_single_signature.rs index 46489c1ccdc..a853a6bdaeb 100644 --- a/mithril-signer/tests/create_cardano_transaction_single_signature.rs +++ b/mithril-signer/tests/create_cardano_transaction_single_signature.rs @@ -9,7 +9,7 @@ use mithril_common::{ }, SignedEntityTypeDiscriminants, SlotNumber, TimePoint, }, - test_utils::MithrilFixtureBuilder, + test::MithrilFixtureBuilder, }; use test_extensions::StateMachineTester; diff --git a/mithril-signer/tests/create_immutable_files_full_single_signature.rs b/mithril-signer/tests/create_immutable_files_full_single_signature.rs index 047ceeb0c3a..250ed7cd871 100644 --- a/mithril-signer/tests/create_immutable_files_full_single_signature.rs +++ b/mithril-signer/tests/create_immutable_files_full_single_signature.rs @@ -7,7 +7,7 @@ use mithril_common::entities::{CardanoDbBeacon, SignedEntityTypeDiscriminants}; use mithril_common::{ crypto_helper::tests_setup, entities::{BlockNumber, ChainPoint, Epoch, SlotNumber, TimePoint}, - test_utils::MithrilFixtureBuilder, + test::MithrilFixtureBuilder, }; use test_extensions::StateMachineTester; diff --git a/mithril-signer/tests/era_switch.rs b/mithril-signer/tests/era_switch.rs index 70578005649..87cfc84dec9 100644 --- a/mithril-signer/tests/era_switch.rs +++ b/mithril-signer/tests/era_switch.rs @@ -3,7 +3,7 @@ mod test_extensions; use mithril_common::{ crypto_helper::tests_setup, entities::{BlockNumber, ChainPoint, Epoch, SlotNumber, SupportedEra, TimePoint}, - test_utils::{MithrilFixtureBuilder, double::Dummy}, + test::{MithrilFixtureBuilder, double::Dummy}, }; use mithril_era::EraMarker; use test_extensions::StateMachineTester; diff --git a/mithril-signer/tests/test_extensions/certificate_handler.rs b/mithril-signer/tests/test_extensions/certificate_handler.rs index 0040d5dc455..377d1eda16f 100644 --- a/mithril-signer/tests/test_extensions/certificate_handler.rs +++ b/mithril-signer/tests/test_extensions/certificate_handler.rs @@ -10,7 +10,7 @@ use mithril_common::{ SignedEntityType, SignedEntityTypeDiscriminants, Signer, SingleSignature, TimePoint, }, messages::AggregatorFeaturesMessage, - test_utils::double::{Dummy, fake_data}, + test::double::{Dummy, fake_data}, }; use mithril_ticker::{MithrilTickerService, TickerService}; @@ -170,7 +170,7 @@ mod tests { use mithril_cardano_node_chain::test::double::FakeChainObserver; use mithril_cardano_node_internal_database::test::double::DumbImmutableFileObserver; use mithril_common::entities::{BlockNumber, ChainPoint}; - use mithril_common::test_utils::double::fake_data; + use mithril_common::test::double::fake_data; use super::*; diff --git a/mithril-signer/tests/test_extensions/state_machine_tester.rs b/mithril-signer/tests/test_extensions/state_machine_tester.rs index a755eb716bd..43dd22662b4 100644 --- a/mithril-signer/tests/test_extensions/state_machine_tester.rs +++ b/mithril-signer/tests/test_extensions/state_machine_tester.rs @@ -39,7 +39,7 @@ use mithril_common::{ MithrilSignableBuilderService, MithrilStakeDistributionSignableBuilder, SignableBuilderServiceDependencies, }, - test_utils::double::Dummy, + test::double::Dummy, }; use mithril_era::{EraChecker, EraMarker, EraReader, adapters::EraReaderDummyAdapter}; use mithril_persistence::{ diff --git a/mithril-test-lab/mithril-end-to-end/src/bin/load-aggregator/main.rs b/mithril-test-lab/mithril-end-to-end/src/bin/load-aggregator/main.rs index f3277bfe435..98ade94adfb 100644 --- a/mithril-test-lab/mithril-end-to-end/src/bin/load-aggregator/main.rs +++ b/mithril-test-lab/mithril-end-to-end/src/bin/load-aggregator/main.rs @@ -7,7 +7,7 @@ use mithril_cardano_node_internal_database::test::{DummyCardanoDb, DummyCardanoD use mithril_common::{ StdResult, entities::{Epoch, ProtocolParameters}, - test_utils::MithrilFixture, + test::MithrilFixture, }; use mithril_end_to_end::{ diff --git a/mithril-test-lab/mithril-end-to-end/src/stress_test/aggregator_helpers.rs b/mithril-test-lab/mithril-end-to-end/src/stress_test/aggregator_helpers.rs index 09a4de4a38b..43a33667142 100644 --- a/mithril-test-lab/mithril-end-to-end/src/stress_test/aggregator_helpers.rs +++ b/mithril-test-lab/mithril-end-to-end/src/stress_test/aggregator_helpers.rs @@ -1,7 +1,7 @@ use slog_scope::info; use std::time::Duration; -use mithril_common::{StdResult, entities::Epoch, test_utils::MithrilFixture}; +use mithril_common::{StdResult, entities::Epoch, test::MithrilFixture}; use crate::{ Aggregator, AggregatorConfig, diff --git a/mithril-test-lab/mithril-end-to-end/src/stress_test/fake_chain.rs b/mithril-test-lab/mithril-end-to-end/src/stress_test/fake_chain.rs index f7abcae034b..5cba5745d32 100644 --- a/mithril-test-lab/mithril-end-to-end/src/stress_test/fake_chain.rs +++ b/mithril-test-lab/mithril-end-to-end/src/stress_test/fake_chain.rs @@ -1,7 +1,7 @@ use slog_scope::debug; use std::{fs::File, io::Write, path::Path}; -use mithril_common::{entities::Epoch, test_utils::MithrilFixture}; +use mithril_common::{entities::Epoch, test::MithrilFixture}; pub fn set_stake_distribution( mock_stake_distribution_file_path: &Path, diff --git a/mithril-test-lab/mithril-end-to-end/src/stress_test/payload_builder.rs b/mithril-test-lab/mithril-end-to-end/src/stress_test/payload_builder.rs index e620f2a2c91..e8f82902b07 100644 --- a/mithril-test-lab/mithril-end-to-end/src/stress_test/payload_builder.rs +++ b/mithril-test-lab/mithril-end-to-end/src/stress_test/payload_builder.rs @@ -14,7 +14,7 @@ use mithril_common::{ }, messages::{RegisterSignatureMessageHttp, RegisterSignerMessage}, protocol::ToMessage, - test_utils::{MithrilFixture, MithrilFixtureBuilder}, + test::{MithrilFixture, MithrilFixtureBuilder}, }; /// Generate signer data diff --git a/mithril-test-lab/mithril-end-to-end/src/utils/file_utils.rs b/mithril-test-lab/mithril-end-to-end/src/utils/file_utils.rs index 1de1afa855f..c1efc7dd20a 100644 --- a/mithril-test-lab/mithril-end-to-end/src/utils/file_utils.rs +++ b/mithril-test-lab/mithril-end-to-end/src/utils/file_utils.rs @@ -66,7 +66,7 @@ pub async fn last_errors(file_path: &Path, number_of_error: u64) -> StdResult Date: Tue, 22 Jul 2025 17:56:11 +0200 Subject: [PATCH 03/15] refactor(common): move all builder in `mithril_common::test` to `test::builder` --- .../repository/cardano_transaction_repository.rs | 2 +- .../query/certificate/get_certificate.rs | 2 +- .../get_signer_registration.rs | 2 +- .../insert_or_replace_signer_registration.rs | 2 +- .../src/database/record/signer_registration.rs | 2 +- .../src/dependency_injection/containers/serve.rs | 2 +- .../src/http_server/routes/signer_routes.rs | 2 +- .../src/http_server/routes/status.rs | 2 +- mithril-aggregator/src/multi_signer.rs | 2 +- mithril-aggregator/src/runtime/runner.rs | 2 +- .../synchronizer_service.rs | 2 +- .../src/services/certifier/certifier_service.rs | 5 ++++- mithril-aggregator/src/services/epoch_service.rs | 7 +++++-- mithril-aggregator/src/services/message.rs | 2 +- mithril-aggregator/src/services/prover.rs | 2 +- .../signable_builder/signable_seed_builder.rs | 5 ++++- .../src/services/signer_registration/follower.rs | 2 +- .../src/services/signer_registration/leader.rs | 2 +- .../src/services/signer_registration/verifier.rs | 2 +- mithril-aggregator/src/tools/genesis.rs | 2 +- .../cardano_stake_distribution_verify_stakes.rs | 2 +- mithril-aggregator/tests/certificate_chain.rs | 2 +- mithril-aggregator/tests/create_certificate.rs | 2 +- .../tests/create_certificate_follower.rs | 5 ++++- ...reate_certificate_with_buffered_signatures.rs | 2 +- mithril-aggregator/tests/era_checker.rs | 2 +- mithril-aggregator/tests/genesis_to_signing.rs | 2 +- .../tests/open_message_expiration.rs | 2 +- .../tests/open_message_newer_exists.rs | 2 +- mithril-aggregator/tests/prove_transactions.rs | 2 +- .../tests/test_extensions/runtime_tester.rs | 4 +++- mithril-client/src/certificate_client/verify.rs | 4 ++-- .../src/certificate_chain/certificate_genesis.rs | 2 +- .../certificate_chain/certificate_verifier.rs | 5 +++-- mithril-common/src/crypto_helper/conversions.rs | 2 +- mithril-common/src/crypto_helper/tests_setup.rs | 5 ++++- .../src/entities/mithril_stake_distribution.rs | 2 +- mithril-common/src/entities/signer.rs | 2 +- mithril-common/src/entities/single_signature.rs | 4 ++-- mithril-common/src/protocol/multi_signer.rs | 6 ++++-- mithril-common/src/protocol/signer_builder.rs | 4 ++-- mithril-common/src/protocol/single_signer.rs | 2 +- .../src/signable_builder/cardano_transactions.rs | 2 +- .../cardano_transactions_builder.rs | 4 ++-- .../{ => builder}/certificate_chain_builder.rs | 11 +++++++---- .../src/test/{ => builder}/fixture_builder.rs | 7 ++++--- .../src/test/{ => builder}/mithril_fixture.rs | 0 mithril-common/src/test/builder/mod.rs | 16 ++++++++++++++++ mithril-common/src/test/double/fake_data.rs | 2 +- .../src/test/double/precomputed_kes_key.rs | 4 ++-- mithril-common/src/test/mod.rs | 12 +----------- mithril-signer/src/runtime/runner.rs | 2 +- mithril-signer/src/services/epoch_service.rs | 2 +- .../signable_builder/signable_seed_builder.rs | 2 +- mithril-signer/src/services/single_signer.rs | 2 +- ...reate_cardano_transaction_single_signature.rs | 2 +- ...eate_immutable_files_full_single_signature.rs | 2 +- mithril-signer/tests/era_switch.rs | 2 +- .../src/bin/load-aggregator/main.rs | 2 +- .../src/stress_test/aggregator_helpers.rs | 2 +- .../src/stress_test/fake_chain.rs | 2 +- .../src/stress_test/payload_builder.rs | 2 +- 62 files changed, 113 insertions(+), 83 deletions(-) rename mithril-common/src/test/{ => builder}/cardano_transactions_builder.rs (98%) rename mithril-common/src/test/{ => builder}/certificate_chain_builder.rs (99%) rename mithril-common/src/test/{ => builder}/fixture_builder.rs (99%) rename mithril-common/src/test/{ => builder}/mithril_fixture.rs (100%) create mode 100644 mithril-common/src/test/builder/mod.rs diff --git a/internal/mithril-persistence/src/database/repository/cardano_transaction_repository.rs b/internal/mithril-persistence/src/database/repository/cardano_transaction_repository.rs index e2050e89f67..63e7cd37e4f 100644 --- a/internal/mithril-persistence/src/database/repository/cardano_transaction_repository.rs +++ b/internal/mithril-persistence/src/database/repository/cardano_transaction_repository.rs @@ -325,7 +325,7 @@ impl BlockRangeRootRetriever for CardanoTransactionRepositor #[cfg(test)] mod tests { - use mithril_common::test::CardanoTransactionsBuilder; + use mithril_common::test::builder::CardanoTransactionsBuilder; use crate::database::query::GetBlockRangeRootQuery; use crate::database::test_helper::cardano_tx_db_connection; diff --git a/mithril-aggregator/src/database/query/certificate/get_certificate.rs b/mithril-aggregator/src/database/query/certificate/get_certificate.rs index 697ef75f3b1..2474c135820 100644 --- a/mithril-aggregator/src/database/query/certificate/get_certificate.rs +++ b/mithril-aggregator/src/database/query/certificate/get_certificate.rs @@ -61,7 +61,7 @@ impl Query for GetCertificateRecordQuery { mod tests { use mithril_common::crypto_helper::ProtocolParameters; use mithril_common::crypto_helper::tests_setup::setup_certificate_chain; - use mithril_common::test::CertificateChainBuilder; + use mithril_common::test::builder::CertificateChainBuilder; use mithril_persistence::sqlite::ConnectionExtensions; diff --git a/mithril-aggregator/src/database/query/signer_registration/get_signer_registration.rs b/mithril-aggregator/src/database/query/signer_registration/get_signer_registration.rs index d2e02f7d6c0..190622e74ce 100644 --- a/mithril-aggregator/src/database/query/signer_registration/get_signer_registration.rs +++ b/mithril-aggregator/src/database/query/signer_registration/get_signer_registration.rs @@ -59,7 +59,7 @@ mod tests { use chrono::{DateTime, Utc}; use mithril_common::entities::SignerWithStake; - use mithril_common::test::MithrilFixtureBuilder; + use mithril_common::test::builder::MithrilFixtureBuilder; use mithril_persistence::sqlite::ConnectionExtensions; use crate::database::test_helper::{insert_signer_registrations, main_db_connection}; diff --git a/mithril-aggregator/src/database/query/signer_registration/insert_or_replace_signer_registration.rs b/mithril-aggregator/src/database/query/signer_registration/insert_or_replace_signer_registration.rs index 8f9d50effdf..bebc696f8e7 100644 --- a/mithril-aggregator/src/database/query/signer_registration/insert_or_replace_signer_registration.rs +++ b/mithril-aggregator/src/database/query/signer_registration/insert_or_replace_signer_registration.rs @@ -63,7 +63,7 @@ impl Query for InsertOrReplaceSignerRegistrationRecordQuery { #[cfg(test)] mod tests { use mithril_common::entities::Epoch; - use mithril_common::test::MithrilFixtureBuilder; + use mithril_common::test::builder::MithrilFixtureBuilder; use mithril_persistence::sqlite::ConnectionExtensions; use crate::database::test_helper::main_db_connection; diff --git a/mithril-aggregator/src/database/record/signer_registration.rs b/mithril-aggregator/src/database/record/signer_registration.rs index 59bd9925db5..6e72169a167 100644 --- a/mithril-aggregator/src/database/record/signer_registration.rs +++ b/mithril-aggregator/src/database/record/signer_registration.rs @@ -172,7 +172,7 @@ impl SqLiteEntity for SignerRegistrationRecord { #[cfg(test)] mod tests { - use mithril_common::test::MithrilFixtureBuilder; + use mithril_common::test::builder::MithrilFixtureBuilder; use super::*; diff --git a/mithril-aggregator/src/dependency_injection/containers/serve.rs b/mithril-aggregator/src/dependency_injection/containers/serve.rs index 913d6b69923..b37d783aad5 100644 --- a/mithril-aggregator/src/dependency_injection/containers/serve.rs +++ b/mithril-aggregator/src/dependency_injection/containers/serve.rs @@ -10,7 +10,7 @@ use mithril_common::{ StakeDistribution, }, signable_builder::SignableBuilderService, - test::MithrilFixture, + test::builder::MithrilFixture, }; use mithril_era::{EraChecker, EraReader}; diff --git a/mithril-aggregator/src/http_server/routes/signer_routes.rs b/mithril-aggregator/src/http_server/routes/signer_routes.rs index f45e8166ebe..154d91c0ef7 100644 --- a/mithril-aggregator/src/http_server/routes/signer_routes.rs +++ b/mithril-aggregator/src/http_server/routes/signer_routes.rs @@ -272,7 +272,7 @@ mod tests { entities::Epoch, messages::RegisterSignerMessage, test::{ - MithrilFixtureBuilder, + builder::MithrilFixtureBuilder, double::{Dummy, fake_data}, }, }; diff --git a/mithril-aggregator/src/http_server/routes/status.rs b/mithril-aggregator/src/http_server/routes/status.rs index 30b9c47094d..c379d7a3d24 100644 --- a/mithril-aggregator/src/http_server/routes/status.rs +++ b/mithril-aggregator/src/http_server/routes/status.rs @@ -116,7 +116,7 @@ mod tests { use mithril_common::{ entities::{Epoch, ProtocolParameters, Stake}, test::{ - MithrilFixtureBuilder, + builder::MithrilFixtureBuilder, double::{Dummy, fake_data}, }, }; diff --git a/mithril-aggregator/src/multi_signer.rs b/mithril-aggregator/src/multi_signer.rs index 499851facef..5f8e093dc5f 100644 --- a/mithril-aggregator/src/multi_signer.rs +++ b/mithril-aggregator/src/multi_signer.rs @@ -147,7 +147,7 @@ mod tests { use mithril_common::entities::{CardanoDbBeacon, Epoch, SignedEntityType, SignerWithStake}; use mithril_common::protocol::ToMessage; use mithril_common::test::{ - MithrilFixtureBuilder, + builder::MithrilFixtureBuilder, double::{Dummy, fake_data}, }; diff --git a/mithril-aggregator/src/runtime/runner.rs b/mithril-aggregator/src/runtime/runner.rs index b2426b7dfd1..e9de8698a9a 100644 --- a/mithril-aggregator/src/runtime/runner.rs +++ b/mithril-aggregator/src/runtime/runner.rs @@ -550,7 +550,7 @@ pub mod tests { signable_builder::SignableBuilderService, temp_dir, test::{ - MithrilFixtureBuilder, + builder::MithrilFixtureBuilder, double::{Dummy, fake_data}, }, }; diff --git a/mithril-aggregator/src/services/certificate_chain_synchronizer/synchronizer_service.rs b/mithril-aggregator/src/services/certificate_chain_synchronizer/synchronizer_service.rs index 2a5ea803af1..2b67d3ee52f 100644 --- a/mithril-aggregator/src/services/certificate_chain_synchronizer/synchronizer_service.rs +++ b/mithril-aggregator/src/services/certificate_chain_synchronizer/synchronizer_service.rs @@ -228,7 +228,7 @@ mod tests { FakeCertificaterRetriever, MithrilCertificateVerifier, }; use mithril_common::test::{ - CertificateChainBuilder, CertificateChainFixture, + builder::{CertificateChainBuilder, CertificateChainFixture}, double::{fake_data, fake_keys}, mock_extensions::MockBuilder, }; diff --git a/mithril-aggregator/src/services/certifier/certifier_service.rs b/mithril-aggregator/src/services/certifier/certifier_service.rs index 79a37cf579c..04c7cb7be47 100644 --- a/mithril-aggregator/src/services/certifier/certifier_service.rs +++ b/mithril-aggregator/src/services/certifier/certifier_service.rs @@ -419,7 +419,10 @@ mod tests { use mithril_common::{ entities::{CardanoDbBeacon, ProtocolMessagePartKey}, temp_dir, - test::{MithrilFixture, MithrilFixtureBuilder, double::fake_data}, + test::{ + builder::{MithrilFixture, MithrilFixtureBuilder}, + double::fake_data, + }, }; use tokio::sync::RwLock; diff --git a/mithril-aggregator/src/services/epoch_service.rs b/mithril-aggregator/src/services/epoch_service.rs index 3b2e30b674b..09ba539d8db 100644 --- a/mithril-aggregator/src/services/epoch_service.rs +++ b/mithril-aggregator/src/services/epoch_service.rs @@ -635,7 +635,10 @@ impl FakeEpochServiceBuilder { #[cfg(test)] impl FakeEpochService { - pub fn from_fixture(epoch: Epoch, fixture: &mithril_common::test::MithrilFixture) -> Self { + pub fn from_fixture( + epoch: Epoch, + fixture: &mithril_common::test::builder::MithrilFixture, + ) -> Self { use mithril_common::entities::CardanoTransactionsSigningConfig; use mithril_common::test::double::Dummy; @@ -840,7 +843,7 @@ mod tests { BlockNumber, CardanoTransactionsSigningConfig, Stake, StakeDistribution, SupportedEra, }; use mithril_common::test::{ - MithrilFixture, MithrilFixtureBuilder, StakeDistributionGenerationMethod, + builder::{MithrilFixture, MithrilFixtureBuilder, StakeDistributionGenerationMethod}, double::{Dummy, fake_data}, }; diff --git a/mithril-aggregator/src/services/message.rs b/mithril-aggregator/src/services/message.rs index e5ddeac1ea5..37fb00dba68 100644 --- a/mithril-aggregator/src/services/message.rs +++ b/mithril-aggregator/src/services/message.rs @@ -437,7 +437,7 @@ mod tests { mod epoch_settings { use mithril_common::{ entities::{CardanoTransactionsSigningConfig, ProtocolParameters}, - test::MithrilFixtureBuilder, + test::builder::MithrilFixtureBuilder, }; use crate::{entities::AggregatorEpochSettings, services::FakeEpochServiceBuilder}; diff --git a/mithril-aggregator/src/services/prover.rs b/mithril-aggregator/src/services/prover.rs index 7c8615a9bce..70ea9a2287d 100644 --- a/mithril-aggregator/src/services/prover.rs +++ b/mithril-aggregator/src/services/prover.rs @@ -213,7 +213,7 @@ mod tests { MKMap, MKMapNode, MKTreeNode, MKTreeStoreInMemory, MKTreeStorer, }; use mithril_common::entities::CardanoTransaction; - use mithril_common::test::CardanoTransactionsBuilder; + use mithril_common::test::builder::CardanoTransactionsBuilder; use mockall::mock; use mockall::predicate::eq; diff --git a/mithril-aggregator/src/services/signable_builder/signable_seed_builder.rs b/mithril-aggregator/src/services/signable_builder/signable_seed_builder.rs index 2f474796058..d1ed66f8af5 100644 --- a/mithril-aggregator/src/services/signable_builder/signable_seed_builder.rs +++ b/mithril-aggregator/src/services/signable_builder/signable_seed_builder.rs @@ -58,7 +58,10 @@ impl SignableSeedBuilder for AggregatorSignableSeedBuilder { mod tests { use mithril_common::{ entities::Epoch, - test::{MithrilFixture, MithrilFixtureBuilder, double::Dummy}, + test::{ + builder::{MithrilFixture, MithrilFixtureBuilder}, + double::Dummy, + }, }; use crate::{entities::AggregatorEpochSettings, services::FakeEpochServiceBuilder}; diff --git a/mithril-aggregator/src/services/signer_registration/follower.rs b/mithril-aggregator/src/services/signer_registration/follower.rs index 2a5e8109781..1d2d4009204 100644 --- a/mithril-aggregator/src/services/signer_registration/follower.rs +++ b/mithril-aggregator/src/services/signer_registration/follower.rs @@ -180,7 +180,7 @@ mod tests { use mithril_common::messages::{ EpochSettingsMessage, SignerMessagePart, TryFromMessageAdapter, }; - use mithril_common::test::{MithrilFixtureBuilder, double::Dummy}; + use mithril_common::test::{builder::MithrilFixtureBuilder, double::Dummy}; use crate::{ database::{repository::SignerRegistrationStore, test_helper::main_db_connection}, diff --git a/mithril-aggregator/src/services/signer_registration/leader.rs b/mithril-aggregator/src/services/signer_registration/leader.rs index b3609d6d7d3..5a4ca839cbb 100644 --- a/mithril-aggregator/src/services/signer_registration/leader.rs +++ b/mithril-aggregator/src/services/signer_registration/leader.rs @@ -150,7 +150,7 @@ mod tests { use mithril_common::{ entities::{Epoch, Signer, SignerWithStake}, - test::MithrilFixtureBuilder, + test::builder::MithrilFixtureBuilder, }; use crate::{ diff --git a/mithril-aggregator/src/services/signer_registration/verifier.rs b/mithril-aggregator/src/services/signer_registration/verifier.rs index 2f08b7e14f2..7e0fb62f3c6 100644 --- a/mithril-aggregator/src/services/signer_registration/verifier.rs +++ b/mithril-aggregator/src/services/signer_registration/verifier.rs @@ -82,7 +82,7 @@ mod tests { use mithril_cardano_node_chain::test::double::FakeChainObserver; use mithril_common::{ entities::TimePoint, - test::{MithrilFixtureBuilder, double::Dummy}, + test::{builder::MithrilFixtureBuilder, double::Dummy}, }; use super::*; diff --git a/mithril-aggregator/src/tools/genesis.rs b/mithril-aggregator/src/tools/genesis.rs index c8ec03c93c8..257ca41e160 100644 --- a/mithril-aggregator/src/tools/genesis.rs +++ b/mithril-aggregator/src/tools/genesis.rs @@ -206,7 +206,7 @@ mod tests { ProtocolGenesisSecretKey, ProtocolGenesisSigner, ProtocolGenesisVerificationKey, ProtocolGenesisVerifier, }, - test::{MithrilFixtureBuilder, TempDir, double::fake_data}, + test::{TempDir, builder::MithrilFixtureBuilder, double::fake_data}, }; use std::{fs::read_to_string, path::PathBuf}; diff --git a/mithril-aggregator/tests/cardano_stake_distribution_verify_stakes.rs b/mithril-aggregator/tests/cardano_stake_distribution_verify_stakes.rs index 002bb085125..2dbe303d143 100644 --- a/mithril-aggregator/tests/cardano_stake_distribution_verify_stakes.rs +++ b/mithril-aggregator/tests/cardano_stake_distribution_verify_stakes.rs @@ -9,7 +9,7 @@ use mithril_common::{ SignedEntityTypeDiscriminants, SlotNumber, StakeDistribution, StakeDistributionParty, TimePoint, }, - test::MithrilFixtureBuilder, + test::builder::MithrilFixtureBuilder, }; use test_extensions::ExpectedMetrics; use test_extensions::{ExpectedCertificate, RuntimeTester, utilities::get_test_dir}; diff --git a/mithril-aggregator/tests/certificate_chain.rs b/mithril-aggregator/tests/certificate_chain.rs index 82a4d9afda5..dcf7ab2a62f 100644 --- a/mithril-aggregator/tests/certificate_chain.rs +++ b/mithril-aggregator/tests/certificate_chain.rs @@ -8,7 +8,7 @@ use mithril_common::{ TimePoint, }, temp_dir, - test::MithrilFixtureBuilder, + test::builder::MithrilFixtureBuilder, }; use test_extensions::{ ExpectedCertificate, ExpectedMetrics, RuntimeTester, utilities::get_test_dir, diff --git a/mithril-aggregator/tests/create_certificate.rs b/mithril-aggregator/tests/create_certificate.rs index e9abe023d4e..b6a34970664 100644 --- a/mithril-aggregator/tests/create_certificate.rs +++ b/mithril-aggregator/tests/create_certificate.rs @@ -8,7 +8,7 @@ use mithril_common::{ StakeDistributionParty, TimePoint, }, temp_dir, - test::MithrilFixtureBuilder, + test::builder::MithrilFixtureBuilder, }; use test_extensions::{ ExpectedCertificate, ExpectedMetrics, RuntimeTester, utilities::get_test_dir, diff --git a/mithril-aggregator/tests/create_certificate_follower.rs b/mithril-aggregator/tests/create_certificate_follower.rs index 16a4fb6dbd0..371fe067b06 100644 --- a/mithril-aggregator/tests/create_certificate_follower.rs +++ b/mithril-aggregator/tests/create_certificate_follower.rs @@ -9,7 +9,10 @@ use mithril_common::{ SignedEntityTypeDiscriminants, SlotNumber, StakeDistributionParty, TimePoint, }, temp_dir, - test::{MithrilFixture, MithrilFixtureBuilder, StakeDistributionGenerationMethod, TempDir}, + test::{ + TempDir, + builder::{MithrilFixture, MithrilFixtureBuilder, StakeDistributionGenerationMethod}, + }, }; use test_extensions::{ExpectedCertificate, RuntimeTester, utilities::get_test_dir}; diff --git a/mithril-aggregator/tests/create_certificate_with_buffered_signatures.rs b/mithril-aggregator/tests/create_certificate_with_buffered_signatures.rs index dcfab8aa15c..073b1e5b587 100644 --- a/mithril-aggregator/tests/create_certificate_with_buffered_signatures.rs +++ b/mithril-aggregator/tests/create_certificate_with_buffered_signatures.rs @@ -8,7 +8,7 @@ use mithril_common::{ TimePoint, }, temp_dir, - test::MithrilFixtureBuilder, + test::builder::MithrilFixtureBuilder, }; use test_extensions::{ ExpectedCertificate, ExpectedMetrics, RuntimeTester, utilities::get_test_dir, diff --git a/mithril-aggregator/tests/era_checker.rs b/mithril-aggregator/tests/era_checker.rs index 72fb79e4582..36202f14da9 100644 --- a/mithril-aggregator/tests/era_checker.rs +++ b/mithril-aggregator/tests/era_checker.rs @@ -5,7 +5,7 @@ use mithril_common::{ BlockNumber, ChainPoint, Epoch, ProtocolParameters, SlotNumber, SupportedEra, TimePoint, }, temp_dir, - test::{MithrilFixtureBuilder, double::Dummy}, + test::{builder::MithrilFixtureBuilder, double::Dummy}, }; use mithril_era::EraMarker; diff --git a/mithril-aggregator/tests/genesis_to_signing.rs b/mithril-aggregator/tests/genesis_to_signing.rs index dd6a01c8f87..e47dba18f5a 100644 --- a/mithril-aggregator/tests/genesis_to_signing.rs +++ b/mithril-aggregator/tests/genesis_to_signing.rs @@ -4,7 +4,7 @@ use mithril_aggregator::ServeCommandConfiguration; use mithril_common::{ entities::{BlockNumber, ChainPoint, Epoch, ProtocolParameters, SlotNumber, TimePoint}, temp_dir, - test::MithrilFixtureBuilder, + test::builder::MithrilFixtureBuilder, }; use test_extensions::{ExpectedCertificate, RuntimeTester, utilities::get_test_dir}; diff --git a/mithril-aggregator/tests/open_message_expiration.rs b/mithril-aggregator/tests/open_message_expiration.rs index ad7a88ae29d..4e321f2b158 100644 --- a/mithril-aggregator/tests/open_message_expiration.rs +++ b/mithril-aggregator/tests/open_message_expiration.rs @@ -9,7 +9,7 @@ use mithril_common::{ SignedEntityTypeDiscriminants, SlotNumber, TimePoint, }, temp_dir, - test::MithrilFixtureBuilder, + test::builder::MithrilFixtureBuilder, }; use test_extensions::{ ExpectedCertificate, ExpectedMetrics, RuntimeTester, utilities::get_test_dir, diff --git a/mithril-aggregator/tests/open_message_newer_exists.rs b/mithril-aggregator/tests/open_message_newer_exists.rs index 7d487a1f914..f3850e3201a 100644 --- a/mithril-aggregator/tests/open_message_newer_exists.rs +++ b/mithril-aggregator/tests/open_message_newer_exists.rs @@ -7,7 +7,7 @@ use mithril_common::{ SignedEntityTypeDiscriminants, SlotNumber, StakeDistributionParty, TimePoint, }, temp_dir, - test::MithrilFixtureBuilder, + test::builder::MithrilFixtureBuilder, }; use test_extensions::{ ExpectedCertificate, ExpectedMetrics, RuntimeTester, utilities::get_test_dir, diff --git a/mithril-aggregator/tests/prove_transactions.rs b/mithril-aggregator/tests/prove_transactions.rs index d0192289a1c..4125ed824d3 100644 --- a/mithril-aggregator/tests/prove_transactions.rs +++ b/mithril-aggregator/tests/prove_transactions.rs @@ -5,7 +5,7 @@ use mithril_common::{ ProtocolParameters, SignedEntityType, SignedEntityTypeDiscriminants, SlotNumber, TimePoint, }, temp_dir, - test::MithrilFixtureBuilder, + test::builder::MithrilFixtureBuilder, }; use test_extensions::{ ExpectedCertificate, ExpectedMetrics, RuntimeTester, utilities::get_test_dir, diff --git a/mithril-aggregator/tests/test_extensions/runtime_tester.rs b/mithril-aggregator/tests/test_extensions/runtime_tester.rs index 640ba881658..2adb9d8d70b 100644 --- a/mithril-aggregator/tests/test_extensions/runtime_tester.rs +++ b/mithril-aggregator/tests/test_extensions/runtime_tester.rs @@ -30,7 +30,9 @@ use mithril_common::{ TimePoint, }, test::{ - MithrilFixture, MithrilFixtureBuilder, SignerFixture, StakeDistributionGenerationMethod, + builder::{ + MithrilFixture, MithrilFixtureBuilder, SignerFixture, StakeDistributionGenerationMethod, + }, double::Dummy, }, }; diff --git a/mithril-client/src/certificate_client/verify.rs b/mithril-client/src/certificate_client/verify.rs index 3d0913ed97a..c7e8af2464e 100644 --- a/mithril-client/src/certificate_client/verify.rs +++ b/mithril-client/src/certificate_client/verify.rs @@ -244,7 +244,7 @@ impl CertificateVerifier for MithrilCertificateVerifier { #[cfg(test)] mod tests { - use mithril_common::test::CertificateChainBuilder; + use mithril_common::test::builder::CertificateChainBuilder; use crate::certificate_client::tests_utils::CertificateClientTestBuilder; use crate::feedback::StackFeedbackReceiver; @@ -321,7 +321,7 @@ mod tests { #[cfg(feature = "unstable")] mod cache { use chrono::TimeDelta; - use mithril_common::test::CertificateChainingMethod; + use mithril_common::test::builder::CertificateChainingMethod; use mockall::predicate::eq; use crate::aggregator_client::MockAggregatorClient; diff --git a/mithril-common/src/certificate_chain/certificate_genesis.rs b/mithril-common/src/certificate_chain/certificate_genesis.rs index f75207878c5..afaf2344e85 100644 --- a/mithril-common/src/certificate_chain/certificate_genesis.rs +++ b/mithril-common/src/certificate_chain/certificate_genesis.rs @@ -111,7 +111,7 @@ impl CertificateGenesisProducer { mod tests { use super::*; - use crate::{entities::ProtocolMessagePartKey, test::MithrilFixtureBuilder}; + use crate::{entities::ProtocolMessagePartKey, test::builder::MithrilFixtureBuilder}; #[test] fn test_create_genesis_protocol_message_has_expected_keys_and_values() { diff --git a/mithril-common/src/certificate_chain/certificate_verifier.rs b/mithril-common/src/certificate_chain/certificate_verifier.rs index fc28d0d5079..09448ae1f92 100644 --- a/mithril-common/src/certificate_chain/certificate_verifier.rs +++ b/mithril-common/src/certificate_chain/certificate_verifier.rs @@ -429,8 +429,9 @@ mod tests { use crate::certificate_chain::{CertificateRetrieverError, FakeCertificaterRetriever}; use crate::crypto_helper::{ProtocolClerk, tests_setup::*}; - use crate::test::{ - CertificateChainBuilder, CertificateChainBuilderContext, MithrilFixtureBuilder, TestLogger, + use crate::test::TestLogger; + use crate::test::builder::{ + CertificateChainBuilder, CertificateChainBuilderContext, MithrilFixtureBuilder, }; macro_rules! assert_error_matches { diff --git a/mithril-common/src/crypto_helper/conversions.rs b/mithril-common/src/crypto_helper/conversions.rs index 2ed9716a2d5..c3b34b8addc 100644 --- a/mithril-common/src/crypto_helper/conversions.rs +++ b/mithril-common/src/crypto_helper/conversions.rs @@ -30,7 +30,7 @@ impl From<&entities::SignerWithStake> for (types::ProtocolPartyId, types::Protoc #[cfg(test)] pub mod tests { - use crate::test::MithrilFixtureBuilder; + use crate::test::builder::MithrilFixtureBuilder; use super::*; diff --git a/mithril-common/src/crypto_helper/tests_setup.rs b/mithril-common/src/crypto_helper/tests_setup.rs index 231e3009fc1..9b5342ebea8 100644 --- a/mithril-common/src/crypto_helper/tests_setup.rs +++ b/mithril-common/src/crypto_helper/tests_setup.rs @@ -7,7 +7,10 @@ use rand_core::SeedableRng; use crate::{ crypto_helper::{KesSigner, cardano::KesSignerStandard}, entities::{ProtocolMessage, ProtocolMessagePartKey, SignerWithStake, Stake}, - test::{CertificateChainBuilder, CertificateChainFixture, SignerFixture, TempDir}, + test::{ + TempDir, + builder::{CertificateChainBuilder, CertificateChainFixture, SignerFixture}, + }, }; use super::{OpCert, SerDeShelleyFileFormat, types::*}; diff --git a/mithril-common/src/entities/mithril_stake_distribution.rs b/mithril-common/src/entities/mithril_stake_distribution.rs index e842f58908e..d9051200643 100644 --- a/mithril-common/src/entities/mithril_stake_distribution.rs +++ b/mithril-common/src/entities/mithril_stake_distribution.rs @@ -56,7 +56,7 @@ impl MithrilStakeDistribution { #[cfg(test)] mod tests { - use crate::test::{MithrilFixtureBuilder, double::fake_data}; + use crate::test::{builder::MithrilFixtureBuilder, double::fake_data}; use super::*; diff --git a/mithril-common/src/entities/signer.rs b/mithril-common/src/entities/signer.rs index 973a294a3e6..2f921d89130 100644 --- a/mithril-common/src/entities/signer.rs +++ b/mithril-common/src/entities/signer.rs @@ -264,7 +264,7 @@ impl Debug for SignerWithStake { #[cfg(test)] mod tests { - use crate::test::{MithrilFixtureBuilder, double::fake_keys}; + use crate::test::{builder::MithrilFixtureBuilder, double::fake_keys}; use super::*; diff --git a/mithril-common/src/entities/single_signature.rs b/mithril-common/src/entities/single_signature.rs index 6a72a80f905..0544b6dd2c5 100644 --- a/mithril-common/src/entities/single_signature.rs +++ b/mithril-common/src/entities/single_signature.rs @@ -67,7 +67,7 @@ impl SingleSignature { /// Create a fake [SingleSignature] with valid cryptographic data for testing purposes. pub fn fake, TMessage: Into>(party_id: TPartyId, message: TMessage) -> Self { use crate::entities::{ProtocolParameters}; - use crate::test::{MithrilFixtureBuilder, StakeDistributionGenerationMethod}; + use crate::test::builder::{MithrilFixtureBuilder, StakeDistributionGenerationMethod}; let party_id = party_id.into(); let message = message.into(); @@ -110,7 +110,7 @@ impl Debug for SingleSignature { #[cfg(test)] mod tests { use super::*; - use crate::{crypto_helper::tests_setup::setup_message, test::MithrilFixtureBuilder}; + use crate::{crypto_helper::tests_setup::setup_message, test::builder::MithrilFixtureBuilder}; #[test] fn single_signatures_should_convert_to_protocol_signatures() { diff --git a/mithril-common/src/protocol/multi_signer.rs b/mithril-common/src/protocol/multi_signer.rs index 8760007dbf4..913b5d6caf7 100644 --- a/mithril-common/src/protocol/multi_signer.rs +++ b/mithril-common/src/protocol/multi_signer.rs @@ -94,8 +94,10 @@ mod test { use crate::{ entities::{ProtocolMessage, ProtocolMessagePartKey, ProtocolParameters}, protocol::SignerBuilder, - test::double::fake_keys, - test::{MithrilFixture, MithrilFixtureBuilder, StakeDistributionGenerationMethod}, + test::{ + builder::{MithrilFixture, MithrilFixtureBuilder, StakeDistributionGenerationMethod}, + double::fake_keys, + }, }; use super::*; diff --git a/mithril-common/src/protocol/signer_builder.rs b/mithril-common/src/protocol/signer_builder.rs index ed6a67bfdc5..e6c9c9f448d 100644 --- a/mithril-common/src/protocol/signer_builder.rs +++ b/mithril-common/src/protocol/signer_builder.rs @@ -178,7 +178,7 @@ mod test { use crate::{ crypto_helper::{KesSignerStandard, ProtocolRegistrationErrorWrapper}, - test::{MithrilFixtureBuilder, double::fake_data}, + test::{builder::MithrilFixtureBuilder, double::fake_data}, }; use super::*; @@ -207,7 +207,7 @@ mod test { let fixture_with_another_stake_distribution = MithrilFixtureBuilder::default() .with_signers(1) .with_stake_distribution( - crate::test::StakeDistributionGenerationMethod::RandomDistribution { + crate::test::builder::StakeDistributionGenerationMethod::RandomDistribution { seed: [4u8; 32], min_stake: 1, }, diff --git a/mithril-common/src/protocol/single_signer.rs b/mithril-common/src/protocol/single_signer.rs index 3c43349e945..fd7d48711bf 100644 --- a/mithril-common/src/protocol/single_signer.rs +++ b/mithril-common/src/protocol/single_signer.rs @@ -53,7 +53,7 @@ mod test { crypto_helper::{KesSigner, KesSignerStandard}, entities::ProtocolMessage, protocol::SignerBuilder, - test::MithrilFixtureBuilder, + test::builder::MithrilFixtureBuilder, }; #[test] diff --git a/mithril-common/src/signable_builder/cardano_transactions.rs b/mithril-common/src/signable_builder/cardano_transactions.rs index 378d2e3ed57..44fe538d676 100644 --- a/mithril-common/src/signable_builder/cardano_transactions.rs +++ b/mithril-common/src/signable_builder/cardano_transactions.rs @@ -96,7 +96,7 @@ mod tests { use crate::{ crypto_helper::MKTreeStoreInMemory, entities::CardanoTransaction, - test::CardanoTransactionsBuilder, + test::builder::CardanoTransactionsBuilder, }; use super::*; diff --git a/mithril-common/src/test/cardano_transactions_builder.rs b/mithril-common/src/test/builder/cardano_transactions_builder.rs similarity index 98% rename from mithril-common/src/test/cardano_transactions_builder.rs rename to mithril-common/src/test/builder/cardano_transactions_builder.rs index 6c5c82f4524..d5c6ec8fdcf 100644 --- a/mithril-common/src/test/cardano_transactions_builder.rs +++ b/mithril-common/src/test/builder/cardano_transactions_builder.rs @@ -8,7 +8,7 @@ use crate::entities::{BlockNumber, BlockRange, CardanoTransaction, SlotNumber}; /// /// ``` /// use mithril_common::entities::{BlockNumber, CardanoTransaction, SlotNumber}; -/// use mithril_common::test::CardanoTransactionsBuilder; +/// use mithril_common::test::builder::CardanoTransactionsBuilder; /// /// let txs = CardanoTransactionsBuilder::new() /// .max_transactions_per_block(3) @@ -35,7 +35,7 @@ use crate::entities::{BlockNumber, BlockRange, CardanoTransaction, SlotNumber}; /// /// ``` /// use mithril_common::entities::{BlockNumber, CardanoTransaction, SlotNumber}; -/// use mithril_common::test::CardanoTransactionsBuilder; +/// use mithril_common::test::builder::CardanoTransactionsBuilder; /// /// let txs = CardanoTransactionsBuilder::new() /// .max_transactions_per_block(3) diff --git a/mithril-common/src/test/certificate_chain_builder.rs b/mithril-common/src/test/builder/certificate_chain_builder.rs similarity index 99% rename from mithril-common/src/test/certificate_chain_builder.rs rename to mithril-common/src/test/builder/certificate_chain_builder.rs index c64851c00c6..fcd6f15c8ec 100644 --- a/mithril-common/src/test/certificate_chain_builder.rs +++ b/mithril-common/src/test/builder/certificate_chain_builder.rs @@ -14,7 +14,10 @@ use crate::{ CardanoDbBeacon, Certificate, CertificateMetadata, CertificateSignature, Epoch, ProtocolMessage, ProtocolMessagePartKey, SignedEntityType, }, - test::{MithrilFixture, MithrilFixtureBuilder, SignerFixture, double::fake_data}, + test::{ + builder::{MithrilFixture, MithrilFixtureBuilder, SignerFixture}, + double::fake_data, + }, }; /// Genesis certificate processor function type. For tests only. @@ -169,7 +172,7 @@ impl CertificateChainFixture { /// /// ``` /// use mithril_common::crypto_helper::ProtocolParameters; -/// use mithril_common::test::CertificateChainBuilder; +/// use mithril_common::test::builder::CertificateChainBuilder; /// /// let certificate_chain_fixture = CertificateChainBuilder::new() /// .with_total_certificates(5) @@ -184,7 +187,7 @@ impl CertificateChainFixture { /// ``` /// use std::cmp::min; /// use mithril_common::crypto_helper::ProtocolParameters; -/// use mithril_common::test::CertificateChainBuilder; +/// use mithril_common::test::builder::CertificateChainBuilder; /// /// let certificate_chain_fixture = CertificateChainBuilder::new() /// .with_total_certificates(5) @@ -205,7 +208,7 @@ impl CertificateChainFixture { /// ``` /// use mithril_common::entities::Epoch; /// use mithril_common::crypto_helper::ProtocolParameters; -/// use mithril_common::test::CertificateChainBuilder; +/// use mithril_common::test::builder::CertificateChainBuilder; /// /// let certificate_chain_fixture = CertificateChainBuilder::new() /// .with_total_certificates(5) diff --git a/mithril-common/src/test/fixture_builder.rs b/mithril-common/src/test/builder/fixture_builder.rs similarity index 99% rename from mithril-common/src/test/fixture_builder.rs rename to mithril-common/src/test/builder/fixture_builder.rs index e1136c03fdd..6e0ec40f2f2 100644 --- a/mithril-common/src/test/fixture_builder.rs +++ b/mithril-common/src/test/builder/fixture_builder.rs @@ -8,11 +8,12 @@ use crate::{ tests_setup, tests_setup::setup_temp_directory_for_signer, }, entities::{PartyId, ProtocolParameters, Stake, StakeDistribution}, - test::{double::fake_data, mithril_fixture::MithrilFixture}, + test::{ + builder::MithrilFixture, + double::{fake_data, precomputed_kes_key}, + }, }; -use super::double::precomputed_kes_key; - /// A builder of mithril types. pub struct MithrilFixtureBuilder { protocol_parameters: ProtocolParameters, diff --git a/mithril-common/src/test/mithril_fixture.rs b/mithril-common/src/test/builder/mithril_fixture.rs similarity index 100% rename from mithril-common/src/test/mithril_fixture.rs rename to mithril-common/src/test/builder/mithril_fixture.rs diff --git a/mithril-common/src/test/builder/mod.rs b/mithril-common/src/test/builder/mod.rs new file mode 100644 index 00000000000..ffe22ac0edf --- /dev/null +++ b/mithril-common/src/test/builder/mod.rs @@ -0,0 +1,16 @@ +//! Builders for test +//! +//! Enable easier creations of complex types for test purpose + +mod cardano_transactions_builder; +mod certificate_chain_builder; +mod fixture_builder; +mod mithril_fixture; + +pub use cardano_transactions_builder::CardanoTransactionsBuilder; +pub use certificate_chain_builder::{ + CertificateChainBuilder, CertificateChainBuilderContext, CertificateChainFixture, + CertificateChainingMethod, +}; +pub use fixture_builder::{MithrilFixtureBuilder, StakeDistributionGenerationMethod}; +pub use mithril_fixture::{MithrilFixture, SignerFixture}; diff --git a/mithril-common/src/test/double/fake_data.rs b/mithril-common/src/test/double/fake_data.rs index a3d5429ac24..3bb4cab4e3f 100644 --- a/mithril-common/src/test/double/fake_data.rs +++ b/mithril-common/src/test/double/fake_data.rs @@ -11,7 +11,7 @@ use crate::entities::{ ImmutablesLocations, LotteryIndex, ProtocolMessage, ProtocolMessagePartKey, SignedEntityType, SingleSignature, SlotNumber, StakeDistribution, StakeDistributionParty, }; -use crate::test::{MithrilFixtureBuilder, double::Dummy}; +use crate::test::{builder::MithrilFixtureBuilder, double::Dummy}; use super::fake_keys; diff --git a/mithril-common/src/test/double/precomputed_kes_key.rs b/mithril-common/src/test/double/precomputed_kes_key.rs index 5be629dc043..daf56948a97 100644 --- a/mithril-common/src/test/double/precomputed_kes_key.rs +++ b/mithril-common/src/test/double/precomputed_kes_key.rs @@ -1,5 +1,5 @@ -/// If there is a need to update this data, we can run the `verify_kes_key_cache_content` test in `fixture_builder.rs` -/// which generates the code of this function. +/// If there is a need to update this data, we can run the `verify_kes_key_cache_content` test in +/// `test::builder::fixture_builder.rs` which generates the code of this function. pub fn cached_kes_key(kes_key_seed: &[u8]) -> Option<([u8; 612], [u8; 32])> { let (kes_bytes, kes_verification_key) = match kes_key_seed { [ diff --git a/mithril-common/src/test/mod.rs b/mithril-common/src/test/mod.rs index e26a17be671..4f88905e28c 100644 --- a/mithril-common/src/test/mod.rs +++ b/mithril-common/src/test/mod.rs @@ -6,26 +6,16 @@ //! * A builder of [MithrilFixture] to generate signers alongside a stake distribution //! +pub mod builder; pub mod double; pub mod mock_extensions; -mod cardano_transactions_builder; -mod certificate_chain_builder; mod dir_eq; -mod fixture_builder; mod memory_logger; -mod mithril_fixture; mod temp_dir; -pub use cardano_transactions_builder::CardanoTransactionsBuilder; -pub use certificate_chain_builder::{ - CertificateChainBuilder, CertificateChainBuilderContext, CertificateChainFixture, - CertificateChainingMethod, -}; pub use dir_eq::*; -pub use fixture_builder::{MithrilFixtureBuilder, StakeDistributionGenerationMethod}; pub use memory_logger::*; -pub use mithril_fixture::{MithrilFixture, SignerFixture}; pub use temp_dir::*; #[cfg(test)] pub(crate) use utils::*; diff --git a/mithril-signer/src/runtime/runner.rs b/mithril-signer/src/runtime/runner.rs index f9baee012fa..cf40424e685 100644 --- a/mithril-signer/src/runtime/runner.rs +++ b/mithril-signer/src/runtime/runner.rs @@ -354,7 +354,7 @@ mod tests { MithrilStakeDistributionSignableBuilder, SignableBuilderServiceDependencies, }, test::{ - MithrilFixtureBuilder, + builder::MithrilFixtureBuilder, double::{Dummy, fake_data}, }, }; diff --git a/mithril-signer/src/services/epoch_service.rs b/mithril-signer/src/services/epoch_service.rs index e56cd1b4ea0..5222120d46c 100644 --- a/mithril-signer/src/services/epoch_service.rs +++ b/mithril-signer/src/services/epoch_service.rs @@ -429,7 +429,7 @@ mod tests { use mithril_common::entities::{Epoch, StakeDistribution}; use mithril_common::test::{ - MithrilFixtureBuilder, + builder::MithrilFixtureBuilder, double::{Dummy, fake_data}, }; diff --git a/mithril-signer/src/services/signable_builder/signable_seed_builder.rs b/mithril-signer/src/services/signable_builder/signable_seed_builder.rs index 33d6f14387a..d3c4fd128b7 100644 --- a/mithril-signer/src/services/signable_builder/signable_seed_builder.rs +++ b/mithril-signer/src/services/signable_builder/signable_seed_builder.rs @@ -107,7 +107,7 @@ impl SignableSeedBuilder for SignerSignableSeedBuilder { mod tests { use mithril_common::{ - entities::Epoch, entities::ProtocolParameters, test::MithrilFixtureBuilder, + entities::Epoch, entities::ProtocolParameters, test::builder::MithrilFixtureBuilder, }; use crate::{ diff --git a/mithril-signer/src/services/single_signer.rs b/mithril-signer/src/services/single_signer.rs index 4cb916af955..b02b16717bc 100644 --- a/mithril-signer/src/services/single_signer.rs +++ b/mithril-signer/src/services/single_signer.rs @@ -173,7 +173,7 @@ mod tests { use crate::test_tools::TestLogger; use mithril_common::crypto_helper::ProtocolClerk; use mithril_common::entities::{Epoch, ProtocolMessagePartKey}; - use mithril_common::test::MithrilFixtureBuilder; + use mithril_common::test::builder::MithrilFixtureBuilder; use mithril_persistence::store::StakeStorer; use super::*; diff --git a/mithril-signer/tests/create_cardano_transaction_single_signature.rs b/mithril-signer/tests/create_cardano_transaction_single_signature.rs index a853a6bdaeb..15205489f82 100644 --- a/mithril-signer/tests/create_cardano_transaction_single_signature.rs +++ b/mithril-signer/tests/create_cardano_transaction_single_signature.rs @@ -9,7 +9,7 @@ use mithril_common::{ }, SignedEntityTypeDiscriminants, SlotNumber, TimePoint, }, - test::MithrilFixtureBuilder, + test::builder::MithrilFixtureBuilder, }; use test_extensions::StateMachineTester; diff --git a/mithril-signer/tests/create_immutable_files_full_single_signature.rs b/mithril-signer/tests/create_immutable_files_full_single_signature.rs index 250ed7cd871..f498851b5be 100644 --- a/mithril-signer/tests/create_immutable_files_full_single_signature.rs +++ b/mithril-signer/tests/create_immutable_files_full_single_signature.rs @@ -7,7 +7,7 @@ use mithril_common::entities::{CardanoDbBeacon, SignedEntityTypeDiscriminants}; use mithril_common::{ crypto_helper::tests_setup, entities::{BlockNumber, ChainPoint, Epoch, SlotNumber, TimePoint}, - test::MithrilFixtureBuilder, + test::builder::MithrilFixtureBuilder, }; use test_extensions::StateMachineTester; diff --git a/mithril-signer/tests/era_switch.rs b/mithril-signer/tests/era_switch.rs index 87cfc84dec9..1ddfd7555cb 100644 --- a/mithril-signer/tests/era_switch.rs +++ b/mithril-signer/tests/era_switch.rs @@ -3,7 +3,7 @@ mod test_extensions; use mithril_common::{ crypto_helper::tests_setup, entities::{BlockNumber, ChainPoint, Epoch, SlotNumber, SupportedEra, TimePoint}, - test::{MithrilFixtureBuilder, double::Dummy}, + test::{builder::MithrilFixtureBuilder, double::Dummy}, }; use mithril_era::EraMarker; use test_extensions::StateMachineTester; diff --git a/mithril-test-lab/mithril-end-to-end/src/bin/load-aggregator/main.rs b/mithril-test-lab/mithril-end-to-end/src/bin/load-aggregator/main.rs index 98ade94adfb..1c381218349 100644 --- a/mithril-test-lab/mithril-end-to-end/src/bin/load-aggregator/main.rs +++ b/mithril-test-lab/mithril-end-to-end/src/bin/load-aggregator/main.rs @@ -7,7 +7,7 @@ use mithril_cardano_node_internal_database::test::{DummyCardanoDb, DummyCardanoD use mithril_common::{ StdResult, entities::{Epoch, ProtocolParameters}, - test::MithrilFixture, + test::builder::MithrilFixture, }; use mithril_end_to_end::{ diff --git a/mithril-test-lab/mithril-end-to-end/src/stress_test/aggregator_helpers.rs b/mithril-test-lab/mithril-end-to-end/src/stress_test/aggregator_helpers.rs index 43a33667142..25a99ae522f 100644 --- a/mithril-test-lab/mithril-end-to-end/src/stress_test/aggregator_helpers.rs +++ b/mithril-test-lab/mithril-end-to-end/src/stress_test/aggregator_helpers.rs @@ -1,7 +1,7 @@ use slog_scope::info; use std::time::Duration; -use mithril_common::{StdResult, entities::Epoch, test::MithrilFixture}; +use mithril_common::{StdResult, entities::Epoch, test::builder::MithrilFixture}; use crate::{ Aggregator, AggregatorConfig, diff --git a/mithril-test-lab/mithril-end-to-end/src/stress_test/fake_chain.rs b/mithril-test-lab/mithril-end-to-end/src/stress_test/fake_chain.rs index 5cba5745d32..c1058a76193 100644 --- a/mithril-test-lab/mithril-end-to-end/src/stress_test/fake_chain.rs +++ b/mithril-test-lab/mithril-end-to-end/src/stress_test/fake_chain.rs @@ -1,7 +1,7 @@ use slog_scope::debug; use std::{fs::File, io::Write, path::Path}; -use mithril_common::{entities::Epoch, test::MithrilFixture}; +use mithril_common::{entities::Epoch, test::builder::MithrilFixture}; pub fn set_stake_distribution( mock_stake_distribution_file_path: &Path, diff --git a/mithril-test-lab/mithril-end-to-end/src/stress_test/payload_builder.rs b/mithril-test-lab/mithril-end-to-end/src/stress_test/payload_builder.rs index e8f82902b07..8994d29e354 100644 --- a/mithril-test-lab/mithril-end-to-end/src/stress_test/payload_builder.rs +++ b/mithril-test-lab/mithril-end-to-end/src/stress_test/payload_builder.rs @@ -14,7 +14,7 @@ use mithril_common::{ }, messages::{RegisterSignatureMessageHttp, RegisterSignerMessage}, protocol::ToMessage, - test::{MithrilFixture, MithrilFixtureBuilder}, + test::builder::{MithrilFixture, MithrilFixtureBuilder}, }; /// Generate signer data From 8467d3b1b19889ab6bd75769e9699861da89e0c0 Mon Sep 17 00:00:00 2001 From: DJO <790521+Alenar@users.noreply.github.com> Date: Wed, 23 Jul 2025 16:10:42 +0200 Subject: [PATCH 04/15] refactor(common): move assert tools to new `test::assert` module --- .../src/test/{ => assert}/dir_eq.rs | 0 .../src/test/assert/iters_equivalent.rs | 71 ++++++++++++++++ mithril-common/src/test/assert/json.rs | 11 +++ mithril-common/src/test/assert/mod.rs | 7 ++ mithril-common/src/test/mod.rs | 83 +------------------ 5 files changed, 92 insertions(+), 80 deletions(-) rename mithril-common/src/test/{ => assert}/dir_eq.rs (100%) create mode 100644 mithril-common/src/test/assert/iters_equivalent.rs create mode 100644 mithril-common/src/test/assert/json.rs create mode 100644 mithril-common/src/test/assert/mod.rs diff --git a/mithril-common/src/test/dir_eq.rs b/mithril-common/src/test/assert/dir_eq.rs similarity index 100% rename from mithril-common/src/test/dir_eq.rs rename to mithril-common/src/test/assert/dir_eq.rs diff --git a/mithril-common/src/test/assert/iters_equivalent.rs b/mithril-common/src/test/assert/iters_equivalent.rs new file mode 100644 index 00000000000..12931c5e40f --- /dev/null +++ b/mithril-common/src/test/assert/iters_equivalent.rs @@ -0,0 +1,71 @@ +/// Compare two iterators ignoring the order +pub fn equivalent_to(a: I1, b: I2) -> bool +where + T: PartialEq + Ord, + I1: IntoIterator + Clone, + I2: IntoIterator + Clone, +{ + let a = as_sorted_vec(a); + let b = as_sorted_vec(b); + a == b +} + +/// Assert that two iterators are equivalent +pub fn assert_equivalent(a: I1, b: I2) +where + T: PartialEq + Ord + std::fmt::Debug, + I1: IntoIterator + Clone, + I2: IntoIterator + Clone, +{ + let a = as_sorted_vec(a); + let b = as_sorted_vec(b); + assert_eq!(a, b); +} + +/// Assert that two iterators are equivalent +#[macro_export] +macro_rules! assert_equivalent_macro { + ( $expected:expr, $actual:expr ) => {{ + let expected = $crate::test::as_sorted_vec($expected); + let actual = $crate::test::as_sorted_vec($actual); + assert_eq!(expected, actual); + }}; +} +pub use assert_equivalent_macro; + +/// Create a sorted clone of an iterable. +pub fn as_sorted_vec + Clone>(iter: I) -> Vec { + let mut list: Vec = iter.clone().into_iter().collect(); + list.sort(); + list +} + +#[cfg(test)] +mod tests { + use std::collections::HashSet; + + use super::*; + + #[test] + fn test_equivalent_to() { + assert!(equivalent_to(vec![1, 2, 3], vec![3, 2, 1])); + assert!(equivalent_to(vec![1, 2, 3], vec![2, 1, 3])); + assert!(!equivalent_to(vec![1, 2, 3], vec![3, 2, 1, 4])); + assert!(!equivalent_to(vec![1, 2, 3], vec![3, 2])); + + assert!(equivalent_to([1, 2, 3], vec![3, 2, 1])); + assert!(equivalent_to(&[1, 2, 3], &vec![3, 2, 1])); + assert!(equivalent_to([1, 2, 3], HashSet::from([3, 2, 1]))); + assert!(equivalent_to(vec![1, 2, 3], HashSet::from([3, 2, 1]))); + assert!(equivalent_to(&vec![1, 2, 3], &HashSet::from([3, 2, 1]))); + + assert_equivalent(vec![1, 2, 3], vec![3, 2, 1]); + assert_equivalent(vec![1, 2, 3], vec![2, 1, 3]); + + assert_equivalent([1, 2, 3], vec![3, 2, 1]); + assert_equivalent(&[1, 2, 3], &vec![3, 2, 1]); + assert_equivalent([1, 2, 3], HashSet::from([3, 2, 1])); + assert_equivalent(vec![1, 2, 3], HashSet::from([3, 2, 1])); + assert_equivalent(&vec![1, 2, 3], &HashSet::from([3, 2, 1])); + } +} diff --git a/mithril-common/src/test/assert/json.rs b/mithril-common/src/test/assert/json.rs new file mode 100644 index 00000000000..f3c1f9f43a3 --- /dev/null +++ b/mithril-common/src/test/assert/json.rs @@ -0,0 +1,11 @@ +/// Compare two json strings ignoring keys order +#[macro_export] +macro_rules! assert_same_json { + ( $expected:expr, $actual:expr ) => { + assert_eq!( + serde_json::from_str::($expected).unwrap(), + serde_json::from_str::($actual).unwrap() + ) + }; +} +pub use assert_same_json; diff --git a/mithril-common/src/test/assert/mod.rs b/mithril-common/src/test/assert/mod.rs new file mode 100644 index 00000000000..9aefceb543c --- /dev/null +++ b/mithril-common/src/test/assert/mod.rs @@ -0,0 +1,7 @@ +mod dir_eq; +mod iters_equivalent; +mod json; + +pub use dir_eq::*; +pub use iters_equivalent::*; +pub use json::*; diff --git a/mithril-common/src/test/mod.rs b/mithril-common/src/test/mod.rs index 4f88905e28c..ff040ec4e2e 100644 --- a/mithril-common/src/test/mod.rs +++ b/mithril-common/src/test/mod.rs @@ -10,70 +10,16 @@ pub mod builder; pub mod double; pub mod mock_extensions; -mod dir_eq; +mod assert; mod memory_logger; mod temp_dir; -pub use dir_eq::*; +pub use assert::*; pub use memory_logger::*; pub use temp_dir::*; #[cfg(test)] pub(crate) use utils::*; -/// Compare two json strings ignoring keys order -#[macro_export] -macro_rules! assert_same_json { - ( $expected:expr, $actual:expr ) => { - assert_eq!( - serde_json::from_str::($expected).unwrap(), - serde_json::from_str::($actual).unwrap() - ) - }; -} -pub use assert_same_json; - -/// Compare two iterators ignoring the order -pub fn equivalent_to(a: I1, b: I2) -> bool -where - T: PartialEq + Ord, - I1: IntoIterator + Clone, - I2: IntoIterator + Clone, -{ - let a = as_sorted_vec(a); - let b = as_sorted_vec(b); - a == b -} - -/// Assert that two iterators are equivalent -pub fn assert_equivalent(a: I1, b: I2) -where - T: PartialEq + Ord + std::fmt::Debug, - I1: IntoIterator + Clone, - I2: IntoIterator + Clone, -{ - let a = as_sorted_vec(a); - let b = as_sorted_vec(b); - assert_eq!(a, b); -} - -/// Assert that two iterators are equivalent -#[macro_export] -macro_rules! assert_equivalent_macro { - ( $expected:expr, $actual:expr ) => {{ - let expected = $crate::test::as_sorted_vec($expected); - let actual = $crate::test::as_sorted_vec($actual); - assert_eq!(expected, actual); - }}; -} -pub use assert_equivalent_macro; - -/// Create a sorted clone af an iterable. -pub fn as_sorted_vec + Clone>(iter: I) -> Vec { - let mut list: Vec = iter.clone().into_iter().collect(); - list.sort(); - list -} - /// Return the path of the given function. /// If the last function is `f`, it is removed. /// The last `{{closure}}` is also removed. @@ -121,8 +67,8 @@ pub use current_function_path; #[cfg(test)] mod utils { use std::io; + use std::path::Path; use std::sync::Arc; - use std::{collections::HashSet, path::Path}; use slog::{Drain, Logger}; use slog_async::Async; @@ -151,29 +97,6 @@ mod utils { } } - #[test] - fn test_equivalent_to() { - assert!(equivalent_to(vec![1, 2, 3], vec![3, 2, 1])); - assert!(equivalent_to(vec![1, 2, 3], vec![2, 1, 3])); - assert!(!equivalent_to(vec![1, 2, 3], vec![3, 2, 1, 4])); - assert!(!equivalent_to(vec![1, 2, 3], vec![3, 2])); - - assert!(equivalent_to([1, 2, 3], vec![3, 2, 1])); - assert!(equivalent_to(&[1, 2, 3], &vec![3, 2, 1])); - assert!(equivalent_to([1, 2, 3], HashSet::from([3, 2, 1]))); - assert!(equivalent_to(vec![1, 2, 3], HashSet::from([3, 2, 1]))); - assert!(equivalent_to(&vec![1, 2, 3], &HashSet::from([3, 2, 1]))); - - assert_equivalent(vec![1, 2, 3], vec![3, 2, 1]); - assert_equivalent(vec![1, 2, 3], vec![2, 1, 3]); - - assert_equivalent([1, 2, 3], vec![3, 2, 1]); - assert_equivalent(&[1, 2, 3], &vec![3, 2, 1]); - assert_equivalent([1, 2, 3], HashSet::from([3, 2, 1])); - assert_equivalent(vec![1, 2, 3], HashSet::from([3, 2, 1])); - assert_equivalent(&vec![1, 2, 3], &HashSet::from([3, 2, 1])); - } - #[test] fn test_current_function_extract_function_name() { let name = current_function!(); From d58a9f349cafb9bf9357b9f9e426bd833d0b6012 Mon Sep 17 00:00:00 2001 From: DJO <790521+Alenar@users.noreply.github.com> Date: Wed, 23 Jul 2025 16:51:35 +0200 Subject: [PATCH 05/15] refactor(common): supersede `assert_equivalent` fun with a macro As it produce the error directly in the caller test, allowing to give the line of the failure. --- .../cardano_database_artifacts/ancillary.rs | 4 +- .../cardano_database_artifacts/digest.rs | 4 +- .../cardano_database_artifacts/immutable.rs | 12 +++--- .../src/commands/config_association.rs | 4 +- .../immutable_file_digest_repository.rs | 2 +- .../src/http_server/routes/proof_routes.rs | 2 +- .../compressed_archive_snapshotter.rs | 8 ++-- .../src/tools/file_archiver/api.rs | 2 +- .../src/test/assert/iters_equivalent.rs | 41 ++++++++----------- 9 files changed, 35 insertions(+), 44 deletions(-) diff --git a/mithril-aggregator/src/artifact_builder/cardano_database_artifacts/ancillary.rs b/mithril-aggregator/src/artifact_builder/cardano_database_artifacts/ancillary.rs index 94166994b64..2b9685309f4 100644 --- a/mithril-aggregator/src/artifact_builder/cardano_database_artifacts/ancillary.rs +++ b/mithril-aggregator/src/artifact_builder/cardano_database_artifacts/ancillary.rs @@ -345,7 +345,7 @@ mod tests { .await .unwrap(); - assert_equivalent( + assert_equivalent!( locations, vec![AncillaryLocation::CloudStorage { uri: "an_uri".to_string(), @@ -385,7 +385,7 @@ mod tests { .await .unwrap(); - assert_equivalent( + assert_equivalent!( locations, vec![ AncillaryLocation::CloudStorage { diff --git a/mithril-aggregator/src/artifact_builder/cardano_database_artifacts/digest.rs b/mithril-aggregator/src/artifact_builder/cardano_database_artifacts/digest.rs index 8bb515c1fc0..607fa1eccf9 100644 --- a/mithril-aggregator/src/artifact_builder/cardano_database_artifacts/digest.rs +++ b/mithril-aggregator/src/artifact_builder/cardano_database_artifacts/digest.rs @@ -522,7 +522,7 @@ mod tests { let locations = builder.upload_digest_file(&FileArchive::dummy()).await.unwrap(); - assert_equivalent( + assert_equivalent!( locations, vec![ DigestLocation::CloudStorage { @@ -562,7 +562,7 @@ mod tests { let locations = builder.upload_digest_file(&FileArchive::dummy()).await.unwrap(); - assert_equivalent( + assert_equivalent!( locations, vec![ DigestLocation::CloudStorage { diff --git a/mithril-aggregator/src/artifact_builder/cardano_database_artifacts/immutable.rs b/mithril-aggregator/src/artifact_builder/cardano_database_artifacts/immutable.rs index a57445777d5..6e2b8a1382b 100644 --- a/mithril-aggregator/src/artifact_builder/cardano_database_artifacts/immutable.rs +++ b/mithril-aggregator/src/artifact_builder/cardano_database_artifacts/immutable.rs @@ -383,7 +383,7 @@ mod tests { let upload = builder.upload(2).await.unwrap(); - assert_equivalent( + assert_equivalent!( upload.locations, vec![ImmutablesLocation::CloudStorage { uri: MultiFilesUri::Template(TemplateUri("archive.tar.gz".to_string())), @@ -469,7 +469,7 @@ mod tests { .await .unwrap(); - assert_equivalent( + assert_equivalent!( archive_paths, vec![ work_dir.join("00000.tar.gz"), @@ -641,7 +641,7 @@ mod tests { .await .unwrap(); - assert_equivalent( + assert_equivalent!( archive_paths, vec![ work_dir.join("00000.tar.gz"), @@ -683,7 +683,7 @@ mod tests { .await .unwrap(); - assert_equivalent( + assert_equivalent!( archive_paths, vec![ work_dir.join("00000.tar.gz"), @@ -794,7 +794,7 @@ mod tests { .await .unwrap(); - assert_equivalent( + assert_equivalent!( archive_paths, vec![ImmutablesLocation::CloudStorage { uri: MultiFilesUri::Template(TemplateUri("archive_2.tar.gz".to_string())), @@ -836,7 +836,7 @@ mod tests { .await .unwrap(); - assert_equivalent( + assert_equivalent!( archive_paths, vec![ ImmutablesLocation::CloudStorage { diff --git a/mithril-aggregator/src/commands/config_association.rs b/mithril-aggregator/src/commands/config_association.rs index 3a94d759711..22e0dccd1c6 100644 --- a/mithril-aggregator/src/commands/config_association.rs +++ b/mithril-aggregator/src/commands/config_association.rs @@ -73,7 +73,7 @@ macro_rules! extract_all { mod tests { use std::collections::HashMap; - use mithril_common::assert_equivalent_macro; + use mithril_common::assert_equivalent; use mithril_doc::StructDoc; #[allow(dead_code)] @@ -167,7 +167,7 @@ mod tests { "mithril commande subcommande".to_string(), ]; - assert_equivalent_macro!(expected, keys); + assert_equivalent!(expected, keys); } #[test] diff --git a/mithril-aggregator/src/database/repository/immutable_file_digest_repository.rs b/mithril-aggregator/src/database/repository/immutable_file_digest_repository.rs index 3ca6008ddfd..2811b370f4f 100644 --- a/mithril-aggregator/src/database/repository/immutable_file_digest_repository.rs +++ b/mithril-aggregator/src/database/repository/immutable_file_digest_repository.rs @@ -191,7 +191,7 @@ mod tests { let all_immutable_file_digests = repository.get_all_immutable_file_digest().await.unwrap(); - assert_equivalent( + assert_equivalent!( vec![ ImmutableFileDigestRecord { immutable_file_name: "123.chunk".to_string(), diff --git a/mithril-aggregator/src/http_server/routes/proof_routes.rs b/mithril-aggregator/src/http_server/routes/proof_routes.rs index 5bb97cedb1e..6289fb6959b 100644 --- a/mithril-aggregator/src/http_server/routes/proof_routes.rs +++ b/mithril-aggregator/src/http_server/routes/proof_routes.rs @@ -443,6 +443,6 @@ mod tests { transaction_hashes: format!("{tx1},{tx2},{tx2},{tx1},{tx2}",), }; - assert_equivalent(params.sanitize(), vec![tx1, tx2]); + assert_equivalent!(params.sanitize(), vec![tx1, tx2]); } } diff --git a/mithril-aggregator/src/services/snapshotter/compressed_archive_snapshotter.rs b/mithril-aggregator/src/services/snapshotter/compressed_archive_snapshotter.rs index bf970e48291..35a91d19b95 100644 --- a/mithril-aggregator/src/services/snapshotter/compressed_archive_snapshotter.rs +++ b/mithril-aggregator/src/services/snapshotter/compressed_archive_snapshotter.rs @@ -470,8 +470,8 @@ mod tests { let unpacked_files = list_files(&unpack_dir); let unpacked_immutable_files = list_files(&unpack_dir.join(IMMUTABLE_DIR)); - assert_equivalent(vec![IMMUTABLE_DIR.to_string()], unpacked_files); - assert_equivalent( + assert_equivalent!(vec![IMMUTABLE_DIR.to_string()], unpacked_files); + assert_equivalent!( vec![ "00001.chunk".to_string(), "00001.primary".to_string(), @@ -510,8 +510,8 @@ mod tests { let unpacked_files = list_files(&unpack_dir); let unpacked_immutable_files = list_files(&unpack_dir.join(IMMUTABLE_DIR)); - assert_equivalent(vec![IMMUTABLE_DIR.to_string()], unpacked_files); - assert_equivalent( + assert_equivalent!(vec![IMMUTABLE_DIR.to_string()], unpacked_files); + assert_equivalent!( vec![ "00002.chunk".to_string(), "00002.primary".to_string(), diff --git a/mithril-aggregator/src/tools/file_archiver/api.rs b/mithril-aggregator/src/tools/file_archiver/api.rs index 469c6c63a6e..5bd1f16dc8a 100644 --- a/mithril-aggregator/src/tools/file_archiver/api.rs +++ b/mithril-aggregator/src/tools/file_archiver/api.rs @@ -400,7 +400,7 @@ mod tests { .expect_err("FileArchiver::archive should fail if the db is empty."); let remaining_files: Vec = list_remaining_files(&test_dir); - assert_equivalent( + assert_equivalent!( vec!["other-process.file".to_string(), "archive.tar.gz".to_string()], remaining_files, ); diff --git a/mithril-common/src/test/assert/iters_equivalent.rs b/mithril-common/src/test/assert/iters_equivalent.rs index 12931c5e40f..749d4325198 100644 --- a/mithril-common/src/test/assert/iters_equivalent.rs +++ b/mithril-common/src/test/assert/iters_equivalent.rs @@ -10,28 +10,19 @@ where a == b } -/// Assert that two iterators are equivalent -pub fn assert_equivalent(a: I1, b: I2) -where - T: PartialEq + Ord + std::fmt::Debug, - I1: IntoIterator + Clone, - I2: IntoIterator + Clone, -{ - let a = as_sorted_vec(a); - let b = as_sorted_vec(b); - assert_eq!(a, b); -} - /// Assert that two iterators are equivalent #[macro_export] -macro_rules! assert_equivalent_macro { - ( $expected:expr, $actual:expr ) => {{ - let expected = $crate::test::as_sorted_vec($expected); - let actual = $crate::test::as_sorted_vec($actual); - assert_eq!(expected, actual); +macro_rules! assert_equivalent { + ($expected:expr, $actual:expr $(,)?) => {{ + let expected = $expected; + let actual = $actual; + assert_eq!( + $crate::test::as_sorted_vec(expected), + $crate::test::as_sorted_vec(actual) + ); }}; } -pub use assert_equivalent_macro; +pub use assert_equivalent; /// Create a sorted clone of an iterable. pub fn as_sorted_vec + Clone>(iter: I) -> Vec { @@ -59,13 +50,13 @@ mod tests { assert!(equivalent_to(vec![1, 2, 3], HashSet::from([3, 2, 1]))); assert!(equivalent_to(&vec![1, 2, 3], &HashSet::from([3, 2, 1]))); - assert_equivalent(vec![1, 2, 3], vec![3, 2, 1]); - assert_equivalent(vec![1, 2, 3], vec![2, 1, 3]); + assert_equivalent!(vec![1, 2, 3], vec![3, 2, 1]); + assert_equivalent!(vec![1, 2, 3], vec![2, 1, 3]); - assert_equivalent([1, 2, 3], vec![3, 2, 1]); - assert_equivalent(&[1, 2, 3], &vec![3, 2, 1]); - assert_equivalent([1, 2, 3], HashSet::from([3, 2, 1])); - assert_equivalent(vec![1, 2, 3], HashSet::from([3, 2, 1])); - assert_equivalent(&vec![1, 2, 3], &HashSet::from([3, 2, 1])); + assert_equivalent!([1, 2, 3], vec![3, 2, 1]); + assert_equivalent!(&[1, 2, 3], &vec![3, 2, 1]); + assert_equivalent!([1, 2, 3], HashSet::from([3, 2, 1])); + assert_equivalent!(vec![1, 2, 3], HashSet::from([3, 2, 1])); + assert_equivalent!(&vec![1, 2, 3], &HashSet::from([3, 2, 1])); } } From 15f18a202258c3cde3b63223c65339499252e491 Mon Sep 17 00:00:00 2001 From: DJO <790521+Alenar@users.noreply.github.com> Date: Wed, 23 Jul 2025 18:14:01 +0200 Subject: [PATCH 06/15] refactor(common): add `define_test_logger` macro for unified `TestLogger` creation Also move this new and the existing test logging utilities to a `test::logging` module. --- .../src/services/aggregator_client.rs | 2 +- mithril-client/src/aggregator_client.rs | 2 +- .../src/test/{ => logging}/memory_logger.rs | 0 mithril-common/src/test/logging/mod.rs | 56 +++++++++++++++++++ mithril-common/src/test/mod.rs | 34 +---------- .../src/services/aggregator_client.rs | 2 +- 6 files changed, 62 insertions(+), 34 deletions(-) rename mithril-common/src/test/{ => logging}/memory_logger.rs (100%) create mode 100644 mithril-common/src/test/logging/mod.rs diff --git a/mithril-aggregator/src/services/aggregator_client.rs b/mithril-aggregator/src/services/aggregator_client.rs index 0fe0f8b7251..795079b144e 100644 --- a/mithril-aggregator/src/services/aggregator_client.rs +++ b/mithril-aggregator/src/services/aggregator_client.rs @@ -813,7 +813,7 @@ mod tests { mod warn_if_api_version_mismatch { use std::collections::HashMap; - use mithril_common::test::MemoryDrainForTestInspector; + use mithril_common::test::logging::MemoryDrainForTestInspector; use super::*; diff --git a/mithril-client/src/aggregator_client.rs b/mithril-client/src/aggregator_client.rs index 66f3f818ba5..1da283f88d3 100644 --- a/mithril-client/src/aggregator_client.rs +++ b/mithril-client/src/aggregator_client.rs @@ -877,7 +877,7 @@ mod tests { mod warn_if_api_version_mismatch { use http::response::Builder as HttpResponseBuilder; - use mithril_common::test::MemoryDrainForTestInspector; + use mithril_common::test::logging::MemoryDrainForTestInspector; use super::*; diff --git a/mithril-common/src/test/memory_logger.rs b/mithril-common/src/test/logging/memory_logger.rs similarity index 100% rename from mithril-common/src/test/memory_logger.rs rename to mithril-common/src/test/logging/memory_logger.rs diff --git a/mithril-common/src/test/logging/mod.rs b/mithril-common/src/test/logging/mod.rs new file mode 100644 index 00000000000..ad61344989a --- /dev/null +++ b/mithril-common/src/test/logging/mod.rs @@ -0,0 +1,56 @@ +//! Logging utilities for tests +//! +mod memory_logger; + +pub use memory_logger::*; + +/// Creates a test-specific `TestLogger` struct that can creates preconfigured logger instances. +/// +/// This macro avoids direct `slog_async` and `slog_term` dependencies in library crates +/// by letting dependents add them as `dev-dependencies` only. +/// +/// ## Methods +/// +/// - `TestLogger::stdout()` - Logger that outputs to stdout. +/// - `TestLogger::memory()` - Logger that stores messages in memory for inspection. +/// Returns `(Logger, MemoryDrainForTestInspector)` tuple +/// +/// Requires: `slog`, `slog_async`, `slog_term` +#[macro_export] +macro_rules! define_test_logger { + () => { + #[cfg(test)] + pub(crate) struct TestLogger; + + #[cfg(test)] + mod test_logger_impl { + use std::io; + use std::sync::Arc; + + use slog::{Drain, Logger}; + use slog_async::Async; + use slog_term::{CompactFormat, PlainDecorator}; + + use $crate::test::logging::{MemoryDrainForTest, MemoryDrainForTestInspector}; + + impl super::TestLogger { + fn from_writer(writer: W) -> Logger { + let decorator = PlainDecorator::new(writer); + let drain = CompactFormat::new(decorator).build().fuse(); + let drain = Async::new(drain).build().fuse(); + Logger::root(Arc::new(drain), slog::o!()) + } + + pub(crate) fn stdout() -> Logger { + Self::from_writer(slog_term::TestStdoutWriter) + } + + pub(crate) fn memory() -> (Logger, MemoryDrainForTestInspector) { + let (drain, inspector) = MemoryDrainForTest::new(); + (Logger::root(drain.fuse(), slog::o!()), inspector) + } + } + } + }; +} +pub use define_test_logger; diff --git a/mithril-common/src/test/mod.rs b/mithril-common/src/test/mod.rs index ff040ec4e2e..704a1479f82 100644 --- a/mithril-common/src/test/mod.rs +++ b/mithril-common/src/test/mod.rs @@ -8,17 +8,16 @@ pub mod builder; pub mod double; +pub mod logging; pub mod mock_extensions; mod assert; -mod memory_logger; mod temp_dir; pub use assert::*; -pub use memory_logger::*; pub use temp_dir::*; -#[cfg(test)] -pub(crate) use utils::*; + +logging::define_test_logger!(); /// Return the path of the given function. /// If the last function is `f`, it is removed. @@ -66,37 +65,10 @@ pub use current_function_path; #[cfg(test)] mod utils { - use std::io; use std::path::Path; - use std::sync::Arc; - - use slog::{Drain, Logger}; - use slog_async::Async; - use slog_term::{CompactFormat, PlainDecorator}; use super::*; - pub struct TestLogger; - - #[cfg(test)] - impl TestLogger { - fn from_writer(writer: W) -> Logger { - let decorator = PlainDecorator::new(writer); - let drain = CompactFormat::new(decorator).build().fuse(); - let drain = Async::new(drain).build().fuse(); - Logger::root(Arc::new(drain), slog::o!()) - } - - pub fn stdout() -> Logger { - Self::from_writer(slog_term::TestStdoutWriter) - } - - pub fn memory() -> (Logger, MemoryDrainForTestInspector) { - let (drain, inspector) = MemoryDrainForTest::new(); - (Logger::root(drain.fuse(), slog::o!()), inspector) - } - } - #[test] fn test_current_function_extract_function_name() { let name = current_function!(); diff --git a/mithril-signer/src/services/aggregator_client.rs b/mithril-signer/src/services/aggregator_client.rs index 0ab757dd185..35520158050 100644 --- a/mithril-signer/src/services/aggregator_client.rs +++ b/mithril-signer/src/services/aggregator_client.rs @@ -474,8 +474,8 @@ mod tests { use mithril_common::entities::Epoch; use mithril_common::messages::TryFromMessageAdapter; use mithril_common::test::{ - MemoryDrainForTestInspector, double::{Dummy, fake_data}, + logging::MemoryDrainForTestInspector, }; use crate::test_tools::TestLogger; From 0ef8112a7e828214b3ae071756a78a3ed3f6bdb7 Mon Sep 17 00:00:00 2001 From: DJO <790521+Alenar@users.noreply.github.com> Date: Wed, 23 Jul 2025 18:15:34 +0200 Subject: [PATCH 07/15] refactor(tests): use `define_test_logger` instead of manual creation And move its definition to a `test` module instead of a `test_utils` to be in line with the latest naming scheme (only for crates that already have a `test` module). --- .../src/test/mod.rs | 20 +----------- .../src/test/mod.rs | 20 +----------- internal/mithril-dmq/src/consumer/pallas.rs | 2 +- internal/mithril-dmq/src/lib.rs | 25 --------------- internal/mithril-dmq/src/publisher/pallas.rs | 2 +- internal/mithril-dmq/src/test/mod.rs | 2 ++ internal/mithril-metric/src/helper.rs | 21 +----------- .../src/lib.rs | 22 +------------ .../src/artifact_builder/cardano_database.rs | 2 +- .../cardano_database_artifacts/ancillary.rs | 2 +- .../cardano_database_artifacts/digest.rs | 2 +- .../cardano_database_artifacts/immutable.rs | 2 +- .../cardano_immutable_files_full.rs | 3 +- .../src/commands/database_command.rs | 2 +- .../src/commands/genesis_command.rs | 2 +- .../src/commands/tools_command.rs | 2 +- .../src/dependency_injection/builder/mod.rs | 2 +- .../src/file_uploaders/local_uploader.rs | 2 +- .../src/http_server/routes/signer_routes.rs | 2 +- mithril-aggregator/src/lib.rs | 32 ------------------- mithril-aggregator/src/metrics/service.rs | 2 +- mithril-aggregator/src/multi_signer.rs | 2 +- mithril-aggregator/src/runtime/error.rs | 2 +- .../src/runtime/state_machine.rs | 2 +- .../src/services/aggregator_client.rs | 2 +- .../services/cardano_transactions_importer.rs | 2 +- .../synchronizer_service.rs | 2 +- .../services/certifier/buffered_certifier.rs | 2 +- .../services/certifier/certifier_service.rs | 2 +- .../src/services/epoch_service.rs | 2 +- mithril-aggregator/src/services/prover.rs | 2 +- .../src/services/signature_processor.rs | 2 +- .../src/services/signed_entity.rs | 2 +- .../ancillary_signer/with_secret_key.rs | 2 +- .../compressed_archive_snapshotter.rs | 2 +- mithril-aggregator/src/services/upkeep.rs | 2 +- .../src/services/usage_reporter.rs | 2 +- mithril-aggregator/src/test/mod.rs | 2 ++ .../src/tools/certificates_hash_migrator.rs | 2 +- .../src/tools/file_archiver/api.rs | 2 +- mithril-aggregator/src/tools/genesis.rs | 2 +- .../src/tools/signer_importer.rs | 2 +- .../tools/single_signature_authenticator.rs | 6 ++-- .../src/tools/vacuum_tracker.rs | 2 +- mithril-client/src/lib.rs | 30 +---------------- mithril-relay/src/lib.rs | 22 +------------ mithril-signer/src/lib.rs | 28 +--------------- 47 files changed, 49 insertions(+), 252 deletions(-) diff --git a/internal/cardano-node/mithril-cardano-node-chain/src/test/mod.rs b/internal/cardano-node/mithril-cardano-node-chain/src/test/mod.rs index 67af92db201..6e64d4dd5ac 100644 --- a/internal/cardano-node/mithril-cardano-node-chain/src/test/mod.rs +++ b/internal/cardano-node/mithril-cardano-node-chain/src/test/mod.rs @@ -8,22 +8,4 @@ pub mod double; #[cfg(test)] pub(crate) mod test_cli_runner; -#[cfg(test)] -pub(crate) struct TestLogger; - -#[cfg(test)] -impl TestLogger { - fn from_writer(writer: W) -> slog::Logger { - use slog::Drain; - use std::sync::Arc; - - let decorator = slog_term::PlainDecorator::new(writer); - let drain = slog_term::CompactFormat::new(decorator).build().fuse(); - let drain = slog_async::Async::new(drain).build().fuse(); - slog::Logger::root(Arc::new(drain), slog::o!()) - } - - pub(crate) fn stdout() -> slog::Logger { - Self::from_writer(slog_term::TestStdoutWriter) - } -} +mithril_common::define_test_logger!(); diff --git a/internal/cardano-node/mithril-cardano-node-internal-database/src/test/mod.rs b/internal/cardano-node/mithril-cardano-node-internal-database/src/test/mod.rs index df456e81d81..4085130ea78 100644 --- a/internal/cardano-node/mithril-cardano-node-internal-database/src/test/mod.rs +++ b/internal/cardano-node/mithril-cardano-node-internal-database/src/test/mod.rs @@ -10,22 +10,4 @@ pub mod fake_data; pub use dummy_cardano_db::{DummyCardanoDb, DummyCardanoDbBuilder}; -#[cfg(test)] -pub(crate) struct TestLogger; - -#[cfg(test)] -impl TestLogger { - fn from_writer(writer: W) -> slog::Logger { - use slog::Drain; - use std::sync::Arc; - - let decorator = slog_term::PlainDecorator::new(writer); - let drain = slog_term::CompactFormat::new(decorator).build().fuse(); - let drain = slog_async::Async::new(drain).build().fuse(); - slog::Logger::root(Arc::new(drain), slog::o!()) - } - - pub(crate) fn stdout() -> slog::Logger { - Self::from_writer(slog_term::TestStdoutWriter) - } -} +mithril_common::define_test_logger!(); diff --git a/internal/mithril-dmq/src/consumer/pallas.rs b/internal/mithril-dmq/src/consumer/pallas.rs index bb2cc0f5bc9..3bd75426379 100644 --- a/internal/mithril-dmq/src/consumer/pallas.rs +++ b/internal/mithril-dmq/src/consumer/pallas.rs @@ -151,7 +151,7 @@ mod tests { }; use tokio::{net::UnixListener, task::JoinHandle, time::sleep}; - use crate::{test::payload::DmqMessageTestPayload, test_tools::TestLogger}; + use crate::test::{TestLogger, payload::DmqMessageTestPayload}; use super::*; diff --git a/internal/mithril-dmq/src/lib.rs b/internal/mithril-dmq/src/lib.rs index db7536fc64e..73549c74bac 100644 --- a/internal/mithril-dmq/src/lib.rs +++ b/internal/mithril-dmq/src/lib.rs @@ -9,28 +9,3 @@ pub mod test; pub use consumer::{DmqConsumer, DmqConsumerPallas}; pub use message::DmqMessageBuilder; pub use publisher::{DmqPublisher, DmqPublisherPallas}; - -#[cfg(test)] -pub(crate) mod test_tools { - use std::io; - use std::sync::Arc; - - use slog::{Drain, Logger}; - use slog_async::Async; - use slog_term::{CompactFormat, PlainDecorator}; - - pub struct TestLogger; - - impl TestLogger { - fn from_writer(writer: W) -> Logger { - let decorator = PlainDecorator::new(writer); - let drain = CompactFormat::new(decorator).build().fuse(); - let drain = Async::new(drain).build().fuse(); - Logger::root(Arc::new(drain), slog::o!()) - } - - pub fn stdout() -> Logger { - Self::from_writer(slog_term::TestStdoutWriter) - } - } -} diff --git a/internal/mithril-dmq/src/publisher/pallas.rs b/internal/mithril-dmq/src/publisher/pallas.rs index 3295fcfd024..3d000828a06 100644 --- a/internal/mithril-dmq/src/publisher/pallas.rs +++ b/internal/mithril-dmq/src/publisher/pallas.rs @@ -96,7 +96,7 @@ mod tests { test::{TempDir, double::Dummy}, }; - use crate::{test::payload::DmqMessageTestPayload, test_tools::TestLogger}; + use crate::test::{TestLogger, payload::DmqMessageTestPayload}; use super::*; diff --git a/internal/mithril-dmq/src/test/mod.rs b/internal/mithril-dmq/src/test/mod.rs index a1d1c1930d9..f49befff326 100644 --- a/internal/mithril-dmq/src/test/mod.rs +++ b/internal/mithril-dmq/src/test/mod.rs @@ -8,3 +8,5 @@ pub mod double; #[cfg(test)] pub(crate) mod payload; + +mithril_common::define_test_logger!(); diff --git a/internal/mithril-metric/src/helper.rs b/internal/mithril-metric/src/helper.rs index 979dd8ca768..5ca9b7eea2b 100644 --- a/internal/mithril-metric/src/helper.rs +++ b/internal/mithril-metric/src/helper.rs @@ -106,26 +106,7 @@ macro_rules! build_metrics_service { #[cfg(test)] pub(crate) mod test_tools { - use std::{io, sync::Arc}; - - use slog::{Drain, Logger}; - use slog_async::Async; - use slog_term::{CompactFormat, PlainDecorator}; - - pub struct TestLogger; - - impl TestLogger { - fn from_writer(writer: W) -> Logger { - let decorator = PlainDecorator::new(writer); - let drain = CompactFormat::new(decorator).build().fuse(); - let drain = Async::new(drain).build().fuse(); - Logger::root(Arc::new(drain), slog::o!()) - } - - pub fn stdout() -> Logger { - Self::from_writer(slog_term::TestStdoutWriter) - } - } + mithril_common::define_test_logger!(); } #[cfg(test)] diff --git a/internal/signed-entity/mithril-signed-entity-preloader/src/lib.rs b/internal/signed-entity/mithril-signed-entity-preloader/src/lib.rs index 70da053686e..18cb4e8bf18 100644 --- a/internal/signed-entity/mithril-signed-entity-preloader/src/lib.rs +++ b/internal/signed-entity/mithril-signed-entity-preloader/src/lib.rs @@ -9,25 +9,5 @@ pub use cardano_transactions_preloader::*; #[cfg(test)] pub(crate) mod test_tools { - use std::io; - use std::sync::Arc; - - use slog::{Drain, Logger}; - use slog_async::Async; - use slog_term::{CompactFormat, PlainDecorator}; - - pub struct TestLogger; - - impl TestLogger { - fn from_writer(writer: W) -> Logger { - let decorator = PlainDecorator::new(writer); - let drain = CompactFormat::new(decorator).build().fuse(); - let drain = Async::new(drain).build().fuse(); - Logger::root(Arc::new(drain), slog::o!()) - } - - pub fn stdout() -> Logger { - Self::from_writer(slog_term::TestStdoutWriter) - } - } + mithril_common::define_test_logger!(); } diff --git a/mithril-aggregator/src/artifact_builder/cardano_database.rs b/mithril-aggregator/src/artifact_builder/cardano_database.rs index 49ded872526..e09b76cc6c4 100644 --- a/mithril-aggregator/src/artifact_builder/cardano_database.rs +++ b/mithril-aggregator/src/artifact_builder/cardano_database.rs @@ -125,7 +125,7 @@ mod tests { immutable_file_digest_mapper::MockImmutableFileDigestMapper, services::CompressedArchiveSnapshotter, services::ancillary_signer::MockAncillarySigner, - test_tools::TestLogger, + test::TestLogger, tools::{file_archiver::FileArchiver, url_sanitizer::SanitizedUrlWithTrailingSlash}, }; diff --git a/mithril-aggregator/src/artifact_builder/cardano_database_artifacts/ancillary.rs b/mithril-aggregator/src/artifact_builder/cardano_database_artifacts/ancillary.rs index 2b9685309f4..c21a595a2fc 100644 --- a/mithril-aggregator/src/artifact_builder/cardano_database_artifacts/ancillary.rs +++ b/mithril-aggregator/src/artifact_builder/cardano_database_artifacts/ancillary.rs @@ -209,7 +209,7 @@ mod tests { use mithril_common::test::{TempDir, assert_equivalent, double::Dummy}; use crate::services::{DumbSnapshotter, MockSnapshotter}; - use crate::test_tools::TestLogger; + use crate::test::TestLogger; use super::*; diff --git a/mithril-aggregator/src/artifact_builder/cardano_database_artifacts/digest.rs b/mithril-aggregator/src/artifact_builder/cardano_database_artifacts/digest.rs index 607fa1eccf9..a16608d497c 100644 --- a/mithril-aggregator/src/artifact_builder/cardano_database_artifacts/digest.rs +++ b/mithril-aggregator/src/artifact_builder/cardano_database_artifacts/digest.rs @@ -304,7 +304,7 @@ mod tests { use crate::{ file_uploaders::FileUploadRetryPolicy, - immutable_file_digest_mapper::MockImmutableFileDigestMapper, test_tools::TestLogger, + immutable_file_digest_mapper::MockImmutableFileDigestMapper, test::TestLogger, tools::file_archiver::FileArchiver, }; diff --git a/mithril-aggregator/src/artifact_builder/cardano_database_artifacts/immutable.rs b/mithril-aggregator/src/artifact_builder/cardano_database_artifacts/immutable.rs index 6e2b8a1382b..5c7b3f9c3c5 100644 --- a/mithril-aggregator/src/artifact_builder/cardano_database_artifacts/immutable.rs +++ b/mithril-aggregator/src/artifact_builder/cardano_database_artifacts/immutable.rs @@ -286,7 +286,7 @@ mod tests { use crate::services::ancillary_signer::MockAncillarySigner; use crate::services::{CompressedArchiveSnapshotter, DumbSnapshotter, MockSnapshotter}; - use crate::test_tools::TestLogger; + use crate::test::TestLogger; use crate::tools::file_archiver::FileArchiver; use super::*; diff --git a/mithril-aggregator/src/artifact_builder/cardano_immutable_files_full.rs b/mithril-aggregator/src/artifact_builder/cardano_immutable_files_full.rs index 8fe5dcf5d41..d6602b121bd 100644 --- a/mithril-aggregator/src/artifact_builder/cardano_immutable_files_full.rs +++ b/mithril-aggregator/src/artifact_builder/cardano_immutable_files_full.rs @@ -209,8 +209,7 @@ mod tests { use mithril_common::{entities::CompressionAlgorithm, test::double::fake_data}; use crate::{ - DumbUploader, file_uploaders::MockFileUploader, services::DumbSnapshotter, - test_tools::TestLogger, + DumbUploader, file_uploaders::MockFileUploader, services::DumbSnapshotter, test::TestLogger, }; use super::*; diff --git a/mithril-aggregator/src/commands/database_command.rs b/mithril-aggregator/src/commands/database_command.rs index abd2d0d4013..dd807c9e40f 100644 --- a/mithril-aggregator/src/commands/database_command.rs +++ b/mithril-aggregator/src/commands/database_command.rs @@ -189,7 +189,7 @@ mod tests { use mithril_common::temp_dir; - use crate::test_tools::TestLogger; + use crate::test::TestLogger; use super::*; diff --git a/mithril-aggregator/src/commands/genesis_command.rs b/mithril-aggregator/src/commands/genesis_command.rs index d4054adf202..dff8fe35dff 100644 --- a/mithril-aggregator/src/commands/genesis_command.rs +++ b/mithril-aggregator/src/commands/genesis_command.rs @@ -368,7 +368,7 @@ mod tests { use mithril_common::temp_dir; - use crate::test_tools::TestLogger; + use crate::test::TestLogger; use super::*; diff --git a/mithril-aggregator/src/commands/tools_command.rs b/mithril-aggregator/src/commands/tools_command.rs index ba87c89f56a..d8df52b5bc9 100644 --- a/mithril-aggregator/src/commands/tools_command.rs +++ b/mithril-aggregator/src/commands/tools_command.rs @@ -140,7 +140,7 @@ mod tests { use mithril_common::temp_dir; - use crate::test_tools::TestLogger; + use crate::test::TestLogger; use super::*; diff --git a/mithril-aggregator/src/dependency_injection/builder/mod.rs b/mithril-aggregator/src/dependency_injection/builder/mod.rs index d14398c7d1d..bb0a6499654 100644 --- a/mithril-aggregator/src/dependency_injection/builder/mod.rs +++ b/mithril-aggregator/src/dependency_injection/builder/mod.rs @@ -526,6 +526,6 @@ impl DependenciesBuilder { #[cfg(test)] impl DependenciesBuilder { pub(crate) fn new_with_stdout_logger(configuration: Arc) -> Self { - Self::new(crate::test_tools::TestLogger::stdout(), configuration) + Self::new(crate::test::TestLogger::stdout(), configuration) } } diff --git a/mithril-aggregator/src/file_uploaders/local_uploader.rs b/mithril-aggregator/src/file_uploaders/local_uploader.rs index a1be0236daa..a62eb48da12 100644 --- a/mithril-aggregator/src/file_uploaders/local_uploader.rs +++ b/mithril-aggregator/src/file_uploaders/local_uploader.rs @@ -94,7 +94,7 @@ mod tests { use mithril_common::test::TempDir; - use crate::test_tools::TestLogger; + use crate::test::TestLogger; use super::*; diff --git a/mithril-aggregator/src/http_server/routes/signer_routes.rs b/mithril-aggregator/src/http_server/routes/signer_routes.rs index 154d91c0ef7..233ddb1e113 100644 --- a/mithril-aggregator/src/http_server/routes/signer_routes.rs +++ b/mithril-aggregator/src/http_server/routes/signer_routes.rs @@ -284,7 +284,7 @@ mod tests { initialize_dependencies, services::{FakeEpochService, MockSignerRegisterer}, store::MockVerificationKeyStorer, - test_tools::TestLogger, + test::TestLogger, }; use super::*; diff --git a/mithril-aggregator/src/lib.rs b/mithril-aggregator/src/lib.rs index f45df0e37da..7d9909bff76 100644 --- a/mithril-aggregator/src/lib.rs +++ b/mithril-aggregator/src/lib.rs @@ -69,35 +69,3 @@ use tikv_jemallocator::Jemalloc; #[cfg(all(not(target_env = "msvc"), feature = "jemallocator"))] #[global_allocator] static GLOBAL: Jemalloc = Jemalloc; - -#[cfg(test)] -pub(crate) mod test_tools { - use std::io; - use std::sync::Arc; - - use slog::{Drain, Logger}; - use slog_async::Async; - use slog_term::{CompactFormat, PlainDecorator}; - - use mithril_common::test::{MemoryDrainForTest, MemoryDrainForTestInspector}; - - pub struct TestLogger; - - impl TestLogger { - fn from_writer(writer: W) -> Logger { - let decorator = PlainDecorator::new(writer); - let drain = CompactFormat::new(decorator).build().fuse(); - let drain = Async::new(drain).build().fuse(); - Logger::root(Arc::new(drain), slog::o!()) - } - - pub fn stdout() -> Logger { - Self::from_writer(slog_term::TestStdoutWriter) - } - - pub fn memory() -> (Logger, MemoryDrainForTestInspector) { - let (drain, inspector) = MemoryDrainForTest::new(); - (Logger::root(drain.fuse(), slog::o!()), inspector) - } - } -} diff --git a/mithril-aggregator/src/metrics/service.rs b/mithril-aggregator/src/metrics/service.rs index 755faad0696..1517e487e65 100644 --- a/mithril-aggregator/src/metrics/service.rs +++ b/mithril-aggregator/src/metrics/service.rs @@ -198,7 +198,7 @@ impl Default for MetricLabelValueMap { #[cfg(test)] mod tests { - use crate::test_tools::TestLogger; + use crate::test::TestLogger; use super::*; diff --git a/mithril-aggregator/src/multi_signer.rs b/mithril-aggregator/src/multi_signer.rs index 5f8e093dc5f..8e6e1243560 100644 --- a/mithril-aggregator/src/multi_signer.rs +++ b/mithril-aggregator/src/multi_signer.rs @@ -153,7 +153,7 @@ mod tests { use crate::entities::AggregatorEpochSettings; use crate::services::{FakeEpochService, FakeEpochServiceBuilder}; - use crate::test_tools::TestLogger; + use crate::test::TestLogger; use super::*; diff --git a/mithril-aggregator/src/runtime/error.rs b/mithril-aggregator/src/runtime/error.rs index 17632fd38c3..0cd500f7f07 100644 --- a/mithril-aggregator/src/runtime/error.rs +++ b/mithril-aggregator/src/runtime/error.rs @@ -93,7 +93,7 @@ impl From for RuntimeError { mod tests { use anyhow::anyhow; - use crate::test_tools::TestLogger; + use crate::test::TestLogger; use super::*; diff --git a/mithril-aggregator/src/runtime/state_machine.rs b/mithril-aggregator/src/runtime/state_machine.rs index 420cb120b4e..fc613f3f5c8 100644 --- a/mithril-aggregator/src/runtime/state_machine.rs +++ b/mithril-aggregator/src/runtime/state_machine.rs @@ -390,7 +390,7 @@ mod tests { use mithril_common::test::double::{Dummy, fake_data}; use crate::entities::OpenMessage; - use crate::test_tools::TestLogger; + use crate::test::TestLogger; use super::super::runner::MockAggregatorRunner; use super::*; diff --git a/mithril-aggregator/src/services/aggregator_client.rs b/mithril-aggregator/src/services/aggregator_client.rs index 795079b144e..cfad2b7f15e 100644 --- a/mithril-aggregator/src/services/aggregator_client.rs +++ b/mithril-aggregator/src/services/aggregator_client.rs @@ -425,7 +425,7 @@ mod tests { use mithril_common::messages::CertificateListItemMessage; use mithril_common::test::double::Dummy; - use crate::test_tools::TestLogger; + use crate::test::TestLogger; use super::*; diff --git a/mithril-aggregator/src/services/cardano_transactions_importer.rs b/mithril-aggregator/src/services/cardano_transactions_importer.rs index d9d991b0587..58e58c2dc83 100644 --- a/mithril-aggregator/src/services/cardano_transactions_importer.rs +++ b/mithril-aggregator/src/services/cardano_transactions_importer.rs @@ -230,7 +230,7 @@ mod tests { use mithril_persistence::sqlite::SqliteConnectionPool; use crate::database::test_helper::cardano_tx_db_connection; - use crate::test_tools::TestLogger; + use crate::test::TestLogger; use super::*; diff --git a/mithril-aggregator/src/services/certificate_chain_synchronizer/synchronizer_service.rs b/mithril-aggregator/src/services/certificate_chain_synchronizer/synchronizer_service.rs index 2b67d3ee52f..16a1a41d486 100644 --- a/mithril-aggregator/src/services/certificate_chain_synchronizer/synchronizer_service.rs +++ b/mithril-aggregator/src/services/certificate_chain_synchronizer/synchronizer_service.rs @@ -236,8 +236,8 @@ mod tests { use crate::services::{ MockOpenMessageStorer, MockRemoteCertificateRetriever, MockSynchronizedCertificateStorer, }; + use crate::test::TestLogger; use crate::test::mocks::MockCertificateVerifier; - use crate::test_tools::TestLogger; use super::*; diff --git a/mithril-aggregator/src/services/certifier/buffered_certifier.rs b/mithril-aggregator/src/services/certifier/buffered_certifier.rs index 7ff36038bc5..f1bc8451d8c 100644 --- a/mithril-aggregator/src/services/certifier/buffered_certifier.rs +++ b/mithril-aggregator/src/services/certifier/buffered_certifier.rs @@ -198,7 +198,7 @@ mod tests { use crate::services::{ CertifierServiceError, MockBufferedSingleSignatureStore, MockCertifierService, }; - use crate::test_tools::TestLogger; + use crate::test::TestLogger; use super::*; diff --git a/mithril-aggregator/src/services/certifier/certifier_service.rs b/mithril-aggregator/src/services/certifier/certifier_service.rs index 04c7cb7be47..574867822d5 100644 --- a/mithril-aggregator/src/services/certifier/certifier_service.rs +++ b/mithril-aggregator/src/services/certifier/certifier_service.rs @@ -413,7 +413,7 @@ mod tests { use crate::{ ServeCommandConfiguration, dependency_injection::DependenciesBuilder, - multi_signer::MockMultiSigner, services::FakeEpochService, test_tools::TestLogger, + multi_signer::MockMultiSigner, services::FakeEpochService, test::TestLogger, }; use chrono::{DateTime, Days}; use mithril_common::{ diff --git a/mithril-aggregator/src/services/epoch_service.rs b/mithril-aggregator/src/services/epoch_service.rs index 09ba539d8db..5c6e9101c73 100644 --- a/mithril-aggregator/src/services/epoch_service.rs +++ b/mithril-aggregator/src/services/epoch_service.rs @@ -848,8 +848,8 @@ mod tests { }; use crate::store::{FakeEpochSettingsStorer, MockVerificationKeyStorer}; + use crate::test::TestLogger; use crate::test::mocks::MockStakeStore; - use crate::test_tools::TestLogger; use super::*; diff --git a/mithril-aggregator/src/services/prover.rs b/mithril-aggregator/src/services/prover.rs index 70ea9a2287d..e4581eb003f 100644 --- a/mithril-aggregator/src/services/prover.rs +++ b/mithril-aggregator/src/services/prover.rs @@ -217,7 +217,7 @@ mod tests { use mockall::mock; use mockall::predicate::eq; - use crate::test_tools::TestLogger; + use crate::test::TestLogger; use super::*; diff --git a/mithril-aggregator/src/services/signature_processor.rs b/mithril-aggregator/src/services/signature_processor.rs index d05ca95fbbb..65240936e90 100644 --- a/mithril-aggregator/src/services/signature_processor.rs +++ b/mithril-aggregator/src/services/signature_processor.rs @@ -112,7 +112,7 @@ mod tests { FakeSignatureConsumer, MockCertifierService, MockSignatureConsumer, SignatureRegistrationStatus, }, - test_tools::TestLogger, + test::TestLogger, }; use super::*; diff --git a/mithril-aggregator/src/services/signed_entity.rs b/mithril-aggregator/src/services/signed_entity.rs index c2a7aa1fd2d..7cd5d3531f2 100644 --- a/mithril-aggregator/src/services/signed_entity.rs +++ b/mithril-aggregator/src/services/signed_entity.rs @@ -512,7 +512,7 @@ mod tests { use crate::artifact_builder::MockArtifactBuilder; use crate::database::repository::MockSignedEntityStorer; - use crate::test_tools::TestLogger; + use crate::test::TestLogger; use super::*; diff --git a/mithril-aggregator/src/services/snapshotter/ancillary_signer/with_secret_key.rs b/mithril-aggregator/src/services/snapshotter/ancillary_signer/with_secret_key.rs index c8e7a15e64d..42b5370a42c 100644 --- a/mithril-aggregator/src/services/snapshotter/ancillary_signer/with_secret_key.rs +++ b/mithril-aggregator/src/services/snapshotter/ancillary_signer/with_secret_key.rs @@ -41,7 +41,7 @@ mod tests { use std::collections::BTreeMap; use std::path::PathBuf; - use crate::test_tools::TestLogger; + use crate::test::TestLogger; use super::*; diff --git a/mithril-aggregator/src/services/snapshotter/compressed_archive_snapshotter.rs b/mithril-aggregator/src/services/snapshotter/compressed_archive_snapshotter.rs index 35a91d19b95..900a136b204 100644 --- a/mithril-aggregator/src/services/snapshotter/compressed_archive_snapshotter.rs +++ b/mithril-aggregator/src/services/snapshotter/compressed_archive_snapshotter.rs @@ -329,7 +329,7 @@ mod tests { use mithril_common::{assert_dir_eq, current_function, temp_dir_create}; use crate::services::ancillary_signer::MockAncillarySigner; - use crate::test_tools::TestLogger; + use crate::test::TestLogger; use super::*; diff --git a/mithril-aggregator/src/services/upkeep.rs b/mithril-aggregator/src/services/upkeep.rs index e9891dcfd15..055575626e9 100644 --- a/mithril-aggregator/src/services/upkeep.rs +++ b/mithril-aggregator/src/services/upkeep.rs @@ -199,7 +199,7 @@ mod tests { use crate::event_store::database::test_helper::{ event_store_db_connection, event_store_db_file_connection, }; - use crate::test_tools::TestLogger; + use crate::test::TestLogger; use super::*; diff --git a/mithril-aggregator/src/services/usage_reporter.rs b/mithril-aggregator/src/services/usage_reporter.rs index 105baedcc54..0c1590e61a1 100644 --- a/mithril-aggregator/src/services/usage_reporter.rs +++ b/mithril-aggregator/src/services/usage_reporter.rs @@ -166,7 +166,7 @@ mod tests { use super::UsageReporter; use super::*; - use crate::test_tools::TestLogger; + use crate::test::TestLogger; fn build_usage_reporter() -> ( UsageReporter, diff --git a/mithril-aggregator/src/test/mod.rs b/mithril-aggregator/src/test/mod.rs index 3c35bb708a2..c1fb123f62e 100644 --- a/mithril-aggregator/src/test/mod.rs +++ b/mithril-aggregator/src/test/mod.rs @@ -1,3 +1,5 @@ mod double; #[cfg(test)] pub mod mocks; + +mithril_common::define_test_logger!(); diff --git a/mithril-aggregator/src/tools/certificates_hash_migrator.rs b/mithril-aggregator/src/tools/certificates_hash_migrator.rs index 4cb2d8d682d..6b477687e73 100644 --- a/mithril-aggregator/src/tools/certificates_hash_migrator.rs +++ b/mithril-aggregator/src/tools/certificates_hash_migrator.rs @@ -221,7 +221,7 @@ mod test { use crate::database::record::{CertificateRecord, SignedEntityRecord}; use crate::database::repository::SignedEntityStore; - use crate::test_tools::TestLogger; + use crate::test::TestLogger; use super::*; diff --git a/mithril-aggregator/src/tools/file_archiver/api.rs b/mithril-aggregator/src/tools/file_archiver/api.rs index 5bd1f16dc8a..e0aff2ee7ff 100644 --- a/mithril-aggregator/src/tools/file_archiver/api.rs +++ b/mithril-aggregator/src/tools/file_archiver/api.rs @@ -44,7 +44,7 @@ impl FileArchiver { #[cfg(test)] pub fn new_for_test(verification_temp_dir: PathBuf) -> Self { - use crate::test_tools::TestLogger; + use crate::test::TestLogger; Self { zstandard_compression_parameter: ZstandardCompressionParameters::default(), verification_temp_dir, diff --git a/mithril-aggregator/src/tools/genesis.rs b/mithril-aggregator/src/tools/genesis.rs index 257ca41e160..deb9bc598b7 100644 --- a/mithril-aggregator/src/tools/genesis.rs +++ b/mithril-aggregator/src/tools/genesis.rs @@ -211,7 +211,7 @@ mod tests { use std::{fs::read_to_string, path::PathBuf}; use crate::database::test_helper::main_db_connection; - use crate::test_tools::TestLogger; + use crate::test::TestLogger; use super::*; diff --git a/mithril-aggregator/src/tools/signer_importer.rs b/mithril-aggregator/src/tools/signer_importer.rs index cdf9f151a9b..0e753b5f71e 100644 --- a/mithril-aggregator/src/tools/signer_importer.rs +++ b/mithril-aggregator/src/tools/signer_importer.rs @@ -201,7 +201,7 @@ mod tests { use crate::database::repository::{SignerGetter, SignerStore}; use crate::database::test_helper::main_db_connection; use crate::http_server::routes::reply; - use crate::test_tools::TestLogger; + use crate::test::TestLogger; use super::*; diff --git a/mithril-aggregator/src/tools/single_signature_authenticator.rs b/mithril-aggregator/src/tools/single_signature_authenticator.rs index edab41fd39c..baae3b74a07 100644 --- a/mithril-aggregator/src/tools/single_signature_authenticator.rs +++ b/mithril-aggregator/src/tools/single_signature_authenticator.rs @@ -88,7 +88,7 @@ impl SingleSignatureAuthenticator { Self { multi_signer: Arc::new(multi_signer), - logger: crate::test_tools::TestLogger::stdout(), + logger: crate::test::TestLogger::stdout(), } } @@ -103,7 +103,7 @@ impl SingleSignatureAuthenticator { Self { multi_signer: Arc::new(multi_signer), - logger: crate::test_tools::TestLogger::stdout(), + logger: crate::test::TestLogger::stdout(), } } } @@ -113,7 +113,7 @@ mod tests { use anyhow::anyhow; use crate::multi_signer::MockMultiSigner; - use crate::test_tools::TestLogger; + use crate::test::TestLogger; use super::*; diff --git a/mithril-aggregator/src/tools/vacuum_tracker.rs b/mithril-aggregator/src/tools/vacuum_tracker.rs index 9b90f6ce122..d185a8b9ff6 100644 --- a/mithril-aggregator/src/tools/vacuum_tracker.rs +++ b/mithril-aggregator/src/tools/vacuum_tracker.rs @@ -90,7 +90,7 @@ impl VacuumTracker { mod tests { use mithril_common::temp_dir_create; - use crate::test_tools::TestLogger; + use crate::test::TestLogger; use super::*; diff --git a/mithril-client/src/lib.rs b/mithril-client/src/lib.rs index ca116c7934d..22647c6333e 100644 --- a/mithril-client/src/lib.rs +++ b/mithril-client/src/lib.rs @@ -144,33 +144,5 @@ pub use type_alias::*; #[cfg(test)] pub(crate) mod test_utils { - use std::io; - use std::sync::Arc; - - use slog::{Drain, Logger}; - use slog_async::Async; - use slog_term::{CompactFormat, PlainDecorator}; - - use mithril_common::test::{MemoryDrainForTest, MemoryDrainForTestInspector}; - - pub struct TestLogger; - - #[allow(unused)] - impl TestLogger { - fn from_writer(writer: W) -> Logger { - let decorator = PlainDecorator::new(writer); - let drain = CompactFormat::new(decorator).build().fuse(); - let drain = Async::new(drain).build().fuse(); - Logger::root(Arc::new(drain), slog::o!()) - } - - pub fn stdout() -> Logger { - Self::from_writer(slog_term::TestStdoutWriter) - } - - pub fn memory() -> (Logger, MemoryDrainForTestInspector) { - let (drain, inspector) = MemoryDrainForTest::new(); - (Logger::root(drain.fuse(), slog::o!()), inspector) - } - } + mithril_common::define_test_logger!(); } diff --git a/mithril-relay/src/lib.rs b/mithril-relay/src/lib.rs index 52e2ecc45e6..af3929eeec0 100644 --- a/mithril-relay/src/lib.rs +++ b/mithril-relay/src/lib.rs @@ -25,25 +25,5 @@ pub mod mithril_p2p_topic { #[cfg(test)] pub(crate) mod test_tools { - use std::io; - use std::sync::Arc; - - use slog::{Drain, Logger}; - use slog_async::Async; - use slog_term::{CompactFormat, PlainDecorator}; - - pub struct TestLogger; - - impl TestLogger { - fn from_writer(writer: W) -> Logger { - let decorator = PlainDecorator::new(writer); - let drain = CompactFormat::new(decorator).build().fuse(); - let drain = Async::new(drain).build().fuse(); - Logger::root(Arc::new(drain), slog::o!()) - } - - pub fn stdout() -> Logger { - Self::from_writer(slog_term::TestStdoutWriter) - } - } + mithril_common::define_test_logger!(); } diff --git a/mithril-signer/src/lib.rs b/mithril-signer/src/lib.rs index f84b5299ef7..5a770109531 100644 --- a/mithril-signer/src/lib.rs +++ b/mithril-signer/src/lib.rs @@ -41,31 +41,5 @@ static GLOBAL: Jemalloc = Jemalloc; #[cfg(test)] pub(crate) mod test_tools { - use std::io; - use std::sync::Arc; - - use slog::{Drain, Logger}; - use slog_async::Async; - use slog_term::{CompactFormat, PlainDecorator}; - - use mithril_common::test::{MemoryDrainForTest, MemoryDrainForTestInspector}; - pub struct TestLogger; - - impl TestLogger { - fn from_writer(writer: W) -> Logger { - let decorator = PlainDecorator::new(writer); - let drain = CompactFormat::new(decorator).build().fuse(); - let drain = Async::new(drain).build().fuse(); - Logger::root(Arc::new(drain), slog::o!()) - } - - pub fn stdout() -> Logger { - Self::from_writer(slog_term::TestStdoutWriter) - } - - pub fn memory() -> (Logger, MemoryDrainForTestInspector) { - let (drain, inspector) = MemoryDrainForTest::new(); - (Logger::root(drain.fuse(), slog::o!()), inspector) - } - } + mithril_common::define_test_logger!(); } From f0f4f266d6a5378ae10f284e36b90d997da1b5e9 Mon Sep 17 00:00:00 2001 From: DJO <790521+Alenar@users.noreply.github.com> Date: Wed, 23 Jul 2025 18:22:22 +0200 Subject: [PATCH 08/15] refactor(aggregator): move `test::mocks` to `test::double::mocks` As mocks are test double, it should have been there in the first place --- .../cardano-node/mithril-cardano-node-chain/src/test/mod.rs | 1 + .../mithril-cardano-node-internal-database/src/test/mod.rs | 1 + internal/mithril-dmq/src/test/mod.rs | 1 + .../certificate_chain_synchronizer/synchronizer_service.rs | 2 +- mithril-aggregator/src/services/epoch_service.rs | 2 +- .../src/services/signer_registration/follower.rs | 2 +- mithril-aggregator/src/services/stake_distribution.rs | 2 +- mithril-aggregator/src/test/{ => double}/mocks.rs | 0 mithril-aggregator/src/test/double/mod.rs | 6 ++++++ mithril-aggregator/src/test/mod.rs | 5 ++--- mithril-common/src/test/mod.rs | 1 + 11 files changed, 16 insertions(+), 7 deletions(-) rename mithril-aggregator/src/test/{ => double}/mocks.rs (100%) diff --git a/internal/cardano-node/mithril-cardano-node-chain/src/test/mod.rs b/internal/cardano-node/mithril-cardano-node-chain/src/test/mod.rs index 6e64d4dd5ac..33ec3bc3de9 100644 --- a/internal/cardano-node/mithril-cardano-node-chain/src/test/mod.rs +++ b/internal/cardano-node/mithril-cardano-node-chain/src/test/mod.rs @@ -8,4 +8,5 @@ pub mod double; #[cfg(test)] pub(crate) mod test_cli_runner; +#[cfg(test)] mithril_common::define_test_logger!(); diff --git a/internal/cardano-node/mithril-cardano-node-internal-database/src/test/mod.rs b/internal/cardano-node/mithril-cardano-node-internal-database/src/test/mod.rs index 4085130ea78..4da2a80e34c 100644 --- a/internal/cardano-node/mithril-cardano-node-internal-database/src/test/mod.rs +++ b/internal/cardano-node/mithril-cardano-node-internal-database/src/test/mod.rs @@ -10,4 +10,5 @@ pub mod fake_data; pub use dummy_cardano_db::{DummyCardanoDb, DummyCardanoDbBuilder}; +#[cfg(test)] mithril_common::define_test_logger!(); diff --git a/internal/mithril-dmq/src/test/mod.rs b/internal/mithril-dmq/src/test/mod.rs index f49befff326..77858983f2e 100644 --- a/internal/mithril-dmq/src/test/mod.rs +++ b/internal/mithril-dmq/src/test/mod.rs @@ -9,4 +9,5 @@ pub mod double; #[cfg(test)] pub(crate) mod payload; +#[cfg(test)] mithril_common::define_test_logger!(); diff --git a/mithril-aggregator/src/services/certificate_chain_synchronizer/synchronizer_service.rs b/mithril-aggregator/src/services/certificate_chain_synchronizer/synchronizer_service.rs index 16a1a41d486..2c39e402b0e 100644 --- a/mithril-aggregator/src/services/certificate_chain_synchronizer/synchronizer_service.rs +++ b/mithril-aggregator/src/services/certificate_chain_synchronizer/synchronizer_service.rs @@ -237,7 +237,7 @@ mod tests { MockOpenMessageStorer, MockRemoteCertificateRetriever, MockSynchronizedCertificateStorer, }; use crate::test::TestLogger; - use crate::test::mocks::MockCertificateVerifier; + use crate::test::double::mocks::MockCertificateVerifier; use super::*; diff --git a/mithril-aggregator/src/services/epoch_service.rs b/mithril-aggregator/src/services/epoch_service.rs index 5c6e9101c73..cce318f25f4 100644 --- a/mithril-aggregator/src/services/epoch_service.rs +++ b/mithril-aggregator/src/services/epoch_service.rs @@ -849,7 +849,7 @@ mod tests { use crate::store::{FakeEpochSettingsStorer, MockVerificationKeyStorer}; use crate::test::TestLogger; - use crate::test::mocks::MockStakeStore; + use crate::test::double::mocks::MockStakeStore; use super::*; diff --git a/mithril-aggregator/src/services/signer_registration/follower.rs b/mithril-aggregator/src/services/signer_registration/follower.rs index 1d2d4009204..68465ff4de3 100644 --- a/mithril-aggregator/src/services/signer_registration/follower.rs +++ b/mithril-aggregator/src/services/signer_registration/follower.rs @@ -189,7 +189,7 @@ mod tests { FakeEpochService, MockLeaderAggregatorClient, MockSignerRecorder, MockSignerRegistrationVerifier, }, - test::mocks::MockStakeStore, + test::double::mocks::MockStakeStore, }; use super::*; diff --git a/mithril-aggregator/src/services/stake_distribution.rs b/mithril-aggregator/src/services/stake_distribution.rs index e5a3b41af4e..af48d0aac0a 100644 --- a/mithril-aggregator/src/services/stake_distribution.rs +++ b/mithril-aggregator/src/services/stake_distribution.rs @@ -227,7 +227,7 @@ mod tests { use mithril_common::temp_dir; use crate::dependency_injection::DependenciesBuilder; - use crate::test::mocks::MockChainObserver; + use crate::test::double::mocks::MockChainObserver; use super::*; diff --git a/mithril-aggregator/src/test/mocks.rs b/mithril-aggregator/src/test/double/mocks.rs similarity index 100% rename from mithril-aggregator/src/test/mocks.rs rename to mithril-aggregator/src/test/double/mocks.rs diff --git a/mithril-aggregator/src/test/double/mod.rs b/mithril-aggregator/src/test/double/mod.rs index 7ee7ff27e5a..f56475fc994 100644 --- a/mithril-aggregator/src/test/double/mod.rs +++ b/mithril-aggregator/src/test/double/mod.rs @@ -1 +1,7 @@ +//! Test doubles +//! +//! Enable unit testing with controlled inputs and predictable behavior. + mod dummies; +#[cfg(test)] +pub mod mocks; diff --git a/mithril-aggregator/src/test/mod.rs b/mithril-aggregator/src/test/mod.rs index c1fb123f62e..14d1a095866 100644 --- a/mithril-aggregator/src/test/mod.rs +++ b/mithril-aggregator/src/test/mod.rs @@ -1,5 +1,4 @@ -mod double; -#[cfg(test)] -pub mod mocks; +pub mod double; +#[cfg(test)] mithril_common::define_test_logger!(); diff --git a/mithril-common/src/test/mod.rs b/mithril-common/src/test/mod.rs index 704a1479f82..879528f958a 100644 --- a/mithril-common/src/test/mod.rs +++ b/mithril-common/src/test/mod.rs @@ -17,6 +17,7 @@ mod temp_dir; pub use assert::*; pub use temp_dir::*; +#[cfg(test)] logging::define_test_logger!(); /// Return the path of the given function. From 901f644bb0ebd4aa874ce48a79596993ccd84651 Mon Sep 17 00:00:00 2001 From: DJO <790521+Alenar@users.noreply.github.com> Date: Thu, 24 Jul 2025 11:54:22 +0200 Subject: [PATCH 09/15] refactor(common): move `FakeCertificaterRetriever` to `test::double` --- .../synchronizer_service.rs | 6 ++-- .../certificate_chain/certificate_verifier.rs | 28 +++++-------------- mithril-common/src/certificate_chain/mod.rs | 7 ----- .../double/certificate_retriever.rs} | 3 +- mithril-common/src/test/double/mod.rs | 3 ++ 5 files changed, 13 insertions(+), 34 deletions(-) rename mithril-common/src/{certificate_chain/fake_certificate_retriever.rs => test/double/certificate_retriever.rs} (96%) diff --git a/mithril-aggregator/src/services/certificate_chain_synchronizer/synchronizer_service.rs b/mithril-aggregator/src/services/certificate_chain_synchronizer/synchronizer_service.rs index 2c39e402b0e..871b1442fd1 100644 --- a/mithril-aggregator/src/services/certificate_chain_synchronizer/synchronizer_service.rs +++ b/mithril-aggregator/src/services/certificate_chain_synchronizer/synchronizer_service.rs @@ -224,12 +224,10 @@ mod tests { use anyhow::anyhow; use std::sync::RwLock; - use mithril_common::certificate_chain::{ - FakeCertificaterRetriever, MithrilCertificateVerifier, - }; + use mithril_common::certificate_chain::MithrilCertificateVerifier; use mithril_common::test::{ builder::{CertificateChainBuilder, CertificateChainFixture}, - double::{fake_data, fake_keys}, + double::{FakeCertificaterRetriever, fake_data, fake_keys}, mock_extensions::MockBuilder, }; diff --git a/mithril-common/src/certificate_chain/certificate_verifier.rs b/mithril-common/src/certificate_chain/certificate_verifier.rs index 09448ae1f92..28d452bdf28 100644 --- a/mithril-common/src/certificate_chain/certificate_verifier.rs +++ b/mithril-common/src/certificate_chain/certificate_verifier.rs @@ -421,18 +421,17 @@ mod tests { use std::collections::HashMap; use async_trait::async_trait; - use mockall::mock; use tokio::sync::Mutex; - use super::CertificateRetriever; - use super::*; - - use crate::certificate_chain::{CertificateRetrieverError, FakeCertificaterRetriever}; + use crate::certificate_chain::certificate_retriever::MockCertificateRetriever; use crate::crypto_helper::{ProtocolClerk, tests_setup::*}; use crate::test::TestLogger; use crate::test::builder::{ CertificateChainBuilder, CertificateChainBuilderContext, MithrilFixtureBuilder, }; + use crate::test::double::FakeCertificaterRetriever; + + use super::*; macro_rules! assert_error_matches { ( $expected_error:path, $error:expr ) => {{ @@ -448,27 +447,14 @@ mod tests { }}; } - mock! { - pub CertificateRetrieverImpl { } - - #[async_trait] - impl CertificateRetriever for CertificateRetrieverImpl { - - async fn get_certificate_details( - &self, - certificate_hash: &str, - ) -> Result; - } - } - struct MockDependencyInjector { - mock_certificate_retriever: MockCertificateRetrieverImpl, + mock_certificate_retriever: MockCertificateRetriever, } impl MockDependencyInjector { fn new() -> MockDependencyInjector { MockDependencyInjector { - mock_certificate_retriever: MockCertificateRetrieverImpl::new(), + mock_certificate_retriever: MockCertificateRetriever::new(), } } @@ -505,7 +491,7 @@ mod tests { let verifier = MithrilCertificateVerifier::new( TestLogger::stdout(), - Arc::new(MockCertificateRetrieverImpl::new()), + Arc::new(MockCertificateRetriever::new()), ); let message_tampered = message_hash[1..].to_vec(); assert!( diff --git a/mithril-common/src/certificate_chain/mod.rs b/mithril-common/src/certificate_chain/mod.rs index dda71e61ffb..07ce00ab5cb 100644 --- a/mithril-common/src/certificate_chain/mod.rs +++ b/mithril-common/src/certificate_chain/mod.rs @@ -3,16 +3,9 @@ mod certificate_genesis; mod certificate_retriever; mod certificate_verifier; -cfg_test_tools! { - mod fake_certificate_retriever; -} pub use certificate_genesis::CertificateGenesisProducer; pub use certificate_retriever::{CertificateRetriever, CertificateRetrieverError}; pub use certificate_verifier::{ CertificateVerifier, CertificateVerifierError, MithrilCertificateVerifier, }; - -cfg_test_tools! { - pub use fake_certificate_retriever::FakeCertificaterRetriever; -} diff --git a/mithril-common/src/certificate_chain/fake_certificate_retriever.rs b/mithril-common/src/test/double/certificate_retriever.rs similarity index 96% rename from mithril-common/src/certificate_chain/fake_certificate_retriever.rs rename to mithril-common/src/test/double/certificate_retriever.rs index 4bf1d7aca76..c30b5a5b14b 100644 --- a/mithril-common/src/certificate_chain/fake_certificate_retriever.rs +++ b/mithril-common/src/test/double/certificate_retriever.rs @@ -6,10 +6,9 @@ use async_trait::async_trait; use std::collections::HashMap; use tokio::sync::RwLock; +use crate::certificate_chain::{CertificateRetriever, CertificateRetrieverError}; use crate::entities::Certificate; -use super::{CertificateRetriever, CertificateRetrieverError}; - /// A fake [CertificateRetriever] that returns a [Certificate] given its hash pub struct FakeCertificaterRetriever { certificates_map: RwLock>, diff --git a/mithril-common/src/test/double/mod.rs b/mithril-common/src/test/double/mod.rs index 492ba28fb1f..a81d0450fe2 100644 --- a/mithril-common/src/test/double/mod.rs +++ b/mithril-common/src/test/double/mod.rs @@ -2,11 +2,14 @@ //! //! Enable unit testing with controlled inputs and predictable behavior. +mod certificate_retriever; mod dummies; pub mod fake_data; pub mod fake_keys; pub(super) mod precomputed_kes_key; +pub use certificate_retriever::FakeCertificaterRetriever; + /// A trait for giving a type a dummy value. /// /// Sometimes in tests you need to provide a value for a type, but the actual value doesn't matter. From 34ba5193477039bd45ab9fb8dc9034f592bb44d0 Mon Sep 17 00:00:00 2001 From: DJO <790521+Alenar@users.noreply.github.com> Date: Thu, 24 Jul 2025 16:56:46 +0200 Subject: [PATCH 10/15] refactor(common): move `crypto_helper` test utilities to `test::crypto_helper` --- internal/mithril-dmq/src/message.rs | 4 +- internal/mithril-dmq/src/publisher/pallas.rs | 3 +- .../query/certificate/get_certificate.rs | 2 +- .../query/certificate/insert_certificate.rs | 2 +- .../insert_or_replace_certificate.rs | 3 +- .../src/database/record/certificate.rs | 2 +- .../repository/certificate_repository.rs | 2 +- .../to_cardano_transactions_proof_message.rs | 1 + mithril-aggregator/src/multi_signer.rs | 2 +- .../fake_aggregator/cardano_transaction.rs | 1 + .../certificate_chain/certificate_verifier.rs | 15 +++--- .../src/crypto_helper/cardano/kes/mod.rs | 7 --- .../cardano/kes/signer_with_key.rs | 9 ++-- .../cardano/kes/verifier_standard.rs | 9 ++-- .../cardano/key_certification.rs | 20 ++----- .../src/crypto_helper/merkle_tree.rs | 29 +---------- mithril-common/src/crypto_helper/mod.rs | 7 --- .../src/entities/single_signature.rs | 3 +- .../messages/cardano_transactions_proof.rs | 1 + .../src/test/builder/fixture_builder.rs | 6 +-- .../src/test/builder/mithril_fixture.rs | 1 + .../test/crypto_helper/cardano/extensions.rs | 52 +++++++++++++++++++ .../src/test/crypto_helper/cardano/kes/mod.rs | 5 ++ .../crypto_helper/cardano/kes/setup.rs} | 5 +- .../crypto_helper/cardano/kes/signer_fake.rs | 12 ++--- .../src/test/crypto_helper/cardano/mod.rs | 5 ++ mithril-common/src/test/crypto_helper/mod.rs | 7 +++ .../crypto_helper/setup.rs} | 8 +-- mithril-common/src/test/mod.rs | 1 + mithril-signer/src/configuration.rs | 4 +- ...te_cardano_transaction_single_signature.rs | 5 +- ...e_immutable_files_full_single_signature.rs | 5 +- mithril-signer/tests/era_switch.rs | 5 +- 33 files changed, 129 insertions(+), 114 deletions(-) create mode 100644 mithril-common/src/test/crypto_helper/cardano/extensions.rs create mode 100644 mithril-common/src/test/crypto_helper/cardano/kes/mod.rs rename mithril-common/src/{crypto_helper/cardano/kes/tests_setup.rs => test/crypto_helper/cardano/kes/setup.rs} (93%) rename mithril-common/src/{ => test}/crypto_helper/cardano/kes/signer_fake.rs (91%) create mode 100644 mithril-common/src/test/crypto_helper/cardano/mod.rs create mode 100644 mithril-common/src/test/crypto_helper/mod.rs rename mithril-common/src/{crypto_helper/tests_setup.rs => test/crypto_helper/setup.rs} (96%) diff --git a/internal/mithril-dmq/src/message.rs b/internal/mithril-dmq/src/message.rs index d7d3b89b56b..79ad7589e96 100644 --- a/internal/mithril-dmq/src/message.rs +++ b/internal/mithril-dmq/src/message.rs @@ -92,9 +92,9 @@ impl DmqMessageBuilder { mod tests { use mithril_cardano_node_chain::test::double::FakeChainObserver; use mithril_common::{ - crypto_helper::{KesSignerFake, TryToBytes}, + crypto_helper::TryToBytes, entities::{BlockNumber, ChainPoint, TimePoint}, - test::double::Dummy, + test::{crypto_helper::KesSignerFake, double::Dummy}, }; use super::*; diff --git a/internal/mithril-dmq/src/publisher/pallas.rs b/internal/mithril-dmq/src/publisher/pallas.rs index 3d000828a06..64fc089f098 100644 --- a/internal/mithril-dmq/src/publisher/pallas.rs +++ b/internal/mithril-dmq/src/publisher/pallas.rs @@ -91,9 +91,8 @@ mod tests { use mithril_cardano_node_chain::test::double::FakeChainObserver; use mithril_common::{ - crypto_helper::KesSignerFake, current_function, - test::{TempDir, double::Dummy}, + test::{TempDir, crypto_helper::KesSignerFake, double::Dummy}, }; use crate::test::{TestLogger, payload::DmqMessageTestPayload}; diff --git a/mithril-aggregator/src/database/query/certificate/get_certificate.rs b/mithril-aggregator/src/database/query/certificate/get_certificate.rs index 2474c135820..f3343da48b5 100644 --- a/mithril-aggregator/src/database/query/certificate/get_certificate.rs +++ b/mithril-aggregator/src/database/query/certificate/get_certificate.rs @@ -60,8 +60,8 @@ impl Query for GetCertificateRecordQuery { #[cfg(test)] mod tests { use mithril_common::crypto_helper::ProtocolParameters; - use mithril_common::crypto_helper::tests_setup::setup_certificate_chain; use mithril_common::test::builder::CertificateChainBuilder; + use mithril_common::test::crypto_helper::setup_certificate_chain; use mithril_persistence::sqlite::ConnectionExtensions; diff --git a/mithril-aggregator/src/database/query/certificate/insert_certificate.rs b/mithril-aggregator/src/database/query/certificate/insert_certificate.rs index 381e0321e23..93d49eba4ce 100644 --- a/mithril-aggregator/src/database/query/certificate/insert_certificate.rs +++ b/mithril-aggregator/src/database/query/certificate/insert_certificate.rs @@ -40,7 +40,7 @@ impl Query for InsertCertificateRecordQuery { #[cfg(test)] mod tests { - use mithril_common::crypto_helper::tests_setup::setup_certificate_chain; + use mithril_common::test::crypto_helper::setup_certificate_chain; use mithril_persistence::sqlite::ConnectionExtensions; use crate::database::test_helper::main_db_connection; diff --git a/mithril-aggregator/src/database/query/certificate/insert_or_replace_certificate.rs b/mithril-aggregator/src/database/query/certificate/insert_or_replace_certificate.rs index 0c28cce6b21..e604f165286 100644 --- a/mithril-aggregator/src/database/query/certificate/insert_or_replace_certificate.rs +++ b/mithril-aggregator/src/database/query/certificate/insert_or_replace_certificate.rs @@ -38,9 +38,8 @@ impl Query for InsertOrReplaceCertificateRecordQuery { mod tests { use std::collections::HashMap; - use mithril_common::crypto_helper::tests_setup::setup_certificate_chain; use mithril_common::entities::Epoch; - use mithril_common::test::double::fake_data; + use mithril_common::test::{crypto_helper::setup_certificate_chain, double::fake_data}; use mithril_persistence::sqlite::ConnectionExtensions; use crate::database::query::{GetCertificateRecordQuery, InsertCertificateRecordQuery}; diff --git a/mithril-aggregator/src/database/record/certificate.rs b/mithril-aggregator/src/database/record/certificate.rs index d05d82b62f5..e6f517565c9 100644 --- a/mithril-aggregator/src/database/record/certificate.rs +++ b/mithril-aggregator/src/database/record/certificate.rs @@ -384,7 +384,7 @@ impl SqLiteEntity for CertificateRecord { #[cfg(test)] mod tests { - use mithril_common::crypto_helper::tests_setup::setup_certificate_chain; + use mithril_common::test::crypto_helper::setup_certificate_chain; use super::*; diff --git a/mithril-aggregator/src/database/repository/certificate_repository.rs b/mithril-aggregator/src/database/repository/certificate_repository.rs index ebb985ee5a3..f1d2c4572f5 100644 --- a/mithril-aggregator/src/database/repository/certificate_repository.rs +++ b/mithril-aggregator/src/database/repository/certificate_repository.rs @@ -164,7 +164,7 @@ impl SynchronizedCertificateStorer for CertificateRepository { #[cfg(test)] mod tests { - use mithril_common::crypto_helper::tests_setup::setup_certificate_chain; + use mithril_common::test::crypto_helper::setup_certificate_chain; use crate::database::test_helper::{insert_certificate_records, main_db_connection}; diff --git a/mithril-aggregator/src/message_adapters/to_cardano_transactions_proof_message.rs b/mithril-aggregator/src/message_adapters/to_cardano_transactions_proof_message.rs index b9da5212d01..2907ffea8b9 100644 --- a/mithril-aggregator/src/message_adapters/to_cardano_transactions_proof_message.rs +++ b/mithril-aggregator/src/message_adapters/to_cardano_transactions_proof_message.rs @@ -60,6 +60,7 @@ fn try_adapt_set_proof_message( #[cfg(test)] mod tests { use mithril_common::crypto_helper::MKProof; + use mithril_common::test::crypto_helper::MKProofTestExtension; use mithril_common::test::double::Dummy; use super::*; diff --git a/mithril-aggregator/src/multi_signer.rs b/mithril-aggregator/src/multi_signer.rs index 8e6e1243560..44e81c74472 100644 --- a/mithril-aggregator/src/multi_signer.rs +++ b/mithril-aggregator/src/multi_signer.rs @@ -143,11 +143,11 @@ mod tests { use std::sync::Arc; use tokio::sync::RwLock; - use mithril_common::crypto_helper::tests_setup::*; use mithril_common::entities::{CardanoDbBeacon, Epoch, SignedEntityType, SignerWithStake}; use mithril_common::protocol::ToMessage; use mithril_common::test::{ builder::MithrilFixtureBuilder, + crypto_helper::setup_message, double::{Dummy, fake_data}, }; diff --git a/mithril-client/tests/extensions/fake_aggregator/cardano_transaction.rs b/mithril-client/tests/extensions/fake_aggregator/cardano_transaction.rs index 44dc9aac79c..7d05c948e87 100644 --- a/mithril-client/tests/extensions/fake_aggregator/cardano_transaction.rs +++ b/mithril-client/tests/extensions/fake_aggregator/cardano_transaction.rs @@ -1,6 +1,7 @@ use mithril_client::common::{BlockNumber, ProtocolMessagePartKey}; use mithril_client::{CardanoTransactionsProofs, CardanoTransactionsSetProof, MithrilCertificate}; use mithril_common::crypto_helper::{MKProof, ProtocolMkProof}; +use mithril_common::test::crypto_helper::MKProofTestExtension; use mithril_common::test::double::Dummy; use crate::extensions::routes; diff --git a/mithril-common/src/certificate_chain/certificate_verifier.rs b/mithril-common/src/certificate_chain/certificate_verifier.rs index 28d452bdf28..9de7ca53e45 100644 --- a/mithril-common/src/certificate_chain/certificate_verifier.rs +++ b/mithril-common/src/certificate_chain/certificate_verifier.rs @@ -423,13 +423,16 @@ mod tests { use async_trait::async_trait; use tokio::sync::Mutex; - use crate::certificate_chain::certificate_retriever::MockCertificateRetriever; - use crate::crypto_helper::{ProtocolClerk, tests_setup::*}; - use crate::test::TestLogger; - use crate::test::builder::{ - CertificateChainBuilder, CertificateChainBuilderContext, MithrilFixtureBuilder, + use crate::test::{ + TestLogger, + builder::{CertificateChainBuilder, CertificateChainBuilderContext, MithrilFixtureBuilder}, + crypto_helper::{setup_certificate_chain, setup_message, setup_protocol_parameters}, + double::FakeCertificaterRetriever, + }; + use crate::{ + certificate_chain::certificate_retriever::MockCertificateRetriever, + crypto_helper::ProtocolClerk, }; - use crate::test::double::FakeCertificaterRetriever; use super::*; diff --git a/mithril-common/src/crypto_helper/cardano/kes/mod.rs b/mithril-common/src/crypto_helper/cardano/kes/mod.rs index b555fe2843f..eca6050728d 100644 --- a/mithril-common/src/crypto_helper/cardano/kes/mod.rs +++ b/mithril-common/src/crypto_helper/cardano/kes/mod.rs @@ -7,10 +7,3 @@ pub use error::*; pub use interface::*; pub use signer_with_key::*; pub use verifier_standard::*; - -cfg_test_tools! { - mod signer_fake; - pub mod tests_setup; - - pub use signer_fake::*; -} diff --git a/mithril-common/src/crypto_helper/cardano/kes/signer_with_key.rs b/mithril-common/src/crypto_helper/cardano/kes/signer_with_key.rs index c2c7122f3d2..95ef80fedc4 100644 --- a/mithril-common/src/crypto_helper/cardano/kes/signer_with_key.rs +++ b/mithril-common/src/crypto_helper/cardano/kes/signer_with_key.rs @@ -64,12 +64,9 @@ impl KesSigner for KesSignerStandard { mod tests { use super::*; - use crate::crypto_helper::cardano::kes::{ - KesVerifier, KesVerifierStandard, - tests_setup::{ - KesCryptographicMaterialForTest, KesPartyIndexForTest, - create_kes_cryptographic_material, - }, + use crate::crypto_helper::cardano::kes::{KesVerifier, KesVerifierStandard}; + use crate::test::crypto_helper::{ + KesCryptographicMaterialForTest, KesPartyIndexForTest, create_kes_cryptographic_material, }; #[test] diff --git a/mithril-common/src/crypto_helper/cardano/kes/verifier_standard.rs b/mithril-common/src/crypto_helper/cardano/kes/verifier_standard.rs index bba6abac0bc..da660bb22e9 100644 --- a/mithril-common/src/crypto_helper/cardano/kes/verifier_standard.rs +++ b/mithril-common/src/crypto_helper/cardano/kes/verifier_standard.rs @@ -47,12 +47,9 @@ impl KesVerifier for KesVerifierStandard { #[cfg(test)] mod tests { - use crate::crypto_helper::cardano::kes::{ - KesSigner, KesSignerStandard, - tests_setup::{ - KesCryptographicMaterialForTest, KesPartyIndexForTest, - create_kes_cryptographic_material, - }, + use crate::crypto_helper::cardano::kes::{KesSigner, KesSignerStandard}; + use crate::test::crypto_helper::{ + KesCryptographicMaterialForTest, KesPartyIndexForTest, create_kes_cryptographic_material, }; use super::*; diff --git a/mithril-common/src/crypto_helper/cardano/key_certification.rs b/mithril-common/src/crypto_helper/cardano/key_certification.rs index 5cbd057f275..cc090c75845 100644 --- a/mithril-common/src/crypto_helper/cardano/key_certification.rs +++ b/mithril-common/src/crypto_helper/cardano/key_certification.rs @@ -101,7 +101,7 @@ pub enum ProtocolInitializerErrorWrapper { #[derive(Debug, Clone, Serialize, Deserialize)] pub struct StmInitializerWrapper { /// The Initializer - stm_initializer: Initializer, + pub(crate) stm_initializer: Initializer, /// The KES signature over the Mithril key /// @@ -214,13 +214,6 @@ impl StmInitializerWrapper { kes_signature, }) } - - cfg_test_tools! { - /// Override the protocol parameters of the `Initializer` for testing purposes only. - pub fn override_protocol_parameters(&mut self, protocol_parameters: &ProtocolParameters) { - self.stm_initializer.params = protocol_parameters.to_owned(); - } - } } /// Wrapper structure for [MithrilStm:KeyRegistration](mithril_stm::key_reg::KeyRegistration). @@ -301,14 +294,11 @@ impl KeyRegWrapper { #[cfg(test)] mod test { - use crate::crypto_helper::cardano::kes::{ - KesSignerStandard, - tests_setup::{ - KesCryptographicMaterialForTest, KesPartyIndexForTest, - create_kes_cryptographic_material, - }, - }; + use crate::crypto_helper::cardano::kes::KesSignerStandard; use crate::crypto_helper::{OpCert, SerDeShelleyFileFormat}; + use crate::test::crypto_helper::{ + KesCryptographicMaterialForTest, KesPartyIndexForTest, create_kes_cryptographic_material, + }; use rand_chacha::ChaCha20Rng; use rand_core::SeedableRng; diff --git a/mithril-common/src/crypto_helper/merkle_tree.rs b/mithril-common/src/crypto_helper/merkle_tree.rs index 9a63a0cc7b8..1a3bbc28b77 100644 --- a/mithril-common/src/crypto_helper/merkle_tree.rs +++ b/mithril-common/src/crypto_helper/merkle_tree.rs @@ -169,33 +169,6 @@ impl MKProof { .collect::>() } - cfg_test_tools! { - /// Build a [MKProof] based on the given leaves (*Test only*). - pub fn from_leaves + Clone>( - leaves: &[T], - ) -> StdResult { - Self::from_subset_of_leaves(leaves, leaves) - } - - /// Build a [MKProof] based on the given leaves (*Test only*). - pub fn from_subset_of_leaves + Clone>( - leaves: &[T], - leaves_to_verify: &[T], - ) -> StdResult { - let leaves = Self::list_to_mknode(leaves); - let leaves_to_verify = - Self::list_to_mknode(leaves_to_verify); - - let mktree = - MKTree::::new(&leaves).with_context(|| "MKTree creation should not fail")?; - mktree.compute_proof(&leaves_to_verify) - } - - fn list_to_mknode + Clone>(hashes: &[T]) -> Vec { - hashes.iter().map(|h| h.clone().into()).collect() - } - } - /// Convert the proof to bytes pub fn to_bytes(&self) -> StdResult { bincode::serde::encode_to_vec(self, bincode::config::standard()).map_err(|e| e.into()) @@ -465,6 +438,8 @@ impl Clone for MKTree { #[cfg(test)] mod tests { + use crate::test::crypto_helper::MKProofTestExtension; + use super::*; fn generate_leaves(total_leaves: usize) -> Vec { diff --git a/mithril-common/src/crypto_helper/mod.rs b/mithril-common/src/crypto_helper/mod.rs index 6ae2dc7615b..23b31c81e25 100644 --- a/mithril-common/src/crypto_helper/mod.rs +++ b/mithril-common/src/crypto_helper/mod.rs @@ -9,10 +9,6 @@ mod merkle_map; mod merkle_tree; mod types; -cfg_test_tools! { - pub mod tests_setup; -} - pub use cardano::ColdKeyGenerator; pub use cardano::{ @@ -20,9 +16,6 @@ pub use cardano::{ OpCert, ProtocolInitializerErrorWrapper, ProtocolRegistrationErrorWrapper, SerDeShelleyFileFormat, Sum6KesBytes, }; -cfg_test_tools! { - pub use cardano::KesSignerFake; -} pub use codec::*; pub use ed25519_alias::{era::*, genesis::*, manifest::*}; pub use merkle_map::{MKMap, MKMapKey, MKMapNode, MKMapProof, MKMapValue}; diff --git a/mithril-common/src/entities/single_signature.rs b/mithril-common/src/entities/single_signature.rs index 0544b6dd2c5..3d5455b08d0 100644 --- a/mithril-common/src/entities/single_signature.rs +++ b/mithril-common/src/entities/single_signature.rs @@ -109,8 +109,9 @@ impl Debug for SingleSignature { #[cfg(test)] mod tests { + use crate::test::{builder::MithrilFixtureBuilder, crypto_helper::setup_message}; + use super::*; - use crate::{crypto_helper::tests_setup::setup_message, test::builder::MithrilFixtureBuilder}; #[test] fn single_signatures_should_convert_to_protocol_signatures() { diff --git a/mithril-common/src/messages/cardano_transactions_proof.rs b/mithril-common/src/messages/cardano_transactions_proof.rs index a5aae890fbb..6739bbadd9d 100644 --- a/mithril-common/src/messages/cardano_transactions_proof.rs +++ b/mithril-common/src/messages/cardano_transactions_proof.rs @@ -189,6 +189,7 @@ mod tests { CardanoTransactionsSignableBuilder, MockBlockRangeRootRetriever, MockTransactionsImporter, SignableBuilder, }; + use crate::test::crypto_helper::MKProofTestExtension; use crate::test::double::Dummy; use super::*; diff --git a/mithril-common/src/test/builder/fixture_builder.rs b/mithril-common/src/test/builder/fixture_builder.rs index 6e0ec40f2f2..cccb8152d59 100644 --- a/mithril-common/src/test/builder/fixture_builder.rs +++ b/mithril-common/src/test/builder/fixture_builder.rs @@ -5,11 +5,11 @@ use rand_core::{RngCore, SeedableRng}; use crate::{ crypto_helper::{ ColdKeyGenerator, OpCert, ProtocolStakeDistribution, SerDeShelleyFileFormat, Sum6KesBytes, - tests_setup, tests_setup::setup_temp_directory_for_signer, }, entities::{PartyId, ProtocolParameters, Stake, StakeDistribution}, test::{ builder::MithrilFixture, + crypto_helper, double::{fake_data, precomputed_kes_key}, }, }; @@ -96,7 +96,7 @@ impl MithrilFixtureBuilder { /// Transform the specified parameters to a [MithrilFixture]. pub fn build(self) -> MithrilFixture { let protocol_stake_distribution = self.generate_stake_distribution(); - let signers = tests_setup::setup_signers_from_stake_distribution( + let signers = crypto_helper::setup_signers_from_stake_distribution( &protocol_stake_distribution, &self.protocol_parameters.clone().into(), ); @@ -208,7 +208,7 @@ impl MithrilFixtureBuilder { let party_id = operational_certificate .compute_protocol_party_id() .expect("compute protocol party id should not fail"); - let temp_dir = setup_temp_directory_for_signer(&party_id, true) + let temp_dir = crypto_helper::setup_temp_directory_for_signer(&party_id, true) .expect("setup temp directory should return a value"); if !temp_dir.join("kes.sk").exists() { kes_bytes diff --git a/mithril-common/src/test/builder/mithril_fixture.rs b/mithril-common/src/test/builder/mithril_fixture.rs index d82fbc885ee..e10515d35da 100644 --- a/mithril-common/src/test/builder/mithril_fixture.rs +++ b/mithril-common/src/test/builder/mithril_fixture.rs @@ -19,6 +19,7 @@ use crate::{ Signer, SignerWithStake, SingleSignature, Stake, StakeDistribution, StakeDistributionParty, }, protocol::{SignerBuilder, ToMessage}, + test::crypto_helper::ProtocolInitializerTestExtension, }; /// A fixture of Mithril data types. diff --git a/mithril-common/src/test/crypto_helper/cardano/extensions.rs b/mithril-common/src/test/crypto_helper/cardano/extensions.rs new file mode 100644 index 00000000000..4149d950dda --- /dev/null +++ b/mithril-common/src/test/crypto_helper/cardano/extensions.rs @@ -0,0 +1,52 @@ +use anyhow::Context; + +use crate::StdResult; +use crate::crypto_helper::{ + MKProof, MKTree, MKTreeNode, MKTreeStoreInMemory, ProtocolInitializer, ProtocolParameters, +}; + +/// Extension trait adding test utilities to [ProtocolInitializer] +pub trait ProtocolInitializerTestExtension { + /// `TEST ONLY` - Override the protocol parameters of the `Initializer` + fn override_protocol_parameters(&mut self, protocol_parameters: &ProtocolParameters); +} + +impl ProtocolInitializerTestExtension for ProtocolInitializer { + fn override_protocol_parameters(&mut self, protocol_parameters: &ProtocolParameters) { + self.stm_initializer.params = protocol_parameters.to_owned(); + } +} + +/// Extension trait adding test utilities to [MKProof] +pub trait MKProofTestExtension { + /// `TEST ONLY` - Build a [MKProof] based on the given leaves + fn from_leaves + Clone>(leaves: &[T]) -> StdResult; + + /// `TEST ONLY` - Build a [MKProof] based on the given leaves + fn from_subset_of_leaves + Clone>( + leaves: &[T], + leaves_to_verify: &[T], + ) -> StdResult; +} + +impl MKProofTestExtension for MKProof { + fn from_leaves + Clone>(leaves: &[T]) -> StdResult { + Self::from_subset_of_leaves(leaves, leaves) + } + + fn from_subset_of_leaves + Clone>( + leaves: &[T], + leaves_to_verify: &[T], + ) -> StdResult { + fn list_to_mknode + Clone>(hashes: &[T]) -> Vec { + hashes.iter().map(|h| h.clone().into()).collect() + } + + let leaves = list_to_mknode(leaves); + let leaves_to_verify = list_to_mknode(leaves_to_verify); + + let mktree = MKTree::::new(&leaves) + .with_context(|| "MKTree creation should not fail")?; + mktree.compute_proof(&leaves_to_verify) + } +} diff --git a/mithril-common/src/test/crypto_helper/cardano/kes/mod.rs b/mithril-common/src/test/crypto_helper/cardano/kes/mod.rs new file mode 100644 index 00000000000..c285e58225d --- /dev/null +++ b/mithril-common/src/test/crypto_helper/cardano/kes/mod.rs @@ -0,0 +1,5 @@ +mod setup; +mod signer_fake; + +pub(crate) use setup::*; +pub use signer_fake::*; diff --git a/mithril-common/src/crypto_helper/cardano/kes/tests_setup.rs b/mithril-common/src/test/crypto_helper/cardano/kes/setup.rs similarity index 93% rename from mithril-common/src/crypto_helper/cardano/kes/tests_setup.rs rename to mithril-common/src/test/crypto_helper/cardano/kes/setup.rs index a5fad24097b..1e46905d8dc 100644 --- a/mithril-common/src/crypto_helper/cardano/kes/tests_setup.rs +++ b/mithril-common/src/test/crypto_helper/cardano/kes/setup.rs @@ -3,8 +3,9 @@ use std::{fs, path::PathBuf}; use kes_summed_ed25519::kes::Sum6Kes; use kes_summed_ed25519::traits::KesSk; -use crate::crypto_helper::{KesPeriod, ProtocolPartyId, SerDeShelleyFileFormat, Sum6KesBytes}; -use crate::crypto_helper::{OpCert, cardano::ColdKeyGenerator}; +use crate::crypto_helper::{ + ColdKeyGenerator, KesPeriod, OpCert, ProtocolPartyId, SerDeShelleyFileFormat, Sum6KesBytes, +}; /// A type alias for the party index used in KES cryptographic material. pub type KesPartyIndexForTest = u64; diff --git a/mithril-common/src/crypto_helper/cardano/kes/signer_fake.rs b/mithril-common/src/test/crypto_helper/cardano/kes/signer_fake.rs similarity index 91% rename from mithril-common/src/crypto_helper/cardano/kes/signer_fake.rs rename to mithril-common/src/test/crypto_helper/cardano/kes/signer_fake.rs index bc1d0c1c03e..5a76f7c1ad3 100644 --- a/mithril-common/src/crypto_helper/cardano/kes/signer_fake.rs +++ b/mithril-common/src/test/crypto_helper/cardano/kes/signer_fake.rs @@ -5,15 +5,9 @@ use std::sync::Mutex; use crate::{ StdResult, - crypto_helper::{ - KesPeriod, KesSigner, OpCert, - cardano::kes::{ - KesSignerStandard, - tests_setup::{ - KesCryptographicMaterialForTest, KesPartyIndexForTest, - create_kes_cryptographic_material, - }, - }, + crypto_helper::{KesPeriod, KesSigner, KesSignerStandard, OpCert}, + test::crypto_helper::{ + KesCryptographicMaterialForTest, KesPartyIndexForTest, create_kes_cryptographic_material, }, }; diff --git a/mithril-common/src/test/crypto_helper/cardano/mod.rs b/mithril-common/src/test/crypto_helper/cardano/mod.rs new file mode 100644 index 00000000000..2bfee2ee99b --- /dev/null +++ b/mithril-common/src/test/crypto_helper/cardano/mod.rs @@ -0,0 +1,5 @@ +mod extensions; +mod kes; + +pub use extensions::*; +pub use kes::*; diff --git a/mithril-common/src/test/crypto_helper/mod.rs b/mithril-common/src/test/crypto_helper/mod.rs new file mode 100644 index 00000000000..386d3533169 --- /dev/null +++ b/mithril-common/src/test/crypto_helper/mod.rs @@ -0,0 +1,7 @@ +//! Test utilities for Mithril STM types + +mod cardano; +mod setup; + +pub use cardano::*; +pub use setup::*; diff --git a/mithril-common/src/crypto_helper/tests_setup.rs b/mithril-common/src/test/crypto_helper/setup.rs similarity index 96% rename from mithril-common/src/crypto_helper/tests_setup.rs rename to mithril-common/src/test/crypto_helper/setup.rs index 9b5342ebea8..72450ce5f72 100644 --- a/mithril-common/src/crypto_helper/tests_setup.rs +++ b/mithril-common/src/test/crypto_helper/setup.rs @@ -5,7 +5,11 @@ use rand_chacha::ChaCha20Rng; use rand_core::SeedableRng; use crate::{ - crypto_helper::{KesSigner, cardano::KesSignerStandard}, + crypto_helper::{ + KesSigner, KesSignerStandard, OpCert, ProtocolInitializer, ProtocolKeyRegistration, + ProtocolOpCert, ProtocolParameters, ProtocolPartyId, ProtocolStakeDistribution, + SerDeShelleyFileFormat, + }, entities::{ProtocolMessage, ProtocolMessagePartKey, SignerWithStake, Stake}, test::{ TempDir, @@ -13,8 +17,6 @@ use crate::{ }, }; -use super::{OpCert, SerDeShelleyFileFormat, types::*}; - /// Create or retrieve a temporary directory for storing cryptographic material for a signer, use this for tests only. pub fn setup_temp_directory_for_signer( party_id: &ProtocolPartyId, diff --git a/mithril-common/src/test/mod.rs b/mithril-common/src/test/mod.rs index 879528f958a..378aa4c4598 100644 --- a/mithril-common/src/test/mod.rs +++ b/mithril-common/src/test/mod.rs @@ -7,6 +7,7 @@ //! pub mod builder; +pub mod crypto_helper; pub mod double; pub mod logging; pub mod mock_extensions; diff --git a/mithril-signer/src/configuration.rs b/mithril-signer/src/configuration.rs index 1ef77077f3f..6ea58008e01 100644 --- a/mithril-signer/src/configuration.rs +++ b/mithril-signer/src/configuration.rs @@ -8,7 +8,6 @@ use mithril_cardano_node_chain::chain_observer::ChainObserver; use mithril_cli_helper::register_config_value; use mithril_common::{ CardanoNetwork, StdResult, - crypto_helper::tests_setup, entities::{BlockNumber, PartyId}, }; use mithril_era::{ @@ -147,7 +146,8 @@ impl Configuration { #[doc(hidden)] pub fn new_sample>(party_id: P) -> Self { let party_id: PartyId = party_id.into(); - let signer_temp_dir = tests_setup::setup_temp_directory_for_signer(&party_id, false); + let signer_temp_dir = + mithril_common::test::crypto_helper::setup_temp_directory_for_signer(&party_id, false); Self { aggregator_endpoint: "http://0.0.0.0:8000".to_string(), relay_endpoint: None, diff --git a/mithril-signer/tests/create_cardano_transaction_single_signature.rs b/mithril-signer/tests/create_cardano_transaction_single_signature.rs index 15205489f82..d87742fac27 100644 --- a/mithril-signer/tests/create_cardano_transaction_single_signature.rs +++ b/mithril-signer/tests/create_cardano_transaction_single_signature.rs @@ -1,7 +1,6 @@ mod test_extensions; use mithril_common::{ - crypto_helper::tests_setup, entities::{ BlockNumber, CardanoDbBeacon, ChainPoint, Epoch, SignedEntityType::{ @@ -9,14 +8,14 @@ use mithril_common::{ }, SignedEntityTypeDiscriminants, SlotNumber, TimePoint, }, - test::builder::MithrilFixtureBuilder, + test::{builder::MithrilFixtureBuilder, crypto_helper}, }; use test_extensions::StateMachineTester; #[rustfmt::skip] #[tokio::test] async fn test_create_cardano_transaction_single_signature() { - let protocol_parameters = tests_setup::setup_protocol_parameters(); + let protocol_parameters = crypto_helper::setup_protocol_parameters(); let fixture = MithrilFixtureBuilder::default() .with_signers(10) .with_protocol_parameters(protocol_parameters.into()) diff --git a/mithril-signer/tests/create_immutable_files_full_single_signature.rs b/mithril-signer/tests/create_immutable_files_full_single_signature.rs index f498851b5be..811da67976b 100644 --- a/mithril-signer/tests/create_immutable_files_full_single_signature.rs +++ b/mithril-signer/tests/create_immutable_files_full_single_signature.rs @@ -5,16 +5,15 @@ use mithril_common::entities::SignedEntityType::{ }; use mithril_common::entities::{CardanoDbBeacon, SignedEntityTypeDiscriminants}; use mithril_common::{ - crypto_helper::tests_setup, entities::{BlockNumber, ChainPoint, Epoch, SlotNumber, TimePoint}, - test::builder::MithrilFixtureBuilder, + test::{builder::MithrilFixtureBuilder, crypto_helper}, }; use test_extensions::StateMachineTester; #[rustfmt::skip] #[tokio::test] async fn test_create_immutable_files_full_single_signature() { - let protocol_parameters = tests_setup::setup_protocol_parameters(); + let protocol_parameters = crypto_helper::setup_protocol_parameters(); let fixture = MithrilFixtureBuilder::default().with_signers(10).with_protocol_parameters(protocol_parameters.into()).build(); let signers_with_stake = fixture.signers_with_stake(); let initial_time_point = TimePoint { diff --git a/mithril-signer/tests/era_switch.rs b/mithril-signer/tests/era_switch.rs index 1ddfd7555cb..e2d636ada15 100644 --- a/mithril-signer/tests/era_switch.rs +++ b/mithril-signer/tests/era_switch.rs @@ -1,9 +1,8 @@ mod test_extensions; use mithril_common::{ - crypto_helper::tests_setup, entities::{BlockNumber, ChainPoint, Epoch, SlotNumber, SupportedEra, TimePoint}, - test::{builder::MithrilFixtureBuilder, double::Dummy}, + test::{builder::MithrilFixtureBuilder, crypto_helper, double::Dummy}, }; use mithril_era::EraMarker; use test_extensions::StateMachineTester; @@ -11,7 +10,7 @@ use test_extensions::StateMachineTester; #[rustfmt::skip] #[tokio::test] async fn era_fail_at_startup() { - let protocol_parameters = tests_setup::setup_protocol_parameters(); + let protocol_parameters = crypto_helper::setup_protocol_parameters(); let fixture = MithrilFixtureBuilder::default().with_signers(10).with_protocol_parameters(protocol_parameters.into()).build(); let signers_with_stake = fixture.signers_with_stake(); let initial_time_point = TimePoint { From 69457481250df93269206e947466849daad6aa0f Mon Sep 17 00:00:00 2001 From: DJO <790521+Alenar@users.noreply.github.com> Date: Thu, 24 Jul 2025 17:05:51 +0200 Subject: [PATCH 11/15] refactor(common): move `DummyApiVersionDiscriminantSource` to `test::double` --- .../src/services/aggregator_client.rs | 3 +- mithril-common/src/api_version.rs | 32 ++----------------- mithril-common/src/test/double/api_version.rs | 29 +++++++++++++++++ mithril-common/src/test/double/mod.rs | 2 ++ .../src/services/aggregator_client.rs | 3 +- 5 files changed, 35 insertions(+), 34 deletions(-) create mode 100644 mithril-common/src/test/double/api_version.rs diff --git a/mithril-aggregator/src/services/aggregator_client.rs b/mithril-aggregator/src/services/aggregator_client.rs index cfad2b7f15e..836993c8721 100644 --- a/mithril-aggregator/src/services/aggregator_client.rs +++ b/mithril-aggregator/src/services/aggregator_client.rs @@ -421,9 +421,8 @@ mod tests { use reqwest::IntoUrl; use serde_json::json; - use mithril_common::api_version::DummyApiVersionDiscriminantSource; use mithril_common::messages::CertificateListItemMessage; - use mithril_common::test::double::Dummy; + use mithril_common::test::double::{Dummy, DummyApiVersionDiscriminantSource}; use crate::test::TestLogger; diff --git a/mithril-common/src/api_version.rs b/mithril-common/src/api_version.rs index 9c21216979d..3d069df2113 100644 --- a/mithril-common/src/api_version.rs +++ b/mithril-common/src/api_version.rs @@ -73,38 +73,10 @@ impl APIVersionProvider { } } -cfg_test_tools! { - /// A dummy implementation of the `ApiVersionDiscriminantSource` trait for testing purposes. - pub struct DummyApiVersionDiscriminantSource { - discriminant: String, - } - - impl DummyApiVersionDiscriminantSource { - /// Create a new instance of `DummyApiVersionDiscriminantSource` with the given discriminant. - pub fn new>(discrimant: T) -> Self { - Self { - discriminant: discrimant.into(), - } - } - } - - impl Default for DummyApiVersionDiscriminantSource { - fn default() -> Self { - Self { - discriminant: "dummy".to_string(), - } - } - } - - impl ApiVersionDiscriminantSource for DummyApiVersionDiscriminantSource { - fn get_discriminant(&self) -> String { - self.discriminant.clone() - } - } -} - #[cfg(test)] mod test { + use crate::test::double::DummyApiVersionDiscriminantSource; + use super::*; #[test] diff --git a/mithril-common/src/test/double/api_version.rs b/mithril-common/src/test/double/api_version.rs new file mode 100644 index 00000000000..d1455dfd84f --- /dev/null +++ b/mithril-common/src/test/double/api_version.rs @@ -0,0 +1,29 @@ +use crate::api_version::ApiVersionDiscriminantSource; + +/// A dummy implementation of the `ApiVersionDiscriminantSource` trait for testing purposes. +pub struct DummyApiVersionDiscriminantSource { + discriminant: String, +} + +impl DummyApiVersionDiscriminantSource { + /// Create a new instance of `DummyApiVersionDiscriminantSource` with the given discriminant. + pub fn new>(discrimant: T) -> Self { + Self { + discriminant: discrimant.into(), + } + } +} + +impl Default for DummyApiVersionDiscriminantSource { + fn default() -> Self { + Self { + discriminant: "dummy".to_string(), + } + } +} + +impl ApiVersionDiscriminantSource for DummyApiVersionDiscriminantSource { + fn get_discriminant(&self) -> String { + self.discriminant.clone() + } +} diff --git a/mithril-common/src/test/double/mod.rs b/mithril-common/src/test/double/mod.rs index a81d0450fe2..31fe8acc671 100644 --- a/mithril-common/src/test/double/mod.rs +++ b/mithril-common/src/test/double/mod.rs @@ -2,12 +2,14 @@ //! //! Enable unit testing with controlled inputs and predictable behavior. +mod api_version; mod certificate_retriever; mod dummies; pub mod fake_data; pub mod fake_keys; pub(super) mod precomputed_kes_key; +pub use api_version::DummyApiVersionDiscriminantSource; pub use certificate_retriever::FakeCertificaterRetriever; /// A trait for giving a type a dummy value. diff --git a/mithril-signer/src/services/aggregator_client.rs b/mithril-signer/src/services/aggregator_client.rs index 35520158050..d5695a68ba7 100644 --- a/mithril-signer/src/services/aggregator_client.rs +++ b/mithril-signer/src/services/aggregator_client.rs @@ -470,11 +470,10 @@ mod tests { use semver::Version; use serde_json::json; - use mithril_common::api_version::DummyApiVersionDiscriminantSource; use mithril_common::entities::Epoch; use mithril_common::messages::TryFromMessageAdapter; use mithril_common::test::{ - double::{Dummy, fake_data}, + double::{Dummy, DummyApiVersionDiscriminantSource, fake_data}, logging::MemoryDrainForTestInspector, }; From 909f1752f20b7daef6b69617d2a5de094be22796 Mon Sep 17 00:00:00 2001 From: DJO <790521+Alenar@users.noreply.github.com> Date: Thu, 24 Jul 2025 17:40:04 +0200 Subject: [PATCH 12/15] refactor(common): transform test only methods on entities into extension traits This allow a clean split between the production and test code even when using thoses methods as to do so you will now need to import a trait located in the `mithril_common::test` module. one caveat: in order to transform `Blockrange::new` into a extension trait method, its `inner_range` property had to be made `pub(crate)`. --- .../buffered_single_signature_record.rs | 3 + .../services/certifier/buffered_certifier.rs | 1 + .../tools/single_signature_authenticator.rs | 2 + .../src/crypto_helper/merkle_map.rs | 1 + mithril-common/src/entities/block_range.rs | 47 +----- .../cardano_transactions_set_proof.rs | 46 +----- .../src/entities/signed_entity_config.rs | 1 - .../src/entities/single_signature.rs | 28 ---- .../messages/cardano_transactions_proof.rs | 1 + mithril-common/src/test/double/dummies.rs | 1 + .../src/test/entities_extensions.rs | 149 ++++++++++++++++++ mithril-common/src/test/mod.rs | 1 + 12 files changed, 166 insertions(+), 115 deletions(-) create mode 100644 mithril-common/src/test/entities_extensions.rs diff --git a/mithril-aggregator/src/database/record/buffered_single_signature_record.rs b/mithril-aggregator/src/database/record/buffered_single_signature_record.rs index acff5acc0c3..6a302464145 100644 --- a/mithril-aggregator/src/database/record/buffered_single_signature_record.rs +++ b/mithril-aggregator/src/database/record/buffered_single_signature_record.rs @@ -3,7 +3,10 @@ use chrono::{DateTime, Utc}; use mithril_common::entities::{ HexEncodedSingleSignature, LotteryIndex, SignedEntityTypeDiscriminants, SingleSignature, }; +#[cfg(test)] +use mithril_common::test::entities_extensions::SingleSignatureTestExtension; use mithril_common::{StdError, StdResult}; + use mithril_persistence::sqlite::{HydrationError, Projection, SqLiteEntity}; /// `BufferedSingleSignatureRecord` record is the representation of a buffered single_signature diff --git a/mithril-aggregator/src/services/certifier/buffered_certifier.rs b/mithril-aggregator/src/services/certifier/buffered_certifier.rs index f1bc8451d8c..322a52f83a1 100644 --- a/mithril-aggregator/src/services/certifier/buffered_certifier.rs +++ b/mithril-aggregator/src/services/certifier/buffered_certifier.rs @@ -192,6 +192,7 @@ mod tests { }; use mithril_common::entities::SingleSignatureAuthenticationStatus; use mithril_common::test::double::{Dummy, fake_data}; + use mithril_common::test::entities_extensions::SingleSignatureTestExtension; use crate::database::repository::BufferedSingleSignatureRepository; use crate::database::test_helper::main_db_connection; diff --git a/mithril-aggregator/src/tools/single_signature_authenticator.rs b/mithril-aggregator/src/tools/single_signature_authenticator.rs index baae3b74a07..cbec2451833 100644 --- a/mithril-aggregator/src/tools/single_signature_authenticator.rs +++ b/mithril-aggregator/src/tools/single_signature_authenticator.rs @@ -112,6 +112,8 @@ impl SingleSignatureAuthenticator { mod tests { use anyhow::anyhow; + use mithril_common::test::entities_extensions::SingleSignatureTestExtension; + use crate::multi_signer::MockMultiSigner; use crate::test::TestLogger; diff --git a/mithril-common/src/crypto_helper/merkle_map.rs b/mithril-common/src/crypto_helper/merkle_map.rs index 55d757333cd..22c8bc9bb6c 100644 --- a/mithril-common/src/crypto_helper/merkle_map.rs +++ b/mithril-common/src/crypto_helper/merkle_map.rs @@ -468,6 +468,7 @@ mod tests { use crate::{ crypto_helper::MKTreeStoreInMemory, entities::{BlockNumber, BlockRange}, + test::entities_extensions::BlockRangeTestExtension, }; use super::*; diff --git a/mithril-common/src/entities/block_range.rs b/mithril-common/src/entities/block_range.rs index 3bb09cc818a..82853c73d3c 100644 --- a/mithril-common/src/entities/block_range.rs +++ b/mithril-common/src/entities/block_range.rs @@ -19,7 +19,7 @@ pub type BlockRangeLength = BlockNumber; /// BlockRange for the Cardano chain #[derive(Serialize, Deserialize, Clone, Eq, PartialEq, Debug, Hash)] pub struct BlockRange { - inner_range: Range, + pub(crate) inner_range: Range, } impl BlockRange { @@ -27,33 +27,6 @@ impl BlockRange { /// Important: this value should be updated with extreme care (probably with an era change) in order to avoid signing disruptions. pub const LENGTH: BlockRangeLength = BlockNumber(15); - cfg_test_tools! { - /// BlockRange factory - pub fn new(start: u64, end: u64) -> Self { - Self { - inner_range: BlockNumber(start)..BlockNumber(end), - } - } - - /// Try to add two BlockRanges - pub fn try_add(&self, other: &BlockRange) -> StdResult { - if self.inner_range.end.max(other.inner_range.end) - < self.inner_range.start.min(other.inner_range.start) - { - return Err(anyhow!( - "BlockRange cannot be added as they don't strictly overlap" - )); - } - - Ok(Self { - inner_range: Range { - start: self.inner_range.start.min(other.inner_range.start), - end: self.inner_range.end.max(other.inner_range.end), - }, - }) - } - } - /// Get the start of the block range that contains the given block number pub fn start(number: BlockNumber) -> BlockNumber { Self::start_with_length(number, Self::LENGTH) @@ -232,6 +205,8 @@ impl ExactSizeIterator for BlockRangesSequence { mod tests { use std::ops::Not; + use crate::test::entities_extensions::BlockRangeTestExtension; + use super::*; #[test] @@ -259,22 +234,6 @@ mod tests { assert!(BlockRange::new(1, 11) < BlockRange::new(2, 10)); } - #[test] - fn test_block_range_try_add() { - assert_eq!( - BlockRange::new(1, 10).try_add(&BlockRange::new(1, 10)).unwrap(), - BlockRange::new(1, 10) - ); - assert_eq!( - BlockRange::new(1, 10).try_add(&BlockRange::new(1, 11)).unwrap(), - BlockRange::new(1, 11) - ); - assert_eq!( - BlockRange::new(1, 10).try_add(&BlockRange::new(2, 10)).unwrap(), - BlockRange::new(1, 10) - ); - } - #[test] fn test_block_range_start() { assert_eq!(BlockRange::start(BlockNumber(0)), 0); diff --git a/mithril-common/src/entities/cardano_transactions_set_proof.rs b/mithril-common/src/entities/cardano_transactions_set_proof.rs index 4ec4a1bbc07..4423d9f4339 100644 --- a/mithril-common/src/entities/cardano_transactions_set_proof.rs +++ b/mithril-common/src/entities/cardano_transactions_set_proof.rs @@ -4,12 +4,6 @@ use crate::entities::TransactionHash; use super::BlockRange; -cfg_test_tools! { - use crate::crypto_helper::{MKMap, MKTree, MKTreeNode, MKMapNode, MKTreeStorer, MKTreeStoreInMemory}; - use crate::entities::BlockNumber; - use std::collections::HashMap; -} - /// A cryptographic proof of a set of Cardano transactions is included in the global Cardano transactions set #[derive(Clone, Debug, PartialEq)] pub struct CardanoTransactionsSetProof { @@ -51,46 +45,14 @@ impl CardanoTransactionsSetProof { Ok(()) } - - cfg_test_tools! { - /// Helper to create a proof from a list of leaves - pub fn from_leaves(leaves: &[(BlockNumber, TransactionHash)]) -> StdResult { - let transactions_hashes: Vec = - leaves.iter().map(|(_, t)| t.into()).collect(); - let mut transactions_by_block_ranges: HashMap> = - HashMap::new(); - for (block_number, transaction_hash) in leaves { - let block_range = BlockRange::from_block_number(*block_number); - transactions_by_block_ranges - .entry(block_range) - .or_default() - .push(transaction_hash.to_owned()); - } - let mk_map = MKMap::<_, _, MKTreeStoreInMemory>::new( - transactions_by_block_ranges - .into_iter() - .try_fold( - vec![], - |mut acc, (block_range, transactions)| -> StdResult)>> { - acc.push((block_range, MKTree::::new(&transactions)?.into())); - Ok(acc) - }, - )? - .as_slice(), - )?; - let mk_leaves: Vec = transactions_hashes - .iter() - .map(|h| h.to_owned().into()) - .collect(); - let mk_proof = mk_map.compute_proof(&mk_leaves)?; - Ok(Self::new(transactions_hashes, mk_proof)) - } - - } } #[cfg(test)] mod tests { + use crate::crypto_helper::MKTreeStoreInMemory; + use crate::entities::BlockNumber; + use crate::test::entities_extensions::CardanoTransactionsSetProofTestExtension; + use super::*; #[test] diff --git a/mithril-common/src/entities/signed_entity_config.rs b/mithril-common/src/entities/signed_entity_config.rs index 4abc6cfacc0..6c42f6011cd 100644 --- a/mithril-common/src/entities/signed_entity_config.rs +++ b/mithril-common/src/entities/signed_entity_config.rs @@ -120,7 +120,6 @@ impl CardanoTransactionsSigningConfig { step, } } - } /// Compute the block number to be signed based on the chain tip block number. diff --git a/mithril-common/src/entities/single_signature.rs b/mithril-common/src/entities/single_signature.rs index 3d5455b08d0..dc5c411f9e7 100644 --- a/mithril-common/src/entities/single_signature.rs +++ b/mithril-common/src/entities/single_signature.rs @@ -62,34 +62,6 @@ impl SingleSignature { } } -cfg_test_tools! { -impl SingleSignature { - /// Create a fake [SingleSignature] with valid cryptographic data for testing purposes. - pub fn fake, TMessage: Into>(party_id: TPartyId, message: TMessage) -> Self { - use crate::entities::{ProtocolParameters}; - use crate::test::builder::{MithrilFixtureBuilder, StakeDistributionGenerationMethod}; - - let party_id = party_id.into(); - let message = message.into(); - - let fixture = MithrilFixtureBuilder::default() - .with_stake_distribution(StakeDistributionGenerationMethod::Custom( - std::collections::BTreeMap::from([(party_id.to_string(), 100)]), - )) - .with_protocol_parameters(ProtocolParameters::new(1, 1, 1.0)) - .build(); - let signature = fixture.signers_fixture()[0].sign(&message).unwrap(); - - Self { - party_id, - signature: signature.signature, - won_indexes: vec![10, 15], - authentication_status: SingleSignatureAuthenticationStatus::Unauthenticated, - } - } -} -} - impl Debug for SingleSignature { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { let is_pretty_printing = f.alternate(); diff --git a/mithril-common/src/messages/cardano_transactions_proof.rs b/mithril-common/src/messages/cardano_transactions_proof.rs index 6739bbadd9d..13e3d01389f 100644 --- a/mithril-common/src/messages/cardano_transactions_proof.rs +++ b/mithril-common/src/messages/cardano_transactions_proof.rs @@ -191,6 +191,7 @@ mod tests { }; use crate::test::crypto_helper::MKProofTestExtension; use crate::test::double::Dummy; + use crate::test::entities_extensions::CardanoTransactionsSetProofTestExtension; use super::*; diff --git a/mithril-common/src/test/double/dummies.rs b/mithril-common/src/test/double/dummies.rs index 5733a225d47..1a3b0ed6733 100644 --- a/mithril-common/src/test/double/dummies.rs +++ b/mithril-common/src/test/double/dummies.rs @@ -5,6 +5,7 @@ use crate::test::double::{Dummy, fake_data, fake_keys}; mod entities { use crate::crypto_helper::MKTreeStoreInMemory; use crate::entities::*; + use crate::test::entities_extensions::CardanoTransactionsSetProofTestExtension; use super::*; diff --git a/mithril-common/src/test/entities_extensions.rs b/mithril-common/src/test/entities_extensions.rs new file mode 100644 index 00000000000..85098a6e712 --- /dev/null +++ b/mithril-common/src/test/entities_extensions.rs @@ -0,0 +1,149 @@ +//! A set of extension traits to add test utilities to this crate `entities` + +use std::collections::HashMap; +use std::ops::Range; + +use anyhow::anyhow; + +use crate::StdResult; +use crate::crypto_helper::{ + MKMap, MKMapNode, MKTree, MKTreeNode, MKTreeStoreInMemory, MKTreeStorer, +}; +use crate::entities::{ + BlockNumber, BlockRange, CardanoTransactionsSetProof, ProtocolParameters, SingleSignature, + SingleSignatureAuthenticationStatus, TransactionHash, +}; +use crate::test::builder::{MithrilFixtureBuilder, StakeDistributionGenerationMethod}; + +/// Extension trait adding test utilities to [BlockRange] +pub trait BlockRangeTestExtension { + /// `TEST ONLY` - BlockRange factory + fn new(start: u64, end: u64) -> Self; + + /// `TEST ONLY` - Try to add two BlockRanges + fn try_add(&self, other: &BlockRange) -> StdResult; +} + +impl BlockRangeTestExtension for BlockRange { + fn new(start: u64, end: u64) -> Self { + Self { + inner_range: BlockNumber(start)..BlockNumber(end), + } + } + + fn try_add(&self, other: &BlockRange) -> StdResult { + if self.inner_range.end.max(other.inner_range.end) + < self.inner_range.start.min(other.inner_range.start) + { + return Err(anyhow!( + "BlockRange cannot be added as they don't strictly overlap" + )); + } + + Ok(Self { + inner_range: Range { + start: self.inner_range.start.min(other.inner_range.start), + end: self.inner_range.end.max(other.inner_range.end), + }, + }) + } +} + +/// Extension trait adding test utilities to [CardanoTransactionsSetProof] +pub trait CardanoTransactionsSetProofTestExtension { + /// `TEST ONLY` - Helper to create a proof from a list of leaves + fn from_leaves( + leaves: &[(BlockNumber, TransactionHash)], + ) -> StdResult; +} + +impl CardanoTransactionsSetProofTestExtension for CardanoTransactionsSetProof { + fn from_leaves( + leaves: &[(BlockNumber, TransactionHash)], + ) -> StdResult { + let transactions_hashes: Vec = + leaves.iter().map(|(_, t)| t.into()).collect(); + let mut transactions_by_block_ranges: HashMap> = + HashMap::new(); + for (block_number, transaction_hash) in leaves { + let block_range = BlockRange::from_block_number(*block_number); + transactions_by_block_ranges + .entry(block_range) + .or_default() + .push(transaction_hash.to_owned()); + } + let mk_map = MKMap::<_, _, MKTreeStoreInMemory>::new( + transactions_by_block_ranges + .into_iter() + .try_fold( + vec![], + |mut acc, + (block_range, transactions)| + -> StdResult)>> { + acc.push((block_range, MKTree::::new(&transactions)?.into())); + Ok(acc) + }, + )? + .as_slice(), + )?; + let mk_leaves: Vec = + transactions_hashes.iter().map(|h| h.to_owned().into()).collect(); + let mk_proof = mk_map.compute_proof(&mk_leaves)?; + Ok(Self::new(transactions_hashes, mk_proof)) + } +} + +/// Extension trait adding test utilities to [SingleSignature] +pub trait SingleSignatureTestExtension { + /// `TEST ONLY` - Create a fake [SingleSignature] with valid cryptographic data for testing purposes. + fn fake, TMessage: Into>( + party_id: TPartyId, + message: TMessage, + ) -> SingleSignature; +} + +impl SingleSignatureTestExtension for SingleSignature { + fn fake, TMessage: Into>( + party_id: TPartyId, + message: TMessage, + ) -> SingleSignature { + let party_id = party_id.into(); + let message = message.into(); + + let fixture = MithrilFixtureBuilder::default() + .with_stake_distribution(StakeDistributionGenerationMethod::Custom( + std::collections::BTreeMap::from([(party_id.to_string(), 100)]), + )) + .with_protocol_parameters(ProtocolParameters::new(1, 1, 1.0)) + .build(); + let signature = fixture.signers_fixture()[0].sign(&message).unwrap(); + + Self { + party_id, + signature: signature.signature, + won_indexes: vec![10, 15], + authentication_status: SingleSignatureAuthenticationStatus::Unauthenticated, + } + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_block_range_try_add() { + assert_eq!( + BlockRange::new(1, 10).try_add(&BlockRange::new(1, 10)).unwrap(), + BlockRange::new(1, 10) + ); + assert_eq!( + BlockRange::new(1, 10).try_add(&BlockRange::new(1, 11)).unwrap(), + BlockRange::new(1, 11) + ); + assert_eq!( + BlockRange::new(1, 10).try_add(&BlockRange::new(2, 10)).unwrap(), + BlockRange::new(1, 10) + ); + } +} diff --git a/mithril-common/src/test/mod.rs b/mithril-common/src/test/mod.rs index 378aa4c4598..39d5f18ea5c 100644 --- a/mithril-common/src/test/mod.rs +++ b/mithril-common/src/test/mod.rs @@ -9,6 +9,7 @@ pub mod builder; pub mod crypto_helper; pub mod double; +pub mod entities_extensions; pub mod logging; pub mod mock_extensions; From d9b185171a44569f42f01c8beb56606abc4d2c7e Mon Sep 17 00:00:00 2001 From: DJO <790521+Alenar@users.noreply.github.com> Date: Thu, 24 Jul 2025 18:01:42 +0200 Subject: [PATCH 13/15] refactor(common): remove test only `CardanoTransactionsSigningConfig::new` Has its value was low and it was even confusing since both parameters use the same type. This allow to remove the last usage of `cfg_test_tools` in mithril common, beside the one on the test module. --- .../epoch_settings/get_epoch_settings.rs | 5 ++- .../epoch_settings/update_epoch_settings.rs | 8 ++--- .../src/database/test_helper.rs | 13 +++++--- .../src/services/epoch_service.rs | 6 ++-- mithril-aggregator/src/services/message.rs | 32 +++++++++---------- .../src/entities/signed_entity_config.rs | 10 ------ 6 files changed, 36 insertions(+), 38 deletions(-) diff --git a/mithril-aggregator/src/database/query/epoch_settings/get_epoch_settings.rs b/mithril-aggregator/src/database/query/epoch_settings/get_epoch_settings.rs index 95194f4038c..670f623e114 100644 --- a/mithril-aggregator/src/database/query/epoch_settings/get_epoch_settings.rs +++ b/mithril-aggregator/src/database/query/epoch_settings/get_epoch_settings.rs @@ -69,7 +69,10 @@ mod tests { ); assert_eq!( - CardanoTransactionsSigningConfig::new(BlockNumber(10), BlockNumber(15)), + CardanoTransactionsSigningConfig { + security_parameter: BlockNumber(10), + step: BlockNumber(15) + }, epoch_settings_record.cardano_transactions_signing_config ); diff --git a/mithril-aggregator/src/database/query/epoch_settings/update_epoch_settings.rs b/mithril-aggregator/src/database/query/epoch_settings/update_epoch_settings.rs index b20211f22f2..d21c1312059 100644 --- a/mithril-aggregator/src/database/query/epoch_settings/update_epoch_settings.rs +++ b/mithril-aggregator/src/database/query/epoch_settings/update_epoch_settings.rs @@ -68,10 +68,10 @@ mod tests { let epoch_settings_send_to_update = AggregatorEpochSettings { protocol_parameters: fake_data::protocol_parameters(), - cardano_transactions_signing_config: CardanoTransactionsSigningConfig::new( - BlockNumber(24), - BlockNumber(62), - ), + cardano_transactions_signing_config: CardanoTransactionsSigningConfig { + security_parameter: BlockNumber(24), + step: BlockNumber(62), + }, }; let record_returned_by_update_query = connection .fetch_first(UpdateEpochSettingsQuery::one( diff --git a/mithril-aggregator/src/database/test_helper.rs b/mithril-aggregator/src/database/test_helper.rs index 68ae6dba06f..9d3ed820bc4 100644 --- a/mithril-aggregator/src/database/test_helper.rs +++ b/mithril-aggregator/src/database/test_helper.rs @@ -205,10 +205,10 @@ pub fn insert_epoch_settings( Epoch(1), AggregatorEpochSettings { protocol_parameters: ProtocolParameters::new(1, 2, 1.0), - cardano_transactions_signing_config: CardanoTransactionsSigningConfig::new( - BlockNumber(0), - BlockNumber(0), - ), + cardano_transactions_signing_config: CardanoTransactionsSigningConfig { + security_parameter: BlockNumber(0), + step: BlockNumber(0), + }, }, ) .filters() @@ -222,7 +222,10 @@ pub fn insert_epoch_settings( ( epoch, ProtocolParameters::new(*epoch, epoch + 1, 1.0), - CardanoTransactionsSigningConfig::new(BlockNumber(epoch * 10), BlockNumber(15)), + CardanoTransactionsSigningConfig { + security_parameter: BlockNumber(epoch * 10), + step: BlockNumber(15), + }, ) }) { diff --git a/mithril-aggregator/src/services/epoch_service.rs b/mithril-aggregator/src/services/epoch_service.rs index cce318f25f4..3c9a109b534 100644 --- a/mithril-aggregator/src/services/epoch_service.rs +++ b/mithril-aggregator/src/services/epoch_service.rs @@ -1125,8 +1125,10 @@ mod tests { async fn inform_epoch_get_signed_entity_config_from_its_dependencies_and_store() { let epoch = Epoch(5); - let cardano_transactions_signing_config = - CardanoTransactionsSigningConfig::new(BlockNumber(29), BlockNumber(986)); + let cardano_transactions_signing_config = CardanoTransactionsSigningConfig { + security_parameter: BlockNumber(29), + step: BlockNumber(986), + }; let allowed_discriminants = BTreeSet::from([ SignedEntityTypeDiscriminants::CardanoTransactions, SignedEntityTypeDiscriminants::CardanoImmutableFilesFull, diff --git a/mithril-aggregator/src/services/message.rs b/mithril-aggregator/src/services/message.rs index 37fb00dba68..9e8f3d4f83d 100644 --- a/mithril-aggregator/src/services/message.rs +++ b/mithril-aggregator/src/services/message.rs @@ -467,17 +467,17 @@ mod tests { assert_eq!(message.next_signers.len(), 3); assert_eq!( message.cardano_transactions_signing_config, - Some(CardanoTransactionsSigningConfig::new( - BlockNumber(0), - BlockNumber(15) - )) + Some(CardanoTransactionsSigningConfig { + security_parameter: BlockNumber(0), + step: BlockNumber(15) + }) ); assert_eq!( message.next_cardano_transactions_signing_config, - Some(CardanoTransactionsSigningConfig::new( - BlockNumber(0), - BlockNumber(15) - )) + Some(CardanoTransactionsSigningConfig { + security_parameter: BlockNumber(0), + step: BlockNumber(15) + }) ); } @@ -561,17 +561,17 @@ mod tests { #[tokio::test] async fn get_epoch_settings_message_retrieves_signing_configuration_from_epoch_service() { let current_epoch_settings = AggregatorEpochSettings { - cardano_transactions_signing_config: CardanoTransactionsSigningConfig::new( - BlockNumber(100), - BlockNumber(15), - ), + cardano_transactions_signing_config: CardanoTransactionsSigningConfig { + security_parameter: BlockNumber(100), + step: BlockNumber(15), + }, ..AggregatorEpochSettings::dummy() }; let next_epoch_settings = AggregatorEpochSettings { - cardano_transactions_signing_config: CardanoTransactionsSigningConfig::new( - BlockNumber(200), - BlockNumber(15), - ), + cardano_transactions_signing_config: CardanoTransactionsSigningConfig { + security_parameter: BlockNumber(200), + step: BlockNumber(15), + }, ..AggregatorEpochSettings::dummy() }; let epoch_service = FakeEpochServiceBuilder { diff --git a/mithril-common/src/entities/signed_entity_config.rs b/mithril-common/src/entities/signed_entity_config.rs index 6c42f6011cd..e1e69f65ded 100644 --- a/mithril-common/src/entities/signed_entity_config.rs +++ b/mithril-common/src/entities/signed_entity_config.rs @@ -112,16 +112,6 @@ pub struct CardanoTransactionsSigningConfig { } impl CardanoTransactionsSigningConfig { - cfg_test_tools! { - /// Create a new CardanoTransactionsSigningConfig - pub fn new(security_parameter: BlockNumber, step: BlockNumber) -> Self { - Self { - security_parameter, - step, - } - } - } - /// Compute the block number to be signed based on the chain tip block number. /// /// The latest block number to be signed is the highest multiple of the step less or equal than the From 205890f050a2a5ddf953d62ff2f6231f4a7a4123 Mon Sep 17 00:00:00 2001 From: DJO <790521+Alenar@users.noreply.github.com> Date: Fri, 25 Jul 2025 12:41:19 +0200 Subject: [PATCH 14/15] fix: address PR issues - fix incorrect paths in tests - fix making pub(crate) previously internal fields for test extension traits by implementing the trait alongside the type (at the cost of mixing tests tools code with production code, but we keep the benefit of the trait import tagged as a test tool) - update `mithril_common::test` module doc - fix `FakeCertificaterRetriever` async trait use in wasm - remove `cfg_test_tools` macro to limit additional uses until the `test_tools` feature is removed --- .../cardano/key_certification.rs | 15 +++++- mithril-common/src/entities/block_range.rs | 50 ++++++++++++++++++- mithril-common/src/lib.rs | 16 ++---- .../test/crypto_helper/cardano/extensions.rs | 12 +---- .../src/test/double/certificate_retriever.rs | 3 +- .../src/test/entities_extensions.rs | 49 ------------------ mithril-common/src/test/mod.rs | 24 +++++---- mithril-common/src/test/temp_dir.rs | 4 +- 8 files changed, 87 insertions(+), 86 deletions(-) diff --git a/mithril-common/src/crypto_helper/cardano/key_certification.rs b/mithril-common/src/crypto_helper/cardano/key_certification.rs index cc090c75845..f80bbebc378 100644 --- a/mithril-common/src/crypto_helper/cardano/key_certification.rs +++ b/mithril-common/src/crypto_helper/cardano/key_certification.rs @@ -101,7 +101,7 @@ pub enum ProtocolInitializerErrorWrapper { #[derive(Debug, Clone, Serialize, Deserialize)] pub struct StmInitializerWrapper { /// The Initializer - pub(crate) stm_initializer: Initializer, + stm_initializer: Initializer, /// The KES signature over the Mithril key /// @@ -292,6 +292,19 @@ impl KeyRegWrapper { } } +#[cfg(any(test, feature = "test_tools"))] +mod test_extensions { + use crate::test::crypto_helper::ProtocolInitializerTestExtension; + + use super::*; + + impl ProtocolInitializerTestExtension for StmInitializerWrapper { + fn override_protocol_parameters(&mut self, protocol_parameters: &ProtocolParameters) { + self.stm_initializer.params = protocol_parameters.to_owned(); + } + } +} + #[cfg(test)] mod test { use crate::crypto_helper::cardano::kes::KesSignerStandard; diff --git a/mithril-common/src/entities/block_range.rs b/mithril-common/src/entities/block_range.rs index 82853c73d3c..c678dcdb902 100644 --- a/mithril-common/src/entities/block_range.rs +++ b/mithril-common/src/entities/block_range.rs @@ -19,7 +19,7 @@ pub type BlockRangeLength = BlockNumber; /// BlockRange for the Cardano chain #[derive(Serialize, Deserialize, Clone, Eq, PartialEq, Debug, Hash)] pub struct BlockRange { - pub(crate) inner_range: Range, + inner_range: Range, } impl BlockRange { @@ -201,6 +201,38 @@ impl ExactSizeIterator for BlockRangesSequence { } } +#[cfg(any(test, feature = "test_tools"))] +mod test_extensions { + use crate::test::entities_extensions::BlockRangeTestExtension; + + use super::*; + + impl BlockRangeTestExtension for BlockRange { + fn new(start: u64, end: u64) -> Self { + Self { + inner_range: BlockNumber(start)..BlockNumber(end), + } + } + + fn try_add(&self, other: &BlockRange) -> StdResult { + if self.inner_range.end.max(other.inner_range.end) + < self.inner_range.start.min(other.inner_range.start) + { + return Err(anyhow!( + "BlockRange cannot be added as they don't strictly overlap" + )); + } + + Ok(Self { + inner_range: Range { + start: self.inner_range.start.min(other.inner_range.start), + end: self.inner_range.end.max(other.inner_range.end), + }, + }) + } + } +} + #[cfg(test)] mod tests { use std::ops::Not; @@ -234,6 +266,22 @@ mod tests { assert!(BlockRange::new(1, 11) < BlockRange::new(2, 10)); } + #[test] + fn test_block_range_try_add() { + assert_eq!( + BlockRange::new(1, 10).try_add(&BlockRange::new(1, 10)).unwrap(), + BlockRange::new(1, 10) + ); + assert_eq!( + BlockRange::new(1, 10).try_add(&BlockRange::new(1, 11)).unwrap(), + BlockRange::new(1, 11) + ); + assert_eq!( + BlockRange::new(1, 10).try_add(&BlockRange::new(2, 10)).unwrap(), + BlockRange::new(1, 10) + ); + } + #[test] fn test_block_range_start() { assert_eq!(BlockRange::start(BlockNumber(0)), 0); diff --git a/mithril-common/src/lib.rs b/mithril-common/src/lib.rs index faffd90afc1..b1973536571 100644 --- a/mithril-common/src/lib.rs +++ b/mithril-common/src/lib.rs @@ -9,16 +9,6 @@ //! - [certificate chain][certificate_chain] used to validate the Certificate Chain created by an aggregator //! - The [entities] used by, and exchanged between, the aggregator, signers and client. -macro_rules! cfg_test_tools { - ($($item:item)*) => { - $( - #[cfg(any(test, feature = "test_tools"))] - #[cfg_attr(docsrs, doc(cfg(feature = "test_tools")))] - $item - )* - } -} - pub mod api_version; pub mod certificate_chain; pub mod crypto_helper; @@ -28,9 +18,9 @@ pub mod messages; pub mod protocol; pub mod signable_builder; -cfg_test_tools! { - pub mod test; -} +#[cfg(any(test, feature = "test_tools"))] +#[cfg_attr(docsrs, doc(cfg(feature = "test_tools")))] +pub mod test; pub use entities::{CardanoNetwork, MagicId}; diff --git a/mithril-common/src/test/crypto_helper/cardano/extensions.rs b/mithril-common/src/test/crypto_helper/cardano/extensions.rs index 4149d950dda..030dcbf9a70 100644 --- a/mithril-common/src/test/crypto_helper/cardano/extensions.rs +++ b/mithril-common/src/test/crypto_helper/cardano/extensions.rs @@ -1,22 +1,14 @@ use anyhow::Context; use crate::StdResult; -use crate::crypto_helper::{ - MKProof, MKTree, MKTreeNode, MKTreeStoreInMemory, ProtocolInitializer, ProtocolParameters, -}; +use crate::crypto_helper::{MKProof, MKTree, MKTreeNode, MKTreeStoreInMemory, ProtocolParameters}; -/// Extension trait adding test utilities to [ProtocolInitializer] +/// Extension trait adding test utilities to [ProtocolInitializer][crate::crypto_helper::ProtocolInitializer] pub trait ProtocolInitializerTestExtension { /// `TEST ONLY` - Override the protocol parameters of the `Initializer` fn override_protocol_parameters(&mut self, protocol_parameters: &ProtocolParameters); } -impl ProtocolInitializerTestExtension for ProtocolInitializer { - fn override_protocol_parameters(&mut self, protocol_parameters: &ProtocolParameters) { - self.stm_initializer.params = protocol_parameters.to_owned(); - } -} - /// Extension trait adding test utilities to [MKProof] pub trait MKProofTestExtension { /// `TEST ONLY` - Build a [MKProof] based on the given leaves diff --git a/mithril-common/src/test/double/certificate_retriever.rs b/mithril-common/src/test/double/certificate_retriever.rs index c30b5a5b14b..3e4c6281416 100644 --- a/mithril-common/src/test/double/certificate_retriever.rs +++ b/mithril-common/src/test/double/certificate_retriever.rs @@ -27,7 +27,8 @@ impl FakeCertificaterRetriever { } } -#[async_trait] +#[cfg_attr(target_family = "wasm", async_trait(?Send))] +#[cfg_attr(not(target_family = "wasm"), async_trait)] impl CertificateRetriever for FakeCertificaterRetriever { async fn get_certificate_details( &self, diff --git a/mithril-common/src/test/entities_extensions.rs b/mithril-common/src/test/entities_extensions.rs index 85098a6e712..898b43b1c7e 100644 --- a/mithril-common/src/test/entities_extensions.rs +++ b/mithril-common/src/test/entities_extensions.rs @@ -1,9 +1,6 @@ //! A set of extension traits to add test utilities to this crate `entities` use std::collections::HashMap; -use std::ops::Range; - -use anyhow::anyhow; use crate::StdResult; use crate::crypto_helper::{ @@ -24,31 +21,6 @@ pub trait BlockRangeTestExtension { fn try_add(&self, other: &BlockRange) -> StdResult; } -impl BlockRangeTestExtension for BlockRange { - fn new(start: u64, end: u64) -> Self { - Self { - inner_range: BlockNumber(start)..BlockNumber(end), - } - } - - fn try_add(&self, other: &BlockRange) -> StdResult { - if self.inner_range.end.max(other.inner_range.end) - < self.inner_range.start.min(other.inner_range.start) - { - return Err(anyhow!( - "BlockRange cannot be added as they don't strictly overlap" - )); - } - - Ok(Self { - inner_range: Range { - start: self.inner_range.start.min(other.inner_range.start), - end: self.inner_range.end.max(other.inner_range.end), - }, - }) - } -} - /// Extension trait adding test utilities to [CardanoTransactionsSetProof] pub trait CardanoTransactionsSetProofTestExtension { /// `TEST ONLY` - Helper to create a proof from a list of leaves @@ -126,24 +98,3 @@ impl SingleSignatureTestExtension for SingleSignature { } } } - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn test_block_range_try_add() { - assert_eq!( - BlockRange::new(1, 10).try_add(&BlockRange::new(1, 10)).unwrap(), - BlockRange::new(1, 10) - ); - assert_eq!( - BlockRange::new(1, 10).try_add(&BlockRange::new(1, 11)).unwrap(), - BlockRange::new(1, 11) - ); - assert_eq!( - BlockRange::new(1, 10).try_add(&BlockRange::new(2, 10)).unwrap(), - BlockRange::new(1, 10) - ); - } -} diff --git a/mithril-common/src/test/mod.rs b/mithril-common/src/test/mod.rs index 39d5f18ea5c..922ca2f5779 100644 --- a/mithril-common/src/test/mod.rs +++ b/mithril-common/src/test/mod.rs @@ -1,9 +1,15 @@ //! Test utilities //! -//! They contains: -//! * A Open Api Spec tester -//! * Some precomputed fake data and keys -//! * A builder of [MithrilFixture] to generate signers alongside a stake distribution +//! A collection of testing utilities and helpers: +//! +//! * `assert`: Custom assertions for comparing directory structures, iterables, JSON strings and more +//! * `builder`: Test data builders and fixtures +//! * `crypto_helper`: Cryptographic utilities for testing +//! * `double`: Test doubles (mocks, fakes, dummies, ...) +//! * `entities_extensions`: Extension traits adding test-specific methods for [crate::entities] +//! * `logging`: Test logging infrastructure +//! * `mock_extensions`: Additional mocking utilities +//! * `temp_dir`: Temporary directory management for tests //! pub mod builder; @@ -89,7 +95,7 @@ mod utils { #[test] fn test_format_function_path_from_given_function() { assert_eq!( - "mithril_common/test_utils/utils/test_format_function_path_from_given_function", + "mithril_common/test/utils/test_format_function_path_from_given_function", format_current_function_path(test_format_function_path_from_given_function) ); } @@ -98,7 +104,7 @@ mod utils { fn test_format_function_path_from_given_pseudo_function_f() { fn f() {} assert_eq!( - "mithril_common/test_utils/utils/test_format_function_path_from_given_pseudo_function_f", + "mithril_common/test/utils/test_format_function_path_from_given_pseudo_function_f", format_current_function_path(f) ); } @@ -107,7 +113,7 @@ mod utils { async fn test_format_function_path_from_given_async_function_f() { fn f() {} assert_eq!( - "mithril_common/test_utils/utils/test_format_function_path_from_given_async_function_f", + "mithril_common/test/utils/test_format_function_path_from_given_async_function_f", format_current_function_path(f) ); } @@ -116,7 +122,7 @@ mod utils { fn test_build_current_function_path_using_macros() { assert_eq!( Path::new("mithril_common") - .join("test_utils") + .join("test") .join("utils") .join("test_build_current_function_path_using_macros"), current_function_path!() @@ -127,7 +133,7 @@ mod utils { async fn test_build_current_async_function_path_using_macros() { assert_eq!( Path::new("mithril_common") - .join("test_utils") + .join("test") .join("utils") .join("test_build_current_async_function_path_using_macros"), current_function_path!() diff --git a/mithril-common/src/test/temp_dir.rs b/mithril-common/src/test/temp_dir.rs index 328f9037344..f0f90c5723f 100644 --- a/mithril-common/src/test/temp_dir.rs +++ b/mithril-common/src/test/temp_dir.rs @@ -258,7 +258,7 @@ mod tests { std::env::temp_dir() .join(TEMP_DIR_ROOT_NAME) .join("mithril_common") - .join("test_utils") + .join("test") .join("temp_dir") .join("creating_temp_dir_base_on_current_function"), temp_dir!(), @@ -271,7 +271,7 @@ mod tests { std::env::temp_dir() .join(TEMP_DIR_ROOT_NAME) .join("mithril_common") - .join("test_utils") + .join("test") .join("temp_dir") .join("creating_temp_dir_base_on_current_async_function"), temp_dir!(), From f0e30e00005d747bbdf5f35b5b068c08181fe9d8 Mon Sep 17 00:00:00 2001 From: DJO <790521+Alenar@users.noreply.github.com> Date: Fri, 25 Jul 2025 12:50:50 +0200 Subject: [PATCH 15/15] chore: upgrade crate versions * mithril-cardano-node-chain from `0.1.5` to `0.1.6` * mithril-cardano-node-internal-database from `0.1.2` to `0.1.3` * mithril-dmq from `0.1.5` to `0.1.6` * mithril-era from `0.1.3` to `0.1.4` * mithril-metric from `0.1.16` to `0.1.17` * mithril-persistence from `0.2.56` to `0.2.57` * mithril-signed-entity-preloader from `0.0.8` to `0.0.9` * mithril-api-spec from `0.1.3` to `0.1.4` * mithril-aggregator from `0.7.75` to `0.7.76` * mithril-client-cli from `0.12.23` to `0.12.24` * mithril-client from `0.12.23` to `0.12.24` * mithril-common from `0.6.10` to `0.6.11` * mithril-relay from `0.1.48` to `0.1.49` * mithril-signer from `0.2.261` to `0.2.262` * mithril-end-to-end from `0.4.97` to `0.4.98` --- Cargo.lock | 30 +++++++++---------- .../mithril-cardano-node-chain/Cargo.toml | 2 +- .../Cargo.toml | 2 +- internal/mithril-dmq/Cargo.toml | 2 +- internal/mithril-era/Cargo.toml | 2 +- internal/mithril-metric/Cargo.toml | 2 +- internal/mithril-persistence/Cargo.toml | 2 +- .../Cargo.toml | 2 +- internal/tests/mithril-api-spec/Cargo.toml | 2 +- mithril-aggregator/Cargo.toml | 2 +- mithril-client-cli/Cargo.toml | 2 +- mithril-client/Cargo.toml | 2 +- mithril-common/Cargo.toml | 2 +- mithril-relay/Cargo.toml | 2 +- mithril-signer/Cargo.toml | 2 +- .../mithril-end-to-end/Cargo.toml | 2 +- 16 files changed, 30 insertions(+), 30 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1f0e93d9428..ebac50e2060 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3928,7 +3928,7 @@ dependencies = [ [[package]] name = "mithril-aggregator" -version = "0.7.75" +version = "0.7.76" dependencies = [ "anyhow", "async-trait", @@ -4009,7 +4009,7 @@ dependencies = [ [[package]] name = "mithril-api-spec" -version = "0.1.3" +version = "0.1.4" dependencies = [ "jsonschema", "mithril-common", @@ -4031,7 +4031,7 @@ dependencies = [ [[package]] name = "mithril-cardano-node-chain" -version = "0.1.5" +version = "0.1.6" dependencies = [ "anyhow", "async-trait", @@ -4059,7 +4059,7 @@ dependencies = [ [[package]] name = "mithril-cardano-node-internal-database" -version = "0.1.2" +version = "0.1.3" dependencies = [ "anyhow", "async-trait", @@ -4090,7 +4090,7 @@ dependencies = [ [[package]] name = "mithril-client" -version = "0.12.23" +version = "0.12.24" dependencies = [ "anyhow", "async-recursion", @@ -4128,7 +4128,7 @@ dependencies = [ [[package]] name = "mithril-client-cli" -version = "0.12.23" +version = "0.12.24" dependencies = [ "anyhow", "async-trait", @@ -4180,7 +4180,7 @@ dependencies = [ [[package]] name = "mithril-common" -version = "0.6.10" +version = "0.6.11" dependencies = [ "anyhow", "async-trait", @@ -4222,7 +4222,7 @@ dependencies = [ [[package]] name = "mithril-dmq" -version = "0.1.5" +version = "0.1.6" dependencies = [ "anyhow", "async-trait", @@ -4258,7 +4258,7 @@ dependencies = [ [[package]] name = "mithril-end-to-end" -version = "0.4.97" +version = "0.4.98" dependencies = [ "anyhow", "async-recursion", @@ -4281,7 +4281,7 @@ dependencies = [ [[package]] name = "mithril-era" -version = "0.1.3" +version = "0.1.4" dependencies = [ "anyhow", "async-trait", @@ -4295,7 +4295,7 @@ dependencies = [ [[package]] name = "mithril-metric" -version = "0.1.16" +version = "0.1.17" dependencies = [ "anyhow", "axum", @@ -4312,7 +4312,7 @@ dependencies = [ [[package]] name = "mithril-persistence" -version = "0.2.56" +version = "0.2.57" dependencies = [ "anyhow", "async-trait", @@ -4330,7 +4330,7 @@ dependencies = [ [[package]] name = "mithril-relay" -version = "0.1.48" +version = "0.1.49" dependencies = [ "anyhow", "clap", @@ -4374,7 +4374,7 @@ dependencies = [ [[package]] name = "mithril-signed-entity-preloader" -version = "0.0.8" +version = "0.0.9" dependencies = [ "anyhow", "async-trait", @@ -4390,7 +4390,7 @@ dependencies = [ [[package]] name = "mithril-signer" -version = "0.2.261" +version = "0.2.262" dependencies = [ "anyhow", "async-trait", diff --git a/internal/cardano-node/mithril-cardano-node-chain/Cargo.toml b/internal/cardano-node/mithril-cardano-node-chain/Cargo.toml index 2f1ea563933..70d4eeae3ac 100644 --- a/internal/cardano-node/mithril-cardano-node-chain/Cargo.toml +++ b/internal/cardano-node/mithril-cardano-node-chain/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mithril-cardano-node-chain" -version = "0.1.5" +version = "0.1.6" authors.workspace = true documentation.workspace = true edition.workspace = true diff --git a/internal/cardano-node/mithril-cardano-node-internal-database/Cargo.toml b/internal/cardano-node/mithril-cardano-node-internal-database/Cargo.toml index 8e4436828ba..ba22abdd22e 100644 --- a/internal/cardano-node/mithril-cardano-node-internal-database/Cargo.toml +++ b/internal/cardano-node/mithril-cardano-node-internal-database/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mithril-cardano-node-internal-database" -version = "0.1.2" +version = "0.1.3" description = "Mechanisms that allow Mithril nodes to read the files of a Cardano node internal database and compute digests from them" authors.workspace = true documentation.workspace = true diff --git a/internal/mithril-dmq/Cargo.toml b/internal/mithril-dmq/Cargo.toml index e660b212852..4e657f037f4 100644 --- a/internal/mithril-dmq/Cargo.toml +++ b/internal/mithril-dmq/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "mithril-dmq" description = "Mechanisms to publish and consume messages of a 'Decentralized Message Queue network' through a DMQ node" -version = "0.1.5" +version = "0.1.6" authors.workspace = true documentation.workspace = true edition.workspace = true diff --git a/internal/mithril-era/Cargo.toml b/internal/mithril-era/Cargo.toml index 17c9791ab17..aa6e6eb3e93 100644 --- a/internal/mithril-era/Cargo.toml +++ b/internal/mithril-era/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mithril-era" -version = "0.1.3" +version = "0.1.4" authors.workspace = true documentation.workspace = true edition.workspace = true diff --git a/internal/mithril-metric/Cargo.toml b/internal/mithril-metric/Cargo.toml index 1b5fd4aac2a..9b531462bf2 100644 --- a/internal/mithril-metric/Cargo.toml +++ b/internal/mithril-metric/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mithril-metric" -version = "0.1.16" +version = "0.1.17" description = "Common tools to expose metrics." authors = { workspace = true } edition = { workspace = true } diff --git a/internal/mithril-persistence/Cargo.toml b/internal/mithril-persistence/Cargo.toml index 86648425e5f..b314733bbc1 100644 --- a/internal/mithril-persistence/Cargo.toml +++ b/internal/mithril-persistence/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mithril-persistence" -version = "0.2.56" +version = "0.2.57" description = "Common types, interfaces, and utilities to persist data for Mithril nodes." authors = { workspace = true } edition = { workspace = true } diff --git a/internal/signed-entity/mithril-signed-entity-preloader/Cargo.toml b/internal/signed-entity/mithril-signed-entity-preloader/Cargo.toml index eec113401e0..3b75ef97e53 100644 --- a/internal/signed-entity/mithril-signed-entity-preloader/Cargo.toml +++ b/internal/signed-entity/mithril-signed-entity-preloader/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mithril-signed-entity-preloader" -version = "0.0.8" +version = "0.0.9" description = "A preload mechanism for Cardano Transaction signed entity." authors = { workspace = true } edition = { workspace = true } diff --git a/internal/tests/mithril-api-spec/Cargo.toml b/internal/tests/mithril-api-spec/Cargo.toml index 113a2ba6687..b77d61e6237 100644 --- a/internal/tests/mithril-api-spec/Cargo.toml +++ b/internal/tests/mithril-api-spec/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mithril-api-spec" -version = "0.1.3" +version = "0.1.4" authors.workspace = true documentation.workspace = true edition.workspace = true diff --git a/mithril-aggregator/Cargo.toml b/mithril-aggregator/Cargo.toml index fb6c02bd0a0..6e54759ea8f 100644 --- a/mithril-aggregator/Cargo.toml +++ b/mithril-aggregator/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mithril-aggregator" -version = "0.7.75" +version = "0.7.76" description = "A Mithril Aggregator server" authors = { workspace = true } edition = { workspace = true } diff --git a/mithril-client-cli/Cargo.toml b/mithril-client-cli/Cargo.toml index efee7ba1041..6a51bb4f904 100644 --- a/mithril-client-cli/Cargo.toml +++ b/mithril-client-cli/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mithril-client-cli" -version = "0.12.23" +version = "0.12.24" description = "A Mithril Client" authors = { workspace = true } edition = { workspace = true } diff --git a/mithril-client/Cargo.toml b/mithril-client/Cargo.toml index aff5e602ffe..f9c27c73a67 100644 --- a/mithril-client/Cargo.toml +++ b/mithril-client/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mithril-client" -version = "0.12.23" +version = "0.12.24" description = "Mithril client library" authors = { workspace = true } edition = { workspace = true } diff --git a/mithril-common/Cargo.toml b/mithril-common/Cargo.toml index 1409e5f2489..accbd6eb4e9 100644 --- a/mithril-common/Cargo.toml +++ b/mithril-common/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mithril-common" -version = "0.6.10" +version = "0.6.11" description = "Common types, interfaces, and utilities for Mithril nodes." authors = { workspace = true } edition = { workspace = true } diff --git a/mithril-relay/Cargo.toml b/mithril-relay/Cargo.toml index 2cc3ed0e29d..f8cb6c9de05 100644 --- a/mithril-relay/Cargo.toml +++ b/mithril-relay/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mithril-relay" -version = "0.1.48" +version = "0.1.49" description = "A Mithril relay" authors = { workspace = true } edition = { workspace = true } diff --git a/mithril-signer/Cargo.toml b/mithril-signer/Cargo.toml index 976b825d980..06af998a2ee 100644 --- a/mithril-signer/Cargo.toml +++ b/mithril-signer/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mithril-signer" -version = "0.2.261" +version = "0.2.262" description = "A Mithril Signer" authors = { workspace = true } edition = { workspace = true } diff --git a/mithril-test-lab/mithril-end-to-end/Cargo.toml b/mithril-test-lab/mithril-end-to-end/Cargo.toml index 0070989f12b..8f2c6c36041 100644 --- a/mithril-test-lab/mithril-end-to-end/Cargo.toml +++ b/mithril-test-lab/mithril-end-to-end/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mithril-end-to-end" -version = "0.4.97" +version = "0.4.98" authors = { workspace = true } edition = { workspace = true } documentation = { workspace = true }