|
|
@@ -101,62 +101,17 @@ mod tests {
|
|
|
use std::panic::catch_unwind;
|
|
|
use std::sync::Arc;
|
|
|
|
|
|
- use async_trait::async_trait;
|
|
|
- use bytes::Bytes;
|
|
|
use parking_lot::Mutex;
|
|
|
|
|
|
use crate::election::ElectionState;
|
|
|
use crate::remote_peer::RemotePeer;
|
|
|
use crate::term_marker::TermMarker;
|
|
|
+ use crate::utils::do_nothing::{DoNothingPersister, DoNothingRemoteRaft};
|
|
|
use crate::verify_authority::VerifyAuthorityDaemon;
|
|
|
- use crate::{
|
|
|
- AppendEntriesArgs, AppendEntriesReply, InstallSnapshotArgs,
|
|
|
- InstallSnapshotReply, Peer, Persister, RaftState, RemoteRaft,
|
|
|
- RequestVoteArgs, RequestVoteReply,
|
|
|
- };
|
|
|
+ use crate::{Peer, RaftState};
|
|
|
|
|
|
use super::RemoteContext;
|
|
|
|
|
|
- struct DoNothingPersister;
|
|
|
- impl Persister for DoNothingPersister {
|
|
|
- fn read_state(&self) -> Bytes {
|
|
|
- Bytes::new()
|
|
|
- }
|
|
|
-
|
|
|
- fn save_state(&self, _bytes: Bytes) {}
|
|
|
-
|
|
|
- fn state_size(&self) -> usize {
|
|
|
- 0
|
|
|
- }
|
|
|
-
|
|
|
- fn save_snapshot_and_state(&self, _: Bytes, _: &[u8]) {}
|
|
|
- }
|
|
|
-
|
|
|
- struct DoNothingRemoteRaft;
|
|
|
- #[async_trait]
|
|
|
- impl<Command: 'static + Send> RemoteRaft<Command> for DoNothingRemoteRaft {
|
|
|
- async fn request_vote(
|
|
|
- &self,
|
|
|
- _args: RequestVoteArgs,
|
|
|
- ) -> std::io::Result<RequestVoteReply> {
|
|
|
- unimplemented!()
|
|
|
- }
|
|
|
-
|
|
|
- async fn append_entries(
|
|
|
- &self,
|
|
|
- _args: AppendEntriesArgs<Command>,
|
|
|
- ) -> std::io::Result<AppendEntriesReply> {
|
|
|
- unimplemented!()
|
|
|
- }
|
|
|
-
|
|
|
- async fn install_snapshot(
|
|
|
- &self,
|
|
|
- _args: InstallSnapshotArgs,
|
|
|
- ) -> std::io::Result<InstallSnapshotReply> {
|
|
|
- unimplemented!()
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
#[test]
|
|
|
fn test_context_api() {
|
|
|
let rf = Arc::new(Mutex::new(RaftState::<i32>::create(1, Peer(0))));
|