diff options
author | David Goulet <dgoulet@torproject.org> | 2016-05-26 15:26:09 -0400 |
---|---|---|
committer | David Goulet <dgoulet@torproject.org> | 2016-07-01 14:01:42 -0400 |
commit | 4a1904c12665b98c356aba8e7b73a3f3fd508a5b (patch) | |
tree | 0e5e943203291f0926323c5e610610afed8a0325 /src/test | |
parent | 6927467bef1b5c46b85d30ac77b364ed407f6d72 (diff) | |
download | tor-4a1904c12665b98c356aba8e7b73a3f3fd508a5b.tar.gz tor-4a1904c12665b98c356aba8e7b73a3f3fd508a5b.zip |
prop250: Use the new dirvote_get_intermediate_param_value for AuthDirNumSRVAgreements
Signed-off-by: David Goulet <dgoulet@torproject.org>
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/test_shared_random.c | 34 |
1 files changed, 3 insertions, 31 deletions
diff --git a/src/test/test_shared_random.c b/src/test/test_shared_random.c index 89400453d4..b9003502b1 100644 --- a/src/test/test_shared_random.c +++ b/src/test/test_shared_random.c @@ -830,14 +830,6 @@ get_test_vote_with_curr_srv(const char *srv) return vote; } -/* Mock function to return the value located in the options instead of the - * consensus so we can modify it at will. */ -static networkstatus_t * -mock_networkstatus_get_latest_consensus(void) -{ - return mock_consensus; -} - /* Test the function that picks the right SRV given a bunch of votes. Make sure * that the function returns an SRV iff the majority/agreement requirements are * met. */ @@ -894,31 +886,13 @@ test_sr_get_majority_srv_from_votes(void *arg) /* Now we achieve majority for SRV_1, but not the AuthDirNumSRVAgreements requirement. So still not picking an SRV. */ + set_num_srv_agreements(8); chosen_srv = get_majority_srv_from_votes(votes, 1); tt_assert(!chosen_srv); /* We will now lower the AuthDirNumSRVAgreements requirement by tweaking the - * consensus parameter and we will try again. This time it should work. */ - { - char *my_net_params; - /* Set a dummy consensus parameter in every vote */ - SMARTLIST_FOREACH_BEGIN(votes, networkstatus_t *, vote) { - vote->net_params = smartlist_new(); - smartlist_split_string(vote->net_params, - "AuthDirNumSRVAgreements=7", NULL, 0, 0); - } SMARTLIST_FOREACH_END(vote); - - /* Pretend you are making a consensus out of the votes */ - mock_consensus = tor_malloc_zero(sizeof(networkstatus_t)); - mock_consensus->net_params = smartlist_new(); - my_net_params = dirvote_compute_params(votes, 66, smartlist_len(votes)); - smartlist_split_string(mock_consensus->net_params, my_net_params, " ", - SPLIT_SKIP_SPACE|SPLIT_IGNORE_BLANK, 0); - } - - /* Use our fake consensus for finding consensus parameters. */ - MOCK(networkstatus_get_latest_consensus, - mock_networkstatus_get_latest_consensus); + * consensus parameter and we will try again. This time it should work. */ + set_num_srv_agreements(7); chosen_srv = get_majority_srv_from_votes(votes, 1); tt_assert(chosen_srv); tt_int_op(chosen_srv->num_reveals, ==, 42); @@ -928,8 +902,6 @@ test_sr_get_majority_srv_from_votes(void *arg) SMARTLIST_FOREACH(votes, networkstatus_t *, vote, networkstatus_vote_free(vote)); smartlist_free(votes); - networkstatus_vote_free(mock_consensus); - UNMOCK(networkstatus_get_latest_consensus); } static void |