@Test
public void shouldResetElectionTimeoutAndSetSendingServerAsLeaderOnReceivingAnAppendEntriesForElectionTerm() throws StorageException {

    store.setCurrentTerm(3);
    long preAppendEntriesElectionTimeoutTick = getElectionTimeoutTick();
    assertThatSelfTransitionedToFollower(3, 0, null, false);
    // fast forward half-way into the election timeout period
    // this allows us to verify easily that the election timeout was reset
    long ticksBeforeAppendEntriesReceived = (preAppendEntriesElectionTimeoutTick - timer.getTick()) / 2;
    timer.fastForward(ticksBeforeAppendEntriesReceived);
    // at this point, we receive a heartbeat
    algorithm.onAppendEntries(S_01, 3, 0, 0, 0, null);
    assertThatSelfTransitionedToFollower(3, 0, S_01, true);
    // verify that we've reset the election timeout
    long postAppendEntriesElectionTimeoutTick = getElectionTimeoutTick();
    assertThat(postAppendEntriesElectionTimeoutTick, greaterThan(preAppendEntriesElectionTimeoutTick));
    assertThat(postAppendEntriesElectionTimeoutTick, equalTo(timer.getTick() + RaftConstants.MIN_ELECTION_TIMEOUT));
    assertThatLogContainsOnlySentinel();
    assertThatTermAndCommitIndexHaveValues(3, 0);
}