[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor/master] test: Unbreak test_upload_descriptors()



commit ec0da9a6f150c3e96a5aa777dea38105350a2b53
Author: George Kadianakis <desnacked@xxxxxxxxxx>
Date:   Mon Jul 24 13:17:59 2017 +0300

    test: Unbreak test_upload_descriptors()
    
    To upload the descriptor we needed a state file to write the rev counters in,
    but that test did not have a state file initialized.
    
    Also fix the typo in its func name.
    
    Signed-off-by: David Goulet <dgoulet@xxxxxxxxxxxxxx>
---
 src/test/test_hs_service.c | 29 +++++++++++++++++++++++++++--
 1 file changed, 27 insertions(+), 2 deletions(-)

diff --git a/src/test/test_hs_service.c b/src/test/test_hs_service.c
index 664277b19..6d5ea7ed7 100644
--- a/src/test/test_hs_service.c
+++ b/src/test/test_hs_service.c
@@ -16,6 +16,7 @@
 #define HS_INTROPOINT_PRIVATE
 #define MAIN_PRIVATE
 #define NETWORKSTATUS_PRIVATE
+#define STATEFILE_PRIVATE
 #define TOR_CHANNEL_INTERNAL_
 
 #include "test.h"
@@ -43,6 +44,7 @@
 #include "hs_service.h"
 #include "main.h"
 #include "rendservice.h"
+#include "statefile.h"
 
 /* Trunnel */
 #include "hs/cell_establish_intro.h"
@@ -56,6 +58,15 @@ mock_networkstatus_get_live_consensus(time_t now)
   return &mock_ns;
 }
 
+static or_state_t *dummy_state = NULL;
+
+/* Mock function to get fake or state (used for rev counters) */
+static or_state_t *
+get_or_state_replacement(void)
+{
+  return dummy_state;
+}
+
 /* Mock function because we are not trying to test the close circuit that does
  * an awful lot of checks on the circuit object. */
 static void
@@ -779,6 +790,10 @@ test_introduce2(void *arg)
 
   hs_init();
   MOCK(circuit_mark_for_close_, mock_circuit_mark_for_close);
+  MOCK(get_or_state,
+       get_or_state_replacement);
+
+  dummy_state = tor_malloc_zero(sizeof(or_state_t));
 
   circ = helper_create_origin_circuit(CIRCUIT_PURPOSE_S_INTRO, flags);
 
@@ -830,6 +845,8 @@ test_introduce2(void *arg)
   tt_u64_op(ip->introduce2_count, OP_EQ, 0);
 
  done:
+  or_state_free(dummy_state);
+  dummy_state = NULL;
   circuit_free(TO_CIRCUIT(circ));
   hs_free_all();
   UNMOCK(circuit_mark_for_close_);
@@ -1011,6 +1028,10 @@ test_build_update_descriptors(void *arg)
 
   hs_init();
   MOCK(hs_overlap_mode_is_active, mock_hs_overlap_mode_is_active_true);
+  MOCK(get_or_state,
+       get_or_state_replacement);
+
+  dummy_state = tor_malloc_zero(sizeof(or_state_t));
 
   /* Create a service without a current descriptor to trigger a build. */
   service = hs_service_new(get_options());
@@ -1133,7 +1154,7 @@ test_build_update_descriptors(void *arg)
 }
 
 static void
-test_upload_desctriptors(void *arg)
+test_upload_descriptors(void *arg)
 {
   int ret;
   time_t now = time(NULL);
@@ -1144,6 +1165,10 @@ test_upload_desctriptors(void *arg)
 
   hs_init();
   MOCK(hs_overlap_mode_is_active, mock_hs_overlap_mode_is_active_true);
+  MOCK(get_or_state,
+       get_or_state_replacement);
+
+  dummy_state = tor_malloc_zero(sizeof(or_state_t));
 
   /* Create a service with no descriptor. It's added to the global map. */
   service = hs_service_new(get_options());
@@ -1278,7 +1303,7 @@ struct testcase_t hs_service_tests[] = {
     NULL, NULL },
   { "build_update_descriptors", test_build_update_descriptors, TT_FORK,
     NULL, NULL },
-  { "upload_desctriptors", test_upload_desctriptors, TT_FORK,
+  { "upload_descriptors", test_upload_descriptors, TT_FORK,
     NULL, NULL },
   { "revision_counter_state", test_revision_counter_state, TT_FORK,
     NULL, NULL },



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits