Skip to content

Commit

Permalink
Fixes #49
Browse files Browse the repository at this point in the history
  • Loading branch information
willemt committed Jan 9, 2018
1 parent d620a9f commit d188519
Showing 1 changed file with 0 additions and 44 deletions.
44 changes: 0 additions & 44 deletions tests/test_snapshotting.c
Original file line number Diff line number Diff line change
Expand Up @@ -562,47 +562,3 @@ void TestRaft_recv_entry_fails_if_snapshot_in_progress(CuTest* tc)
ety.type = RAFT_LOGTYPE_ADD_NODE;
CuAssertIntEquals(tc, RAFT_ERR_SNAPSHOT_IN_PROGRESS, raft_recv_entry(r, &ety, &cr));
}

void TxestRaft_full_snapshot(CuTest * tc)
{
raft_cbs_t funcs = {
.persist_term = __raft_persist_term,
.send_appendentries = __raft_send_appendentries,
};

void *r = raft_new();
raft_set_callbacks(r, &funcs, NULL);

msg_entry_response_t cr;

raft_add_node(r, NULL, 1, 1);
raft_add_node(r, NULL, 2, 0);

/* I am the leader */
raft_set_state(r, RAFT_STATE_LEADER);
raft_set_current_term(r, 1);
CuAssertIntEquals(tc, 0, raft_get_log_count(r));

/* entry message */
msg_entry_t ety = {};
ety.id = 1;
ety.data.buf = "entry";
ety.data.len = strlen("entry");

/* receive entry */
raft_recv_entry(r, &ety, &cr);
raft_set_commit_idx(r, 1);
CuAssertIntEquals(tc, 1, raft_get_log_count(r));
CuAssertIntEquals(tc, 1, raft_get_num_snapshottable_logs(r));

CuAssertIntEquals(tc, 0, raft_begin_snapshot(r));

raft_entry_t* _ety;
int i = raft_get_first_entry_idx(r);
for (; i < raft_get_commit_idx(r); i++)
CuAssertIntEquals(tc, 0, raft_poll_entry(r, &_ety));

CuAssertIntEquals(tc, 0, raft_end_snapshot(r));
CuAssertIntEquals(tc, 0, raft_get_num_snapshottable_logs(r));
CuAssertIntEquals(tc, 1, raft_get_log_count(r));
}

0 comments on commit d188519

Please sign in to comment.