Skip to content

Commit

Permalink
Refactor: remove some duplicated code in append_memvership_test.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
Phoenix500526 authored and drmingdrmer committed Jun 21, 2024
1 parent ce142d0 commit 86a338f
Showing 1 changed file with 2 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,7 @@ fn eng() -> Engine<UTConfig> {
#[test]
fn test_leader_append_membership_for_leader() -> anyhow::Result<()> {
let mut eng = eng();
eng.state.server_state = ServerState::Leader;
// Make it a real leader: voted for itself and vote is committed.
eng.state.vote = UTime::new(TokioInstant::now(), Vote::new_committed(2, 2));
eng.vote_handler().become_leading();

eng.replication_handler().append_membership(&log_id(3, 1, 4), &m34());
Expand Down Expand Up @@ -107,12 +105,11 @@ fn test_leader_append_membership_update_learner_process() -> anyhow::Result<()>
log_id(5, 1, 10),
]);

eng.state.server_state = ServerState::Leader;
// Make it a real leader: voted for itself and vote is committed.
eng.state.vote = UTime::new(TokioInstant::now(), Vote::new_committed(2, 2));
eng.state
.membership_state
.set_effective(Arc::new(EffectiveMembership::new(Some(log_id(2, 1, 3)), m23_45())));

// Make it a real leader: voted for itself and vote is committed.
eng.vote_handler().become_leading();

if let Some(l) = &mut eng.internal_server_state.leading_mut() {
Expand Down

0 comments on commit 86a338f

Please sign in to comment.