consensus-raft/src/test/java/com/mboysan/consensus/RaftNodeTest.java
/**
     * Tests when a leader fails, a new leader will be elected and the old leader will sync with all the changes
     * in the system state.
     */
Tests when a leader fails, a new leader will be elected and the old leader will sync with all the changes
in the system state.
Tests when a leader fails a new leader will be elected and the old leader will sync with all the changes in the system state .
@Test
    void testLeaderFailure1() throws Exception {
        int numServers = 3;
        init(numServers);
        int oldLeaderId = assertOneLeader();
        kill(oldLeaderId);
        advanceTimeForElections(); 
        int newLeaderId = assertLeaderChanged(oldLeaderId, false);
        List<String> expectedCommands = Arrays.asList("cmd0", "cmd1");
        assertTrue(getNode(newLeaderId).append(expectedCommands.get(0)).get());
        revive(oldLeaderId);
        assertTrue(getNode(newLeaderId).append(expectedCommands.get(1)).get());
        assertLeaderNotChanged(newLeaderId);
        assertLogsEquals(expectedCommands);
    }
@ Test void testLeaderFailure1 ( ) throws Exception { int numServers = 3 ; init ( numServers ) ; int oldLeaderId = assertOneLeader ( ) ; kill ( oldLeaderId ) ; advanceTimeForElections ( ) ; int newLeaderId = assertLeaderChanged ( oldLeaderId , false ) ; List < String > expectedCommands = Arrays . asList ( "cmd0" , "cmd1" ) ; assertTrue ( getNode ( newLeaderId ) . append ( expectedCommands . get ( 0 ) ) . get ( ) ) ; revive ( oldLeaderId ) ; assertTrue ( getNode ( newLeaderId ) . append ( expectedCommands . get ( 1 ) ) . get ( ) ) ; assertLeaderNotChanged ( newLeaderId ) ; assertLogsEquals ( expectedCommands ) ; }
Tests when a leader fails, a new leader will be elected and the old leader will sync with all the changes
 in the system state.
Tests when a leader fails a new leader will be elected and the old leader will sync with all the changes in the system state .
// a new leader will be elected // old leader will pick up all the changes during the above command update