#define RENDCOMMON_PRIVATE
#define GEOIP_PRIVATE
#define CONNECTION_PRIVATE
+#define CONFIG_PRIVATE
+#define RENDCACHE_PRIVATE
#include "or.h"
#include "config.h"
connection_free_(TO_CONN(conn));
tor_free(header);
tor_free(body);
+ tor_free(exp_body);
}
#define RENDEZVOUS2_GET(descid) GET("/tor/rendezvous2/" descid)
NS(router_get_my_routerinfo)(void)
{
if (!mock_routerinfo) {
- mock_routerinfo = tor_malloc(sizeof(routerinfo_t));
+ mock_routerinfo = tor_malloc_zero(sizeof(routerinfo_t));
}
return mock_routerinfo;
UNMOCK(connection_write_to_buf_impl_);
NS_UNMOCK(router_get_my_routerinfo);
NS_UNMOCK(hid_serv_responsible_for_desc_id);
+ tor_free(mock_routerinfo->cache_info.signed_descriptor_body);
+ tor_free(mock_routerinfo);
connection_free_(TO_CONN(conn));
tor_free(header);
tor_free(body);
+ rend_encoded_v2_service_descriptor_free(desc_holder);
+ tor_free(service_id);
rend_cache_free_all();
}
UNMOCK(get_options);
UNMOCK(connection_write_to_buf_impl_);
- if (mock_options)
- tor_free(mock_options->DataDirectory);
+ or_options_free(mock_options); mock_options = NULL;
connection_free_(TO_CONN(conn));
tor_free(header);
tor_free(body);
UNMOCK(get_options);
UNMOCK(connection_write_to_buf_impl_);
- if (mock_options)
- tor_free(mock_options->DataDirectory);
-
+ or_options_free(mock_options); mock_options = NULL;
connection_free_(TO_CONN(conn));
tor_free(header);
smartlist_free(list);
done:
UNMOCK(get_options);
UNMOCK(connection_write_to_buf_impl_);
- tor_free(mock_options);
+ or_options_free(mock_options); mock_options = NULL;
connection_free_(TO_CONN(conn));
tor_free(header);
}
done:
UNMOCK(get_options);
UNMOCK(connection_write_to_buf_impl_);
- tor_free(mock_options);
+ or_options_free(mock_options); mock_options = NULL;
connection_free_(TO_CONN(conn));
tor_free(header);
}
done:
UNMOCK(get_options);
UNMOCK(connection_write_to_buf_impl_);
- tor_free(mock_options);
+ or_options_free(mock_options); mock_options = NULL;
connection_free_(TO_CONN(conn));
tor_free(header);
}
done:
UNMOCK(connection_write_to_buf_impl_);
- tor_free(mock_options);
+ or_options_free(mock_options); mock_options = NULL;
connection_free_(TO_CONN(conn));
tor_free(header);
}
long annotation_len = strstr(TEST_DESCRIPTOR, "router ") - TEST_DESCRIPTOR;
mock_routerinfo->cache_info.signed_descriptor_body =
tor_strdup(TEST_DESCRIPTOR);
- mock_routerinfo->cache_info.signed_descriptor_len = strlen(TEST_DESCRIPTOR);
+ mock_routerinfo->cache_info.signed_descriptor_len =
+ strlen(TEST_DESCRIPTOR) - annotation_len;;
mock_routerinfo->cache_info.annotations_len = annotation_len;
conn = dir_connection_new(tor_addr_family(&MOCK_TOR_ADDR));
tt_assert(strstr(header, "Content-Type: text/plain\r\n"));
tt_assert(strstr(header, "Content-Encoding: identity\r\n"));
- //TODO: Is this a BUG?
- //This is what should be expected:
- //tt_int_op(body_used, OP_EQ, strlen(body));
- tt_int_op(body_used, OP_EQ, strlen(TEST_DESCRIPTOR));
+ tt_int_op(body_used, OP_EQ, strlen(body));
tt_str_op(body, OP_EQ, TEST_DESCRIPTOR + annotation_len);
tt_int_op(conn->dir_spool_src, OP_EQ, DIR_SPOOL_NONE);
done:
NS_UNMOCK(router_get_my_routerinfo);
UNMOCK(connection_write_to_buf_impl_);
+ tor_free(mock_routerinfo->cache_info.signed_descriptor_body);
tor_free(mock_routerinfo);
connection_free_(TO_CONN(conn));
tor_free(header);
long annotation_len = strstr(TEST_DESCRIPTOR, "router ") - TEST_DESCRIPTOR;
mock_routerinfo->cache_info.signed_descriptor_body =
tor_strdup(TEST_DESCRIPTOR);
- mock_routerinfo->cache_info.signed_descriptor_len = strlen(TEST_DESCRIPTOR);
+ mock_routerinfo->cache_info.signed_descriptor_len =
+ strlen(TEST_DESCRIPTOR) - annotation_len;
mock_routerinfo->cache_info.annotations_len = annotation_len;
conn = dir_connection_new(tor_addr_family(&MOCK_TOR_ADDR));
tt_assert(strstr(header, "Content-Type: text/plain\r\n"));
tt_assert(strstr(header, "Content-Encoding: identity\r\n"));
- //TODO: Is this a BUG?
- //This is what should be expected:
- //tt_int_op(body_used, OP_EQ, strlen(body));
- tt_int_op(body_used, OP_EQ, strlen(TEST_DESCRIPTOR));
+ tt_int_op(body_used, OP_EQ, strlen(body));
tt_str_op(body, OP_EQ, TEST_DESCRIPTOR + annotation_len);
tt_int_op(conn->dir_spool_src, OP_EQ, DIR_SPOOL_NONE);
done:
NS_UNMOCK(router_get_my_routerinfo);
UNMOCK(connection_write_to_buf_impl_);
+ tor_free(mock_routerinfo->cache_info.signed_descriptor_body);
tor_free(mock_routerinfo);
connection_free_(TO_CONN(conn));
tor_free(header);
connection_free_(TO_CONN(conn));
tor_free(header);
tor_free(body);
- tor_free(mock_cert);
+ authority_cert_free(mock_cert); mock_cert = NULL;
}
static void
UNMOCK(get_my_v3_authority_cert);
UNMOCK(connection_write_to_buf_impl_);
connection_free_(TO_CONN(conn));
+ authority_cert_free(mock_cert); mock_cert = NULL;
tor_free(header);
tor_free(body);
}
UNMOCK(connection_write_to_buf_impl_);
connection_free_(TO_CONN(conn));
tor_free(header);
- tor_free(mock_options);
+ or_options_free(mock_options); mock_options = NULL;
clear_dir_servers();
routerlist_free_all();
{
dir_connection_t *conn = NULL;
char *header = NULL;
+ char *stats = NULL;
(void) d;
/* init mock */
tt_assert(header);
tt_str_op(NOT_ENOUGH_CONSENSUS_SIGNATURES, OP_EQ, header);
- char *stats = geoip_format_dirreq_stats(time(NULL));
+ stats = geoip_format_dirreq_stats(time(NULL));
tt_assert(stats);
tt_assert(strstr(stats, "not-enough-sigs=8"));
connection_free_(TO_CONN(conn));
tor_free(header);
+ tor_free(stats);
smartlist_free(mock_ns_val->voters);
tor_free(mock_ns_val);
- tor_free(mock_options);
+ or_options_free(mock_options); mock_options = NULL;
}
static void
{
dir_connection_t *conn = NULL;
char *header = NULL;
+ char *stats = NULL;
(void) data;
init_mock_options();
tt_assert(header);
tt_str_op(NOT_FOUND, OP_EQ, header);
- char *stats = geoip_format_dirreq_stats(time(NULL));
+ stats = geoip_format_dirreq_stats(time(NULL));
tt_assert(stats);
tt_assert(strstr(stats, "not-found=8"));
UNMOCK(get_options);
connection_free_(TO_CONN(conn));
tor_free(header);
- tor_free(mock_options);
+ tor_free(stats);
+ or_options_free(mock_options); mock_options = NULL;
}
NS_DECL(int, geoip_get_country_by_addr, (const tor_addr_t *addr));
tor_free(body);
tor_free(stats);
tor_free(hist);
- tor_free(mock_options);
+ or_options_free(mock_options); mock_options = NULL;
dirserv_free_all();
clear_geoip_db();
char *header = NULL;
char *body = NULL;
size_t body_used = 0;
+ char *stats = NULL;
(void) data;
dirserv_free_all();
tt_str_op(SERVER_BUSY, OP_EQ, header);
- char *stats = geoip_format_dirreq_stats(time(NULL));
+ stats = geoip_format_dirreq_stats(time(NULL));
tt_assert(stats);
tt_assert(strstr(stats, "busy=8"));
UNMOCK(get_options);
tor_free(header);
tor_free(body);
- tor_free(mock_options);
+ or_options_free(mock_options); mock_options = NULL;
+ tor_free(stats);
dirserv_free_all();
clear_geoip_db();
}
done:
tor_free(header);
tor_free(body);
- tor_free(mock_options);
+ or_options_free(mock_options); mock_options = NULL;
clear_dir_servers();
dirvote_free_all();
UNMOCK(get_options);
tor_free(header);
tor_free(body);
- tor_free(mock_options);
+ or_options_free(mock_options); mock_options = NULL;
}
static void
body, body_used, 22, 0);
done:
+ connection_free_(TO_CONN(conn));
UNMOCK(connection_write_to_buf_impl_);
}
connection_free_(TO_CONN(conn));
tor_free(header);
tor_free(body);
- tor_free(mock_options);
+ or_options_free(mock_options); mock_options = NULL;
}
static void
UNMOCK(get_my_v3_authority_cert);
connection_free_(TO_CONN(conn));
tor_free(header);
- tor_free(mock_cert);
-
+ tor_free(body);
+ authority_cert_free(mock_cert); mock_cert = NULL;
+ or_options_free(mock_options); mock_options = NULL;
+
clear_dir_servers();
routerlist_free_all();
dirvote_free_all();
UNMOCK(get_my_v3_authority_cert);
connection_free_(TO_CONN(conn));
tor_free(header);
- tor_free(mock_cert);
+ tor_free(body);
+ authority_cert_free(mock_cert); mock_cert = NULL;
+ or_options_free(mock_options); mock_options = NULL;
clear_dir_servers();
routerlist_free_all();