aboutsummaryrefslogtreecommitdiff
path: root/src/test/test_hs_intropoint.c
diff options
context:
space:
mode:
authorDavid Goulet <dgoulet@torproject.org>2019-06-27 14:06:42 -0400
committerDavid Goulet <dgoulet@torproject.org>2019-08-06 07:58:14 -0400
commit90b5422e8ee9dd7c7d04507291668e5870f2e351 (patch)
treef36a15f5cad6ebb550a5d74adfe5fa496d12e963 /src/test/test_hs_intropoint.c
parente53796854811724fdd1db5127bb67943ba5d423c (diff)
downloadtor-90b5422e8ee9dd7c7d04507291668e5870f2e351.tar.gz
tor-90b5422e8ee9dd7c7d04507291668e5870f2e351.zip
test: Series of fixes for hs_dos.c unit tests
Signed-off-by: David Goulet <dgoulet@torproject.org>
Diffstat (limited to 'src/test/test_hs_intropoint.c')
-rw-r--r--src/test/test_hs_intropoint.c63
1 files changed, 33 insertions, 30 deletions
diff --git a/src/test/test_hs_intropoint.c b/src/test/test_hs_intropoint.c
index 1d472397ca..7b01809f96 100644
--- a/src/test/test_hs_intropoint.c
+++ b/src/test/test_hs_intropoint.c
@@ -186,8 +186,6 @@ test_establish_intro_wrong_purpose(void *arg)
(void)arg;
- hs_dos_init();
-
/* Get the auth key of the intro point */
crypto_rand(circ_nonce, sizeof(circ_nonce));
memcpy(intro_circ->rend_circ_nonce, circ_nonce, DIGEST_LEN);
@@ -230,8 +228,6 @@ test_establish_intro_wrong_keytype(void *arg)
(void) arg;
- hs_dos_init();
-
/* Get the auth key of the intro point */
crypto_rand(circ_nonce, sizeof(circ_nonce));
helper_prepare_circ_for_intro(intro_circ, circ_nonce);
@@ -259,8 +255,6 @@ test_establish_intro_wrong_keytype2(void *arg)
(void) arg;
- hs_dos_init();
-
/* Get the auth key of the intro point */
crypto_rand(circ_nonce, sizeof(circ_nonce));
helper_prepare_circ_for_intro(intro_circ, circ_nonce);
@@ -297,8 +291,6 @@ test_establish_intro_wrong_mac(void *arg)
(void) arg;
- hs_dos_init();
-
/* Get the auth key of the intro point */
crypto_rand(circ_nonce, sizeof(circ_nonce));
helper_prepare_circ_for_intro(intro_circ, circ_nonce);
@@ -371,8 +363,6 @@ test_establish_intro_wrong_auth_key_len(void *arg)
(void) arg;
- hs_dos_init();
-
/* Get the auth key of the intro point */
crypto_rand(circ_nonce, sizeof(circ_nonce));
helper_prepare_circ_for_intro(intro_circ, circ_nonce);
@@ -418,8 +408,6 @@ test_establish_intro_wrong_sig_len(void *arg)
(void) arg;
- hs_dos_init();
-
/* Get the auth key of the intro point */
crypto_rand(circ_nonce, sizeof(circ_nonce));
helper_prepare_circ_for_intro(intro_circ, circ_nonce);
@@ -463,8 +451,6 @@ test_establish_intro_wrong_sig(void *arg)
(void) arg;
- hs_dos_init();
-
/* Get the auth key of the intro point */
crypto_rand(circ_nonce, sizeof(circ_nonce));
helper_prepare_circ_for_intro(intro_circ, circ_nonce);
@@ -502,8 +488,6 @@ helper_establish_intro_v3(or_circuit_t *intro_circ)
tt_assert(intro_circ);
- hs_dos_init();
-
/* Prepare the circuit for the incoming ESTABLISH_INTRO */
crypto_rand(circ_nonce, sizeof(circ_nonce));
helper_prepare_circ_for_intro(intro_circ, circ_nonce);
@@ -539,8 +523,6 @@ helper_establish_intro_v2(or_circuit_t *intro_circ)
tt_assert(intro_circ);
- hs_dos_init();
-
/* Prepare the circuit for the incoming ESTABLISH_INTRO */
crypto_rand(circ_nonce, sizeof(circ_nonce));
helper_prepare_circ_for_intro(intro_circ, circ_nonce);
@@ -921,42 +903,63 @@ test_received_introduce1_handling(void *arg)
UNMOCK(relay_send_command_from_edge_);
}
+static void *
+hs_subsystem_setup_fn(const struct testcase_t *tc)
+{
+ (void) tc;
+
+ return NULL;
+}
+
+static int
+hs_subsystem_cleanup_fn(const struct testcase_t *tc, void *arg)
+{
+ (void) tc;
+ (void) arg;
+
+ return 1;
+}
+
+static struct testcase_setup_t test_setup = {
+ hs_subsystem_setup_fn, hs_subsystem_cleanup_fn
+};
+
struct testcase_t hs_intropoint_tests[] = {
{ "intro_point_registration",
- test_intro_point_registration, TT_FORK, NULL, NULL },
+ test_intro_point_registration, TT_FORK, NULL, &test_setup},
{ "receive_establish_intro_wrong_keytype",
- test_establish_intro_wrong_keytype, TT_FORK, NULL, NULL },
+ test_establish_intro_wrong_keytype, TT_FORK, NULL, &test_setup},
{ "receive_establish_intro_wrong_keytype2",
- test_establish_intro_wrong_keytype2, TT_FORK, NULL, NULL },
+ test_establish_intro_wrong_keytype2, TT_FORK, NULL, &test_setup},
{ "receive_establish_intro_wrong_purpose",
- test_establish_intro_wrong_purpose, TT_FORK, NULL, NULL },
+ test_establish_intro_wrong_purpose, TT_FORK, NULL, &test_setup},
{ "receive_establish_intro_wrong_sig",
- test_establish_intro_wrong_sig, TT_FORK, NULL, NULL },
+ test_establish_intro_wrong_sig, TT_FORK, NULL, &test_setup},
{ "receive_establish_intro_wrong_sig_len",
- test_establish_intro_wrong_sig_len, TT_FORK, NULL, NULL },
+ test_establish_intro_wrong_sig_len, TT_FORK, NULL, &test_setup},
{ "receive_establish_intro_wrong_auth_key_len",
- test_establish_intro_wrong_auth_key_len, TT_FORK, NULL, NULL },
+ test_establish_intro_wrong_auth_key_len, TT_FORK, NULL, &test_setup},
{ "receive_establish_intro_wrong_mac",
- test_establish_intro_wrong_mac, TT_FORK, NULL, NULL },
+ test_establish_intro_wrong_mac, TT_FORK, NULL, &test_setup},
{ "introduce1_suitable_circuit",
- test_introduce1_suitable_circuit, TT_FORK, NULL, NULL },
+ test_introduce1_suitable_circuit, TT_FORK, NULL, &test_setup},
{ "introduce1_is_legacy",
- test_introduce1_is_legacy, TT_FORK, NULL, NULL },
+ test_introduce1_is_legacy, TT_FORK, NULL, &test_setup},
{ "introduce1_validation",
- test_introduce1_validation, TT_FORK, NULL, NULL },
+ test_introduce1_validation, TT_FORK, NULL, &test_setup},
{ "received_introduce1_handling",
- test_received_introduce1_handling, TT_FORK, NULL, NULL },
+ test_received_introduce1_handling, TT_FORK, NULL, &test_setup},
END_OF_TESTCASES
};