diff options
author | Nick Mathewson <nickm@torproject.org> | 2018-05-01 19:58:39 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2018-05-01 19:58:39 -0400 |
commit | a2b53c1d0bb759bfe039bb417281bda743655bfe (patch) | |
tree | 22496c572904ff5b7cce8cc363cc9d667dd107fd /src/test/test_hs_client.c | |
parent | 60fad8d41fc7395bd573a2cd9585ae9cb03febc3 (diff) | |
download | tor-a2b53c1d0bb759bfe039bb417281bda743655bfe.tar.gz tor-a2b53c1d0bb759bfe039bb417281bda743655bfe.zip |
coverage: Repeat the test for avoiding failed intro points
This test, in test_client_pick_intro(), will have different coverage
depending on whether it selects a good intro point the first time or
whether it has to try a few times. Since it produces the shorter
coverage with P=1/4, repeat this test 64 times so that it only
provides reduced coverage with P=1/2^128. The performance cost is
negligible.
Closes ticket 25996. This test was introduced in 0.3.2.1-alpha.
Diffstat (limited to 'src/test/test_hs_client.c')
-rw-r--r-- | src/test/test_hs_client.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/test/test_hs_client.c b/src/test/test_hs_client.c index 58e12abca0..50dca588ed 100644 --- a/src/test/test_hs_client.c +++ b/src/test/test_hs_client.c @@ -397,21 +397,25 @@ test_client_pick_intro(void *arg) } SMARTLIST_FOREACH_END(ip); /* Try to get a random intro: Should return the chosen one! */ - extend_info_t *ip = client_get_random_intro(&service_kp.pubkey); - tor_assert(ip); - tt_assert(!tor_mem_is_zero((char*)ip->identity_digest, DIGEST_LEN)); - tt_mem_op(ip->identity_digest, OP_EQ, chosen_intro_ei->identity_digest, - DIGEST_LEN); + /* (We try several times, to make sure this behavior is consistent, and to + * cover the different cases of client_get_random_intro().) */ + for (int i = 0; i < 64; ++i) { + extend_info_t *ip = client_get_random_intro(&service_kp.pubkey); + tor_assert(ip); + tt_assert(!tor_mem_is_zero((char*)ip->identity_digest, DIGEST_LEN)); + tt_mem_op(ip->identity_digest, OP_EQ, chosen_intro_ei->identity_digest, + DIGEST_LEN); + extend_info_free(ip); + } extend_info_free(chosen_intro_ei); - extend_info_free(ip); /* Now also mark the chosen one as failed: See that we can't get any intro points anymore. */ hs_cache_client_intro_state_note(&service_kp.pubkey, &chosen_intro_point->auth_key_cert->signed_key, INTRO_POINT_FAILURE_TIMEOUT); - ip = client_get_random_intro(&service_kp.pubkey); + extend_info_t *ip = client_get_random_intro(&service_kp.pubkey); tor_assert(!ip); } |