Parcourir la source

Merge duplicate implementations of null persistor.

Jing Yang il y a 3 ans
Parent
commit
375fa59ed2
2 fichiers modifiés avec 3 ajouts et 17 suppressions
  1. 2 0
      src/utils/do_nothing.rs
  2. 1 17
      test_configs/src/rpcs.rs

+ 2 - 0
src/utils/do_nothing.rs

@@ -1,3 +1,5 @@
+#![cfg(feature = "integration-test")]
+
 use async_trait::async_trait;
 use bytes::Bytes;
 

+ 1 - 17
test_configs/src/rpcs.rs

@@ -216,8 +216,7 @@ pub fn register_kv_server<
 
 #[cfg(test)]
 mod tests {
-    use bytes::Bytes;
-
+    use ruaft::utils::do_nothing::DoNothingPersister;
     use ruaft::utils::integration_test::{
         make_append_entries_args, make_request_vote_args,
         unpack_append_entries_reply, unpack_request_vote_reply,
@@ -226,21 +225,6 @@ mod tests {
 
     use super::*;
 
-    struct DoNothingPersister;
-    impl ruaft::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]) {}
-    }
-
     #[test]
     fn test_basic_message() -> std::io::Result<()> {
         test_utils::init_test_log!();