TestRaft_server_recv_requestvote_response_increase_votes_for_me problem
tinymindxx opened this issue · 1 comments
tinymindxx commented
in Test_server.c , function TestRaft_server_recv_requestvote_response_increase_votes_for_me may have some error.
void TestRaft_server_recv_requestvote_response_increase_votes_for_me(
CuTest * tc
)
{
void *r = raft_new();
raft_add_node(r, NULL, 1, 1);
raft_add_node(r, NULL, 2, 0);
this action will increase term id to 2;
raft_set_current_term(r, 1);
CuAssertTrue(tc, 0 == raft_get_nvotes_for_me(r));
this action will increase term id to 2;
raft_become_candidate(r);
msg_requestvote_response_t rvr;
memset(&rvr, 0, sizeof(msg_requestvote_response_t));
rvr.term = 1;
rvr.vote_granted = 1;
raft_recv_requestvote_response(r, raft_get_node(r, 2), &rvr);
this action wont increase vote because rcr.termid =1 < current term id;
CuAssertTrue(tc, 1 == raft_get_nvotes_for_me(r));
}
wonder is this a mistake or my understanding error?
willemt commented
Thank you for discovering this! The test was badly written.
I've now fixed it.