File tree Expand file tree Collapse file tree 2 files changed +34
-0
lines changed
mithril-common/src/test_utils Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Original file line number Diff line number Diff line change
1
+ //! Test doubles
2
+ //!
3
+ //! Enable unit testing with controlled inputs and predictable behavior.
4
+
5
+ /// A trait for giving a type a dummy value.
6
+ ///
7
+ /// Sometimes in tests you need to provide a value for a type, but the actual value doesn't matter.
8
+ /// This trait allows defining a "dummy" value for a type, separated from an eventual default
9
+ /// value, that can be reused across multiple tests.
10
+ ///
11
+ /// Note: should not be confused with "fake" values, fake values aim to be believable and contain
12
+ /// valid cryptography (if they have some), dummies don't aim for those characteristics.
13
+ ///
14
+ /// # Example
15
+ /// ```
16
+ /// use mithril_common::test_utils::double::Dummy;
17
+ ///
18
+ /// struct MyType(String);
19
+ ///
20
+ /// impl Dummy for MyType {
21
+ /// fn dummy() -> Self {
22
+ /// MyType("whatever".to_string())
23
+ /// }
24
+ /// }
25
+ ///
26
+ /// let instance = MyType::dummy();
27
+ /// ```
28
+ pub trait Dummy : Sized {
29
+ /// Return a dummy value for the type
30
+ ///
31
+ /// Useful for test contexts when the actual value doesn't matter.
32
+ fn dummy ( ) -> Self ;
33
+ }
Original file line number Diff line number Diff line change 6
6
//! * A builder of [MithrilFixture] to generate signers alongside a stake distribution
7
7
//!
8
8
9
+ pub mod double;
9
10
pub mod fake_data;
10
11
pub mod fake_keys;
11
12
pub mod mock_extensions;
You can’t perform that action at this time.
0 commit comments