[tor-commits] [tor/master] test: Remove buggy unit test in test_hs_service

nickm at torproject.org nickm at torproject.org
Mon Jul 24 18:12:12 UTC 2017


commit 10331081c731cba3e45fd2ffe2649e10797e193b
Author: David Goulet <dgoulet at torproject.org>
Date:   Mon Jul 24 11:31:54 2017 -0400

    test: Remove buggy unit test in test_hs_service
    
    There isn't much of a point of this buggy test afterall to add twice the same
    service object but with a different key which ultinately can end up failing
    the test because 1/N_BUCKETS of probability that we end up to put the service
    in the same bucket.
    
    Fixes #23023
    
    Signed-off-by: David Goulet <dgoulet at torproject.org>
---
 src/test/test_hs_service.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/src/test/test_hs_service.c b/src/test/test_hs_service.c
index 24fca08a1..4a7cb8114 100644
--- a/src/test/test_hs_service.c
+++ b/src/test/test_hs_service.c
@@ -488,6 +488,7 @@ test_access_service(void *arg)
   char *conf = NULL;
   char *hsdir_v3 = tor_strdup(get_fname("hs3"));
   hs_service_ht *global_map;
+  hs_service_t *s = NULL;
 
   (void) arg;
 
@@ -513,7 +514,7 @@ test_access_service(void *arg)
    * in the global map. */
   hs_service_load_all_keys();
   tt_int_op(get_hs_service_map_size(), OP_EQ, 1);
-  hs_service_t *s = get_first_service();
+  s = get_first_service();
   tt_assert(s);
   global_map = get_hs_service_map();
   tt_assert(global_map);
@@ -535,14 +536,9 @@ test_access_service(void *arg)
   /* Twice should fail. */
   ret = register_service(global_map, s);
   tt_int_op(ret, OP_EQ, -1);
-  /* Modify key of service and we should be able to put it back in. */
-  s->keys.identity_pk.pubkey[1] = '\x42';
-  ret = register_service(global_map, s);
-  tt_int_op(ret, OP_EQ, 0);
-  tt_int_op(get_hs_service_map_size(), OP_EQ, 2);
   /* Remove service from map so we don't double free on cleanup. */
   remove_service(global_map, s);
-  tt_int_op(get_hs_service_map_size(), OP_EQ, 1);
+  tt_int_op(get_hs_service_map_size(), OP_EQ, 0);
   query = find_service(global_map, &s->keys.identity_pk);
   tt_assert(!query);
   /* Let's try to remove twice for fun. */
@@ -552,6 +548,7 @@ test_access_service(void *arg)
   teardown_capture_of_logs();
 
  done:
+  hs_service_free(s);
   tor_free(hsdir_v3);
   hs_free_all();
 }



More information about the tor-commits mailing list