summaryrefslogtreecommitdiff
path: root/src/test/test_rendcache.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/test_rendcache.c')
-rw-r--r--src/test/test_rendcache.c66
1 files changed, 0 insertions, 66 deletions
diff --git a/src/test/test_rendcache.c b/src/test/test_rendcache.c
index eaa8671af0..9898e87098 100644
--- a/src/test/test_rendcache.c
+++ b/src/test/test_rendcache.c
@@ -377,10 +377,8 @@ test_rend_cache_store_v2_desc_as_client_with_different_time(void *data)
#define NS_SUBMODULE lookup_v2_desc_as_dir
NS_DECL(const routerinfo_t *, router_get_my_routerinfo, (void));
-NS_DECL(int, hid_serv_responsible_for_desc_id, (const char *id));
static routerinfo_t *mock_routerinfo;
-static int hid_serv_responsible_for_desc_id_response;
static const routerinfo_t *
NS(router_get_my_routerinfo)(void)
@@ -392,13 +390,6 @@ NS(router_get_my_routerinfo)(void)
return mock_routerinfo;
}
-static int
-NS(hid_serv_responsible_for_desc_id)(const char *id)
-{
- (void)id;
- return hid_serv_responsible_for_desc_id_response;
-}
-
static void
test_rend_cache_lookup_v2_desc_as_dir(void *data)
{
@@ -411,7 +402,6 @@ test_rend_cache_lookup_v2_desc_as_dir(void *data)
(void)data;
NS_MOCK(router_get_my_routerinfo);
- NS_MOCK(hid_serv_responsible_for_desc_id);
rend_cache_init();
@@ -425,7 +415,6 @@ test_rend_cache_lookup_v2_desc_as_dir(void *data)
tt_int_op(ret, OP_EQ, 0);
// Test existing descriptor
- hid_serv_responsible_for_desc_id_response = 1;
generate_desc(RECENT_TIME, &desc_holder, &service_id, 3);
rend_cache_store_v2_desc_as_dir(desc_holder->desc_str);
base32_encode(desc_id_base32, sizeof(desc_id_base32), desc_holder->desc_id,
@@ -436,7 +425,6 @@ test_rend_cache_lookup_v2_desc_as_dir(void *data)
done:
NS_UNMOCK(router_get_my_routerinfo);
- NS_UNMOCK(hid_serv_responsible_for_desc_id);
tor_free(mock_routerinfo);
rend_cache_free_all();
rend_encoded_v2_service_descriptor_free(desc_holder);
@@ -447,7 +435,6 @@ test_rend_cache_lookup_v2_desc_as_dir(void *data)
#define NS_SUBMODULE store_v2_desc_as_dir
NS_DECL(const routerinfo_t *, router_get_my_routerinfo, (void));
-NS_DECL(int, hid_serv_responsible_for_desc_id, (const char *id));
static const routerinfo_t *
NS(router_get_my_routerinfo)(void)
@@ -455,13 +442,6 @@ NS(router_get_my_routerinfo)(void)
return mock_routerinfo;
}
-static int
-NS(hid_serv_responsible_for_desc_id)(const char *id)
-{
- (void)id;
- return hid_serv_responsible_for_desc_id_response;
-}
-
static void
test_rend_cache_store_v2_desc_as_dir(void *data)
{
@@ -471,7 +451,6 @@ test_rend_cache_store_v2_desc_as_dir(void *data)
char *service_id = NULL;
NS_MOCK(router_get_my_routerinfo);
- NS_MOCK(hid_serv_responsible_for_desc_id);
rend_cache_init();
@@ -482,21 +461,10 @@ test_rend_cache_store_v2_desc_as_dir(void *data)
// Test when we can't parse the descriptor
mock_routerinfo = tor_malloc(sizeof(routerinfo_t));
- hid_serv_responsible_for_desc_id_response = 1;
ret = rend_cache_store_v2_desc_as_dir("unparseable");
tt_int_op(ret, OP_EQ, RCS_BADDESC);
- // Test when we are not responsible for an HS
- hid_serv_responsible_for_desc_id_response = 0;
- generate_desc(RECENT_TIME, &desc_holder, &service_id, 3);
- ret = rend_cache_store_v2_desc_as_dir(desc_holder->desc_str);
- tt_int_op(ret, OP_EQ, RCS_OKAY);
-
- rend_encoded_v2_service_descriptor_free(desc_holder);
- tor_free(service_id);
-
// Test when we have an old descriptor
- hid_serv_responsible_for_desc_id_response = 1;
generate_desc(TIME_IN_THE_PAST, &desc_holder, &service_id, 3);
ret = rend_cache_store_v2_desc_as_dir(desc_holder->desc_str);
tt_int_op(ret, OP_EQ, RCS_OKAY);
@@ -529,7 +497,6 @@ test_rend_cache_store_v2_desc_as_dir(void *data)
done:
NS_UNMOCK(router_get_my_routerinfo);
- NS_UNMOCK(hid_serv_responsible_for_desc_id);
rend_encoded_v2_service_descriptor_free(desc_holder);
tor_free(service_id);
rend_cache_free_all();
@@ -550,7 +517,6 @@ test_rend_cache_store_v2_desc_as_dir_with_different_time(void *data)
rend_encoded_v2_service_descriptor_t *desc_holder_older;
NS_MOCK(router_get_my_routerinfo);
- NS_MOCK(hid_serv_responsible_for_desc_id);
rend_cache_init();
@@ -577,7 +543,6 @@ test_rend_cache_store_v2_desc_as_dir_with_different_time(void *data)
// Test when we have a newer descriptor stored
mock_routerinfo = tor_malloc(sizeof(routerinfo_t));
- hid_serv_responsible_for_desc_id_response = 1;
rend_cache_store_v2_desc_as_dir(desc_holder_newer->desc_str);
ret = rend_cache_store_v2_desc_as_dir(desc_holder_older->desc_str);
tt_int_op(ret, OP_EQ, RCS_OKAY);
@@ -590,7 +555,6 @@ test_rend_cache_store_v2_desc_as_dir_with_different_time(void *data)
done:
NS_UNMOCK(router_get_my_routerinfo);
- NS_UNMOCK(hid_serv_responsible_for_desc_id);
rend_cache_free_all();
rend_service_descriptor_free(generated);
tor_free(service_id);
@@ -616,7 +580,6 @@ test_rend_cache_store_v2_desc_as_dir_with_different_content(void *data)
rend_encoded_v2_service_descriptor_t *desc_holder_two = NULL;
NS_MOCK(router_get_my_routerinfo);
- NS_MOCK(hid_serv_responsible_for_desc_id);
rend_cache_init();
@@ -645,14 +608,12 @@ test_rend_cache_store_v2_desc_as_dir_with_different_content(void *data)
// Test when we have another descriptor stored, with a different descriptor
mock_routerinfo = tor_malloc(sizeof(routerinfo_t));
- hid_serv_responsible_for_desc_id_response = 1;
rend_cache_store_v2_desc_as_dir(desc_holder_one->desc_str);
ret = rend_cache_store_v2_desc_as_dir(desc_holder_two->desc_str);
tt_int_op(ret, OP_EQ, RCS_OKAY);
done:
NS_UNMOCK(router_get_my_routerinfo);
- NS_UNMOCK(hid_serv_responsible_for_desc_id);
rend_cache_free_all();
rend_service_descriptor_free(generated);
tor_free(service_id);
@@ -1113,14 +1074,6 @@ test_rend_cache_intro_failure_note(void *data)
}
#define NS_SUBMODULE clean_v2_descs_as_dir
-NS_DECL(int, hid_serv_responsible_for_desc_id, (const char *id));
-
-static int
-NS(hid_serv_responsible_for_desc_id)(const char *id)
-{
- (void)id;
- return hid_serv_responsible_for_desc_id_response;
-}
static void
test_rend_cache_clean_v2_descs_as_dir(void *data)
@@ -1133,7 +1086,6 @@ test_rend_cache_clean_v2_descs_as_dir(void *data)
(void)data;
- NS_MOCK(hid_serv_responsible_for_desc_id);
rend_cache_init();
// Test running with an empty cache
@@ -1149,7 +1101,6 @@ test_rend_cache_clean_v2_descs_as_dir(void *data)
e->parsed = desc;
digestmap_set(rend_cache_v2_dir, key, e);
- hid_serv_responsible_for_desc_id_response = 1;
rend_cache_clean_v2_descs_as_dir(now, 0);
tt_int_op(digestmap_size(rend_cache_v2_dir), OP_EQ, 1);
@@ -1158,20 +1109,6 @@ test_rend_cache_clean_v2_descs_as_dir(void *data)
rend_cache_clean_v2_descs_as_dir(now, 0);
tt_int_op(digestmap_size(rend_cache_v2_dir), OP_EQ, 0);
- // Test with one entry that is not under the responsibility of this
- // hidden service
- e = tor_malloc_zero(sizeof(rend_cache_entry_t));
- e->last_served = now;
- desc = tor_malloc_zero(sizeof(rend_service_descriptor_t));
- desc->timestamp = now;
- desc->pk = pk_generate(0);
- e->parsed = desc;
- digestmap_set(rend_cache_v2_dir, key, e);
-
- hid_serv_responsible_for_desc_id_response = 0;
- rend_cache_clean_v2_descs_as_dir(now, 0);
- tt_int_op(digestmap_size(rend_cache_v2_dir), OP_EQ, 0);
-
// Test with one entry that has an old last served
e = tor_malloc_zero(sizeof(rend_cache_entry_t));
e->last_served = now - (REND_CACHE_MAX_AGE + REND_CACHE_MAX_SKEW + 1000);
@@ -1181,7 +1118,6 @@ test_rend_cache_clean_v2_descs_as_dir(void *data)
e->parsed = desc;
digestmap_set(rend_cache_v2_dir, key, e);
- hid_serv_responsible_for_desc_id_response = 1;
rend_cache_clean_v2_descs_as_dir(now, 0);
tt_int_op(digestmap_size(rend_cache_v2_dir), OP_EQ, 0);
@@ -1194,12 +1130,10 @@ test_rend_cache_clean_v2_descs_as_dir(void *data)
e->parsed = desc;
digestmap_set(rend_cache_v2_dir, key, e);
- hid_serv_responsible_for_desc_id_response = 1;
rend_cache_clean_v2_descs_as_dir(now, 20000);
tt_int_op(digestmap_size(rend_cache_v2_dir), OP_EQ, 1);
done:
- NS_UNMOCK(hid_serv_responsible_for_desc_id);
rend_cache_free_all();
}