1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
//! Unit test module for isolating RaftContext components via mocked
//! dependencies.
//!
//! This module provides mock implementations of storage, network and handler
//! components using the [mockall] framework. Designed for granular testing of
//! Raft consensus algorithm components with the following characteristics:
//!
//! - Uses **mocked storage interfaces** with in-memory state control
//! - Simulates network transport with deterministic responses
//! - Allows precise behavior injection for handlers
//! - Enables isolated testing of component interactions
//!
//! The mock context encapsulates a controlled testing environment containing:
//! - Mock storage implementations (raft log, state machine)
//! - Simulated network layer
//! - Configurable cluster membership
//! - Instrumented handler implementations
//!
//! Mock initialization provides a test environment with:
//! - Auto-generated mock objects via [mockall] attributes
//! - Preconfigured peer responses
//! - Deterministic transport simulation
//! - Component interaction tracking
//!
//! This differs from integration tests in that:
//! - I/O operations use mocked storage with ephemeral state
//! - Network communication is simulated without actual ports binding
//! - Component states reset between tests
//! - Specific interaction patterns can be enforced
//!
//! Typical usage scenarios:
//! - Unit testing of individual Raft components
//! - Validation of state machine edge cases
//! - Network partition simulation
//! - Protocol violation testing
//! - Fast feedback during development iterations
//!
//! [mockall]: https://docs.rs/mockall/latest/mockall/
use NodeMeta;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
use watch;
use node_config;
use crateRaftContext;
/// Creates mock RaftContext with automatic TempDir cleanup
///
/// This is the recommended helper for unit tests. It automatically manages
/// temporary directories and provides a clean testing environment.
///
/// Returns:
/// - RaftContext configured for testing
/// - TempDir that auto-cleans on drop
///
/// Example:
/// ```rust,ignore
/// let (_graceful_tx, graceful_rx) = watch::channel(());
/// let (context, _temp_dir) = mock_raft_context_with_temp(graceful_rx, None);
/// // Use context in test...
/// // _temp_dir automatically cleaned up when dropped
/// ```