diff options
author | teor <teor@torproject.org> | 2019-03-20 09:47:59 +1000 |
---|---|---|
committer | teor <teor@torproject.org> | 2019-03-20 09:47:59 +1000 |
commit | 1e154d7a156de68f41a52c067ba47fd38ce2a520 (patch) | |
tree | 6a359bd70ba0ea3ec8124f4c054d6e3655faf47f /src/test/test_shared_random.c | |
parent | 547ee1c345f7333402610e5464cf0c243c24aa36 (diff) | |
parent | d7a5fdcb7408536008e8142becc323148e901da5 (diff) | |
download | tor-1e154d7a156de68f41a52c067ba47fd38ce2a520.tar.gz tor-1e154d7a156de68f41a52c067ba47fd38ce2a520.zip |
Merge branch 'maint-0.3.4' into release-0.3.4
Diffstat (limited to 'src/test/test_shared_random.c')
-rw-r--r-- | src/test/test_shared_random.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/test/test_shared_random.c b/src/test/test_shared_random.c index c04e4660c3..630883e1fb 100644 --- a/src/test/test_shared_random.c +++ b/src/test/test_shared_random.c @@ -60,6 +60,9 @@ init_authority_state(void) * the phase we are currently in which uses "now" as the starting * timestamp. Delete it before we do any testing below. */ sr_state_delete_commits(); + /* It's also possible that a current SRV has been generated, if we are at + * state transition time. But let's just forget about that SRV. */ + sr_state_clean_srvs(); done: UNMOCK(get_my_v3_authority_cert); @@ -544,12 +547,20 @@ test_encoding(void *arg) ; } -/** Setup some SRVs in our SR state. If <b>also_current</b> is set, then set - * both current and previous SRVs. - * Helper of test_vote() and test_sr_compute_srv(). */ +/** Setup some SRVs in our SR state. + * If <b>also_current</b> is set, then set both current and previous SRVs. + * Otherwise, just set the previous SRV. (And clear the current SRV.) + * + * You must call sr_state_free_all() to free the state at the end of each test + * function (on pass or fail). */ static void test_sr_setup_srv(int also_current) { + /* Clear both SRVs before starting. + * In 0.3.5 and earlier, sr_state_set_previous_srv() and + * sr_state_set_current_srv() do not free() the old srvs. */ + sr_state_clean_srvs(); + sr_srv_t *srv = tor_malloc_zero(sizeof(sr_srv_t)); srv->num_reveals = 42; memcpy(srv->value, |