agreement_tests.rs 695 B

12345678910111213141516171819202122232425262728
  1. extern crate labrpc;
  2. extern crate ruaft;
  3. #[macro_use]
  4. extern crate anyhow;
  5. mod config;
  6. #[test]
  7. fn basic_agreement() -> config::Result<()> {
  8. const SERVERS: usize = 5;
  9. let cfg = config::make_config(SERVERS, false);
  10. let _guard = cfg.deferred_cleanup();
  11. cfg.begin("Test (2B): basic agreement");
  12. for index in 1..4 {
  13. let committed = cfg.committed_count(index)?;
  14. assert_eq!(0, committed.0, "some have committed before start()");
  15. let commit_index = cfg.one(index as i32 * 100, SERVERS, false)?;
  16. assert_eq!(
  17. index, commit_index,
  18. "got index {} but expected {}",
  19. commit_index, index
  20. );
  21. }
  22. Ok(())
  23. }