Expand description
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
Re-exports§
pub use mock_raft_builder::*;