Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions DEV-ADR.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,34 @@ To complete
To complete
-->

### 3. Guidelines for Dummy Test Doubles

**Date:** 2025-07-22
**Status:** Accepted

#### Context

The use of `dummy()` functions for creating test doubles is widespread across the codebase. However, inconsistencies
in their placement and visibility have led to maintenance challenges and reduced code clarity.

#### Decision

A `Dummy` trait will be introduced, functioning similarly to Rust's `Default` trait.

The following guidelines will be adopted for implementing the `Dummy` trait:

1. Most implementations should reside in a `test::double::dummies` module within the crate where the type is defined.
2. For types with non-public fields, the `Dummy` trait should be implemented directly below the type's definition.

#### Consequences

- Enhanced consistency in code organization.
- Improved discoverability of test doubles.
- Clearer distinction between production and test code.
- Simplified maintenance of test implementations.

---

## 2. Remove Artifacts serialization support when compiling to WebAssembly

date: 2025-02-26
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "mithril-cardano-node-chain"
version = "0.1.4"
version = "0.1.5"
authors.workspace = true
documentation.workspace = true
edition.workspace = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ impl ChainObserver for FakeChainObserver {

#[cfg(test)]
mod tests {
use mithril_common::test_utils::fake_data;
use mithril_common::test_utils::{double::Dummy, fake_data};

use super::*;

Expand Down
2 changes: 1 addition & 1 deletion internal/mithril-dmq/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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.4"
version = "0.1.5"
authors.workspace = true
documentation.workspace = true
edition.workspace = true
Expand Down
1 change: 1 addition & 0 deletions internal/mithril-dmq/src/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ mod tests {
use mithril_common::{
crypto_helper::{KesSignerFake, TryToBytes},
entities::{BlockNumber, ChainPoint, TimePoint},
test_utils::double::Dummy,
};

use super::*;
Expand Down
7 changes: 5 additions & 2 deletions internal/mithril-dmq/src/publisher/pallas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ impl<M: TryToBytes + Debug + Sync + Send> DmqPublisher<M> for DmqPublisherPallas

#[cfg(all(test, unix))]
mod tests {

use std::{fs, sync::Arc};

use pallas_network::miniprotocols::{
Expand All @@ -91,7 +90,11 @@ mod tests {
use tokio::{net::UnixListener, task::JoinHandle};

use mithril_cardano_node_chain::test::double::FakeChainObserver;
use mithril_common::{crypto_helper::KesSignerFake, current_function, test_utils::TempDir};
use mithril_common::{
crypto_helper::KesSignerFake,
current_function,
test_utils::{TempDir, double::Dummy},
};

use crate::{test::payload::DmqMessageTestPayload, test_tools::TestLogger};

Expand Down
5 changes: 4 additions & 1 deletion internal/mithril-dmq/src/test/payload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use std::fmt::Debug;
use mithril_common::{
StdResult,
crypto_helper::{TryFromBytes, TryToBytes},
test_utils::double::Dummy,
};

/// A test message payload for the DMQ.
Expand All @@ -18,9 +19,11 @@ impl DmqMessageTestPayload {
message: bytes.to_vec(),
}
}
}

impl Dummy for DmqMessageTestPayload {
/// Creates a dummy `DmqMessageTestPayload` with a predefined message.
pub fn dummy() -> Self {
fn dummy() -> Self {
Self {
message: b"dummy message".to_vec(),
}
Expand Down
2 changes: 1 addition & 1 deletion internal/mithril-era/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "mithril-era"
version = "0.1.2"
version = "0.1.3"
authors.workspace = true
documentation.workspace = true
edition.workspace = true
Expand Down
2 changes: 2 additions & 0 deletions internal/mithril-era/src/adapters/bootstrap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ impl EraReaderAdapter for BootstrapAdapter {

#[cfg(test)]
mod tests {
use mithril_common::test_utils::double::Dummy;

use super::*;

#[tokio::test]
Expand Down
1 change: 1 addition & 0 deletions internal/mithril-era/src/adapters/dummy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ impl EraReaderAdapter for DummyAdapter {
#[cfg(test)]
mod tests {
use mithril_common::entities::{Epoch, SupportedEra};
use mithril_common::test_utils::double::Dummy;

use super::*;

Expand Down
2 changes: 1 addition & 1 deletion internal/mithril-era/src/adapters/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ impl EraReaderAdapter for FileAdapter {
#[cfg(test)]
mod tests {
use mithril_common::entities::{Epoch, SupportedEra};
use mithril_common::test_utils::TempDir;
use mithril_common::test_utils::{TempDir, double::Dummy};

use super::*;

Expand Down
2 changes: 2 additions & 0 deletions internal/mithril-era/src/era_checker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ impl ApiVersionDiscriminantSource for EraChecker {

#[cfg(test)]
mod tests {
use mithril_common::test_utils::double::Dummy;

use super::*;

#[test]
Expand Down
2 changes: 2 additions & 0 deletions internal/mithril-era/src/era_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@ impl EraReader {

#[cfg(test)]
mod tests {
use mithril_common::test_utils::double::Dummy;

use super::super::adapters::EraReaderDummyAdapter as DummyAdapter;
use super::*;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "mithril-signed-entity-preloader"
version = "0.0.7"
version = "0.0.8"
description = "A preload mechanism for Cardano Transaction signed entity."
authors = { workspace = true }
edition = { workspace = true }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +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 crate::test_tools::TestLogger;

Expand Down
2 changes: 1 addition & 1 deletion internal/tests/mithril-api-spec/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "mithril-api-spec"
version = "0.1.1"
version = "0.1.2"
authors.workspace = true
documentation.workspace = true
edition.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion internal/tests/mithril-api-spec/src/apispec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ mod tests {

use mithril_common::entities;
use mithril_common::messages::{AggregatorFeaturesMessage, SignerMessagePart};
use mithril_common::test_utils::{TempDir, fake_data};
use mithril_common::test_utils::{TempDir, double::Dummy, fake_data};

use super::*;

Expand Down
2 changes: 1 addition & 1 deletion mithril-aggregator/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "mithril-aggregator"
version = "0.7.74"
version = "0.7.75"
description = "A Mithril Aggregator server"
authors = { workspace = true }
edition = { workspace = true }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ impl AncillaryArtifactBuilder {
mod tests {
use std::path::PathBuf;

use mithril_common::test_utils::{TempDir, assert_equivalent};
use mithril_common::test_utils::{TempDir, assert_equivalent, double::Dummy};

use crate::services::{DumbSnapshotter, MockSnapshotter};
use crate::test_tools::TestLogger;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ mod tests {
current_function,
entities::{CardanoDbBeacon, CompressionAlgorithm},
messages::{CardanoDatabaseDigestListItemMessage, CardanoDatabaseDigestListMessage},
test_utils::{TempDir, assert_equivalent},
test_utils::{TempDir, assert_equivalent, double::Dummy},
};

use crate::{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ impl ArtifactBuilder<Epoch, MithrilStakeDistribution> for MithrilStakeDistributi

#[cfg(test)]
mod tests {
use mithril_common::{crypto_helper::ProtocolParameters, test_utils::fake_data};
use mithril_common::{
crypto_helper::ProtocolParameters,
test_utils::{double::Dummy, fake_data},
};
use std::sync::Arc;
use tokio::sync::RwLock;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ impl Query for InsertOrReplaceOpenMessageQuery {

#[cfg(test)]
mod tests {
use mithril_common::test_utils::double::Dummy;
use mithril_persistence::sqlite::ConnectionExtensions;

use crate::database::query::GetOpenMessageQuery;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,6 @@ impl ImmutableFileDigestRecord {
let aliases = SourceAlias::new(&[("{:immutable_file_digest:}", table)]);
Self::get_projection().expand(aliases)
}

#[cfg(test)]
/// Create a dumb ImmutableFileDigestRecord instance mainly for test purposes
pub fn dummy() -> Self {
Self {
immutable_file_name: "123.chunk".to_string(),
digest: "dummy_digest".to_string(),
}
}
}

impl SqLiteEntity for ImmutableFileDigestRecord {
Expand Down
19 changes: 0 additions & 19 deletions mithril-aggregator/src/database/record/open_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,25 +43,6 @@ impl OpenMessageRecord {
pub fn new_id() -> Uuid {
Uuid::new_v4()
}

#[cfg(test)]
/// Create a dumb OpenMessage instance mainly for test purposes
pub fn dummy() -> Self {
let beacon = mithril_common::test_utils::fake_data::beacon();
let epoch = beacon.epoch;
let signed_entity_type = SignedEntityType::CardanoImmutableFilesFull(beacon);

Self {
open_message_id: Uuid::parse_str("193d1442-e89b-43cf-9519-04d8db9a12ff").unwrap(),
epoch,
signed_entity_type,
protocol_message: ProtocolMessage::new(),
is_certified: false,
is_expired: false,
created_at: Utc::now(),
expires_at: None,
}
}
}

impl SqLiteEntity for OpenMessageRecord {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ impl EpochPruningTask for EpochSettingsStore {

#[cfg(test)]
mod tests {
use mithril_common::test_utils::double::Dummy;

use crate::database::test_helper::{insert_epoch_settings, main_db_connection};

use super::*;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ impl OpenMessageStorer for OpenMessageRepository {
#[cfg(test)]
mod tests {
use mithril_common::entities::{BlockNumber, CardanoDbBeacon};
use mithril_common::test_utils::double::Dummy;

use crate::database::record::SingleSignatureRecord;
use crate::database::test_helper::{
Expand Down
Loading
Loading