Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TestRaft_server_recv_requestvote_response_increase_votes_for_me problem #28

Closed
tinymindxx opened this issue Sep 8, 2016 · 1 comment

Comments

@tinymindxx
Copy link

tinymindxx commented Sep 8, 2016

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
Copy link
Owner

willemt commented Sep 10, 2016

Thank you for discovering this! The test was badly written.

I've now fixed it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants