aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'src/test')
-rw-r--r--src/test/test_btrack.c4
-rw-r--r--src/test/test_circuitpadding.c4
-rw-r--r--src/test/test_controller_events.c3
-rw-r--r--src/test/test_hs_cache.c23
-rw-r--r--src/test/test_hs_common.c1
-rw-r--r--src/test/test_hs_service.c1
-rw-r--r--src/test/test_introduce.c3
-rw-r--r--src/test/test_token_bucket.c2
-rw-r--r--src/test/test_util.c2
9 files changed, 37 insertions, 6 deletions
diff --git a/src/test/test_btrack.c b/src/test/test_btrack.c
index 9e5d0d0723..21e88a57b6 100644
--- a/src/test/test_btrack.c
+++ b/src/test/test_btrack.c
@@ -44,6 +44,8 @@ test_btrack_launch(void *arg)
{
orconn_state_msg_t conn;
ocirc_chan_msg_t circ;
+ memset(&conn, 0, sizeof(conn));
+ memset(&circ, 0, sizeof(circ));
(void)arg;
conn.gid = 1;
@@ -93,6 +95,8 @@ test_btrack_delete(void *arg)
{
orconn_state_msg_t state;
orconn_status_msg_t status;
+ memset(&state, 0, sizeof(state));
+ memset(&status, 0, sizeof(status));
(void)arg;
state.gid = 1;
diff --git a/src/test/test_circuitpadding.c b/src/test/test_circuitpadding.c
index 915f086615..934ddb0208 100644
--- a/src/test/test_circuitpadding.c
+++ b/src/test/test_circuitpadding.c
@@ -92,10 +92,10 @@ static void
nodes_init(void)
{
padding_node.rs = tor_malloc_zero(sizeof(routerstatus_t));
- padding_node.rs->pv.supports_padding = 1;
+ padding_node.rs->pv.supports_hs_setup_padding = 1;
non_padding_node.rs = tor_malloc_zero(sizeof(routerstatus_t));
- non_padding_node.rs->pv.supports_padding = 0;
+ non_padding_node.rs->pv.supports_hs_setup_padding = 0;
}
static void
diff --git a/src/test/test_controller_events.c b/src/test/test_controller_events.c
index a8967bba50..9fb2bc7256 100644
--- a/src/test/test_controller_events.c
+++ b/src/test/test_controller_events.c
@@ -429,6 +429,7 @@ static void
test_cntev_orconn_state(void *arg)
{
orconn_state_msg_t conn;
+ memset(&conn, 0, sizeof(conn));
(void)arg;
MOCK(queue_control_event_string, mock_queue_control_event_string);
@@ -468,6 +469,7 @@ static void
test_cntev_orconn_state_pt(void *arg)
{
orconn_state_msg_t conn;
+ memset(&conn, 0, sizeof(conn));
(void)arg;
MOCK(queue_control_event_string, mock_queue_control_event_string);
@@ -503,6 +505,7 @@ static void
test_cntev_orconn_state_proxy(void *arg)
{
orconn_state_msg_t conn;
+ memset(&conn, 0, sizeof(conn));
(void)arg;
MOCK(queue_control_event_string, mock_queue_control_event_string);
diff --git a/src/test/test_hs_cache.c b/src/test/test_hs_cache.c
index d71f8b6b18..86ac7e7fb1 100644
--- a/src/test/test_hs_cache.c
+++ b/src/test/test_hs_cache.c
@@ -10,6 +10,7 @@
#define DIRCACHE_PRIVATE
#define DIRCLIENT_PRIVATE
#define HS_CACHE_PRIVATE
+#define TOR_CHANNEL_INTERNAL_
#include "trunnel/ed25519_cert.h"
#include "feature/hs/hs_cache.h"
@@ -20,7 +21,12 @@
#include "core/mainloop/connection.h"
#include "core/proto/proto_http.h"
#include "lib/crypt_ops/crypto_format.h"
+#include "core/or/circuitlist.h"
+#include "core/or/channel.h"
+#include "core/or/edge_connection_st.h"
+#include "core/or/or_circuit_st.h"
+#include "core/or/or_connection_st.h"
#include "feature/dircommon/dir_connection_st.h"
#include "feature/nodelist/networkstatus_st.h"
@@ -232,6 +238,8 @@ helper_fetch_desc_from_hsdir(const ed25519_public_key_t *blinded_key)
/* The dir conn we are going to simulate */
dir_connection_t *conn = NULL;
+ edge_connection_t *edge_conn = NULL;
+ or_circuit_t *or_circ = NULL;
/* First extract the blinded public key that we are going to use in our
query, and then build the actual query string. */
@@ -245,8 +253,16 @@ helper_fetch_desc_from_hsdir(const ed25519_public_key_t *blinded_key)
/* Simulate an HTTP GET request to the HSDir */
conn = dir_connection_new(AF_INET);
tt_assert(conn);
+ TO_CONN(conn)->linked = 1; /* Signal that it is encrypted. */
tor_addr_from_ipv4h(&conn->base_.addr, 0x7f000001);
- TO_CONN(conn)->linked = 1;/* Pretend the conn is encrypted :) */
+
+ /* Pretend this conn is anonymous. */
+ edge_conn = edge_connection_new(CONN_TYPE_EXIT, AF_INET);
+ TO_CONN(conn)->linked_conn = TO_CONN(edge_conn);
+ or_circ = or_circuit_new(0, NULL);
+ or_circ->p_chan = tor_malloc_zero(sizeof(channel_t));
+ edge_conn->on_circuit = TO_CIRCUIT(or_circ);
+
retval = directory_handle_command_get(conn, hsdir_query_str,
NULL, 0);
tt_int_op(retval, OP_EQ, 0);
@@ -263,8 +279,11 @@ helper_fetch_desc_from_hsdir(const ed25519_public_key_t *blinded_key)
done:
tor_free(hsdir_query_str);
- if (conn)
+ if (conn) {
+ tor_free(or_circ->p_chan);
+ connection_free_minimal(TO_CONN(conn)->linked_conn);
connection_free_minimal(TO_CONN(conn));
+ }
return received_desc;
}
diff --git a/src/test/test_hs_common.c b/src/test/test_hs_common.c
index abded6021e..de3f7e04f7 100644
--- a/src/test/test_hs_common.c
+++ b/src/test/test_hs_common.c
@@ -502,6 +502,7 @@ test_desc_reupload_logic(void *arg)
pubkey_hex, strlen(pubkey_hex));
hs_build_address(&pubkey, HS_VERSION_THREE, onion_addr);
service = tor_malloc_zero(sizeof(hs_service_t));
+ tt_assert(service);
memcpy(service->onion_address, onion_addr, sizeof(service->onion_address));
ed25519_secret_key_generate(&service->keys.identity_sk, 0);
ed25519_public_key_generate(&service->keys.identity_pk,
diff --git a/src/test/test_hs_service.c b/src/test/test_hs_service.c
index a303f10411..2e4be4e295 100644
--- a/src/test/test_hs_service.c
+++ b/src/test/test_hs_service.c
@@ -1265,6 +1265,7 @@ test_service_event(void *arg)
/* Set a service for this circuit. */
service = helper_create_service();
+ tt_assert(service);
ed25519_pubkey_copy(&circ->hs_ident->identity_pk,
&service->keys.identity_pk);
diff --git a/src/test/test_introduce.c b/src/test/test_introduce.c
index 4a6d90d97e..104e973b1f 100644
--- a/src/test/test_introduce.c
+++ b/src/test/test_introduce.c
@@ -383,8 +383,10 @@ make_intro_from_plaintext(
/* Output the cell */
*cell_out = cell;
+ cell = NULL;
done:
+ tor_free(cell);
return cell_len;
}
@@ -535,4 +537,3 @@ struct testcase_t introduce_tests[] = {
INTRODUCE_LEGACY(late_parse_v3),
END_OF_TESTCASES
};
-
diff --git a/src/test/test_token_bucket.c b/src/test/test_token_bucket.c
index d3ce591388..31670718d9 100644
--- a/src/test/test_token_bucket.c
+++ b/src/test/test_token_bucket.c
@@ -93,7 +93,7 @@ test_token_bucket_ctr_dec(void *arg)
/* Keep underflowing shouldn't flag the bucket as empty. */
tt_uint_op(false, OP_EQ, token_bucket_ctr_dec(&tb, BURST));
- tt_int_op(tb.counter.bucket, OP_EQ, (int32_t) ((BURST + 1) * -1));
+ tt_int_op(tb.counter.bucket, OP_EQ, - (int32_t) (BURST + 1));
done:
;
diff --git a/src/test/test_util.c b/src/test/test_util.c
index 41ecbfd388..c56d3488ba 100644
--- a/src/test/test_util.c
+++ b/src/test/test_util.c
@@ -5399,11 +5399,13 @@ test_util_socketpair(void *arg)
tt_skip();
}
#endif /* defined(__FreeBSD__) */
+#ifdef ENETUNREACH
if (ersatz && socketpair_result == -ENETUNREACH) {
/* We can also fail with -ENETUNREACH if we have no network stack at
* all. */
tt_skip();
}
+#endif
tt_int_op(0, OP_EQ, socketpair_result);
tt_assert(SOCKET_OK(fds[0]));