@Test
public void testNeedsLeaderAddress() {

    logStart("testNeedsLeaderAddress");
    MockRaftActorContext context = createActorContext();
    context.setReplicatedLog(new MockRaftActorContext.SimpleReplicatedLog());
    context.addToPeers("leader", null, VotingState.VOTING);
    ((DefaultConfigParamsImpl)context.getConfigParams()).setPeerAddressResolver(NoopPeerAddressResolver.INSTANCE);
    follower = createBehavior(context);
    follower.handleMessage(leaderActor,
            new AppendEntries(1, "leader", -1, -1, Collections.emptyList(), -1, -1, (short)0));
    AppendEntriesReply reply = MessageCollectorActor.expectFirstMatching(leaderActor, AppendEntriesReply.class);
    assertTrue(reply.isNeedsLeaderAddress());
    MessageCollectorActor.clearMessages(leaderActor);
    PeerAddressResolver mockResolver = mock(PeerAddressResolver.class);
    ((DefaultConfigParamsImpl)context.getConfigParams()).setPeerAddressResolver(mockResolver);
    follower.handleMessage(leaderActor, new AppendEntries(1, "leader", -1, -1, Collections.emptyList(), -1, -1,
            (short)0, RaftVersions.CURRENT_VERSION, leaderActor.path().toString()));
    reply = MessageCollectorActor.expectFirstMatching(leaderActor, AppendEntriesReply.class);
    assertFalse(reply.isNeedsLeaderAddress());
    verify(mockResolver).setResolved("leader", leaderActor.path().toString());
}