|
@@ -289,6 +289,20 @@ helper_create_service(void)
|
|
return service;
|
|
return service;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+ * remove it from onion service map.
|
|
|
|
+ * */
|
|
|
|
+static void
|
|
|
|
+helper_destroy_service(hs_service_t *service)
|
|
|
|
+{
|
|
|
|
+ if (!service)
|
|
|
|
+ return;
|
|
|
|
+
|
|
|
|
+ remove_service(get_hs_service_map(), service);
|
|
|
|
+
|
|
|
|
+ hs_service_free(service);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
|
|
static hs_service_t *
|
|
static hs_service_t *
|
|
helper_create_service_with_clients(int num_clients)
|
|
helper_create_service_with_clients(int num_clients)
|
|
@@ -1626,6 +1640,7 @@ test_build_descriptors(void *arg)
|
|
{
|
|
{
|
|
int ret;
|
|
int ret;
|
|
time_t now = time(NULL);
|
|
time_t now = time(NULL);
|
|
|
|
+ hs_service_t *last_service = NULL;
|
|
|
|
|
|
(void) arg;
|
|
(void) arg;
|
|
|
|
|
|
@@ -1650,6 +1665,7 @@ test_build_descriptors(void *arg)
|
|
* is disabled. */
|
|
* is disabled. */
|
|
{
|
|
{
|
|
hs_service_t *service = helper_create_service();
|
|
hs_service_t *service = helper_create_service();
|
|
|
|
+ last_service = service;
|
|
service_descriptor_free(service->desc_current);
|
|
service_descriptor_free(service->desc_current);
|
|
service->desc_current = NULL;
|
|
service->desc_current = NULL;
|
|
|
|
|
|
@@ -1660,12 +1676,16 @@ test_build_descriptors(void *arg)
|
|
hs_desc_superencrypted_data_t *superencrypted;
|
|
hs_desc_superencrypted_data_t *superencrypted;
|
|
superencrypted = &service->desc_current->desc->superencrypted_data;
|
|
superencrypted = &service->desc_current->desc->superencrypted_data;
|
|
tt_int_op(smartlist_len(superencrypted->clients), OP_EQ, 16);
|
|
tt_int_op(smartlist_len(superencrypted->clients), OP_EQ, 16);
|
|
|
|
+
|
|
|
|
+ helper_destroy_service(service);
|
|
|
|
+ last_service = NULL;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
* clients is zero. */
|
|
* clients is zero. */
|
|
{
|
|
{
|
|
hs_service_t *service = helper_create_service_with_clients(0);
|
|
hs_service_t *service = helper_create_service_with_clients(0);
|
|
|
|
+ last_service = service;
|
|
service_descriptor_free(service->desc_current);
|
|
service_descriptor_free(service->desc_current);
|
|
service->desc_current = NULL;
|
|
service->desc_current = NULL;
|
|
|
|
|
|
@@ -1673,12 +1693,16 @@ test_build_descriptors(void *arg)
|
|
hs_desc_superencrypted_data_t *superencrypted;
|
|
hs_desc_superencrypted_data_t *superencrypted;
|
|
superencrypted = &service->desc_current->desc->superencrypted_data;
|
|
superencrypted = &service->desc_current->desc->superencrypted_data;
|
|
tt_int_op(smartlist_len(superencrypted->clients), OP_EQ, 16);
|
|
tt_int_op(smartlist_len(superencrypted->clients), OP_EQ, 16);
|
|
|
|
+
|
|
|
|
+ helper_destroy_service(service);
|
|
|
|
+ last_service = NULL;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
* clients is not a multiple of 16. */
|
|
* clients is not a multiple of 16. */
|
|
{
|
|
{
|
|
hs_service_t *service = helper_create_service_with_clients(20);
|
|
hs_service_t *service = helper_create_service_with_clients(20);
|
|
|
|
+ last_service = service;
|
|
service_descriptor_free(service->desc_current);
|
|
service_descriptor_free(service->desc_current);
|
|
service->desc_current = NULL;
|
|
service->desc_current = NULL;
|
|
|
|
|
|
@@ -1686,12 +1710,16 @@ test_build_descriptors(void *arg)
|
|
hs_desc_superencrypted_data_t *superencrypted;
|
|
hs_desc_superencrypted_data_t *superencrypted;
|
|
superencrypted = &service->desc_current->desc->superencrypted_data;
|
|
superencrypted = &service->desc_current->desc->superencrypted_data;
|
|
tt_int_op(smartlist_len(superencrypted->clients), OP_EQ, 32);
|
|
tt_int_op(smartlist_len(superencrypted->clients), OP_EQ, 32);
|
|
|
|
+
|
|
|
|
+ helper_destroy_service(service);
|
|
|
|
+ last_service = NULL;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
* a multiple of 16 but not zero. */
|
|
* a multiple of 16 but not zero. */
|
|
{
|
|
{
|
|
hs_service_t *service = helper_create_service_with_clients(32);
|
|
hs_service_t *service = helper_create_service_with_clients(32);
|
|
|
|
+ last_service = service;
|
|
service_descriptor_free(service->desc_current);
|
|
service_descriptor_free(service->desc_current);
|
|
service->desc_current = NULL;
|
|
service->desc_current = NULL;
|
|
|
|
|
|
@@ -1699,9 +1727,13 @@ test_build_descriptors(void *arg)
|
|
hs_desc_superencrypted_data_t *superencrypted;
|
|
hs_desc_superencrypted_data_t *superencrypted;
|
|
superencrypted = &service->desc_current->desc->superencrypted_data;
|
|
superencrypted = &service->desc_current->desc->superencrypted_data;
|
|
tt_int_op(smartlist_len(superencrypted->clients), OP_EQ, 32);
|
|
tt_int_op(smartlist_len(superencrypted->clients), OP_EQ, 32);
|
|
|
|
+
|
|
|
|
+ helper_destroy_service(service);
|
|
|
|
+ last_service = NULL;
|
|
}
|
|
}
|
|
|
|
|
|
done:
|
|
done:
|
|
|
|
+ helper_destroy_service(last_service);
|
|
hs_free_all();
|
|
hs_free_all();
|
|
}
|
|
}
|
|
|
|
|