@SuppressWarnings("unchecked") public void testAppendUpdatesLeaderAndTerm() throws Throwable { runOnServer( () -> { serverContext.setTerm(1); AppendRequest request = AppendRequest.builder() .withTerm(2) .withLeader(members.get(1).hashCode()) .withEntries(Collections.EMPTY_LIST) .withLogIndex(0) .withLogTerm(0) .withCommitIndex(0) .withGlobalIndex(0) .build(); AppendResponse response = state.append(request).get(); threadAssertEquals(serverContext.getTerm(), 2L); threadAssertEquals( serverContext.getLeader().serverAddress(), members.get(1).serverAddress()); threadAssertEquals(serverContext.getLastVotedFor(), 0); threadAssertEquals(response.term(), 2L); threadAssertTrue(response.succeeded()); }); }