|
@@ -1013,6 +1013,7 @@ test_state_transition(void *arg)
|
|
|
{
|
|
|
sr_state_t *state = NULL;
|
|
|
time_t now = time(NULL);
|
|
|
+ sr_srv_t *cur = NULL;
|
|
|
|
|
|
(void) arg;
|
|
|
|
|
@@ -1051,44 +1052,47 @@ test_state_transition(void *arg)
|
|
|
|
|
|
|
|
|
{
|
|
|
- const sr_srv_t *cur, *prev;
|
|
|
test_sr_setup_srv(1);
|
|
|
- cur = sr_state_get_current_srv();
|
|
|
+ tt_assert(sr_state_get_current_srv());
|
|
|
+
|
|
|
+ cur = srv_dup(sr_state_get_current_srv());
|
|
|
tt_assert(cur);
|
|
|
-
|
|
|
+
|
|
|
+ * the current SRV should be set to NULL */
|
|
|
state_rotate_srv();
|
|
|
- prev = sr_state_get_previous_srv();
|
|
|
- tt_assert(prev == cur);
|
|
|
+ tt_mem_op(sr_state_get_previous_srv(), OP_EQ, cur, sizeof(sr_srv_t));
|
|
|
tt_assert(!sr_state_get_current_srv());
|
|
|
sr_state_clean_srvs();
|
|
|
+ tor_free(cur);
|
|
|
}
|
|
|
|
|
|
|
|
|
{
|
|
|
- const sr_srv_t *cur;
|
|
|
|
|
|
* actually makes them rotate and compute new ones. */
|
|
|
test_sr_setup_srv(1);
|
|
|
- cur = sr_state_get_current_srv();
|
|
|
- tt_assert(cur);
|
|
|
+ tt_assert(sr_state_get_current_srv());
|
|
|
+
|
|
|
+ cur = srv_dup(sr_state_get_current_srv());
|
|
|
set_sr_phase(SR_PHASE_REVEAL);
|
|
|
MOCK(get_my_v3_authority_cert, get_my_v3_authority_cert_m);
|
|
|
new_protocol_run(now);
|
|
|
UNMOCK(get_my_v3_authority_cert);
|
|
|
|
|
|
- tt_assert(sr_state_get_previous_srv() == cur);
|
|
|
+ tt_mem_op(sr_state_get_previous_srv(), OP_EQ, cur, sizeof(sr_srv_t));
|
|
|
|
|
|
* our current SRV would be NULL but a new protocol run should make us
|
|
|
* compute a new SRV. */
|
|
|
tt_assert(sr_state_get_current_srv());
|
|
|
|
|
|
- tt_assert(sr_state_get_current_srv() != cur);
|
|
|
+ tt_mem_op(sr_state_get_current_srv(), OP_NE, cur, sizeof(sr_srv_t));
|
|
|
|
|
|
tt_int_op(digestmap_size(state->commits), ==, 1);
|
|
|
tt_int_op(state->n_reveal_rounds, ==, 0);
|
|
|
tt_int_op(state->n_commit_rounds, ==, 0);
|
|
|
|
|
|
tt_u64_op(state->n_protocol_runs, ==, 46);
|
|
|
+ tor_free(cur);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -1099,6 +1103,7 @@ test_state_transition(void *arg)
|
|
|
}
|
|
|
|
|
|
done:
|
|
|
+ tor_free(cur);
|
|
|
sr_state_free();
|
|
|
}
|
|
|
|