]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Fix a failing unit test.
authorNick Mathewson <nickm@torproject.org>
Wed, 31 Jan 2018 19:06:37 +0000 (14:06 -0500)
committerNick Mathewson <nickm@torproject.org>
Wed, 31 Jan 2018 19:06:37 +0000 (14:06 -0500)
When we stopped looking at the "protocols" variable directly, we
broke the hs_service/build_update_descriptors test, since it didn't
actually update any of the flags.

The fix here is to call summarize_protover_flags() from that test,
and to expose summarize_protover_flags() as "STATIC" from
routerparse.c.

src/or/routerparse.c
src/or/routerparse.h
src/test/test_hs_service.c

index fc071b11d37bf6f3eaf120228a249d2e67b55e4a..1b79a6fe248276a937d246877ab19ad0e7f60aab 100644 (file)
@@ -379,10 +379,6 @@ static int check_signature_token(const char *digest,
                                  int flags,
                                  const char *doctype);
 
-static void summarize_protover_flags(protover_summary_flags_t *out,
-                                     const char *protocols,
-                                     const char *version);
-
 #undef DEBUG_AREA_ALLOC
 
 #ifdef DEBUG_AREA_ALLOC
@@ -2544,7 +2540,7 @@ routerstatus_parse_guardfraction(const char *guardfraction_str,
 /** Summarize the protocols listed in <b>protocols</b> into <b>out</b>,
  * falling back or correcting them based on <b>version</b> as appropriate.
  */
-static void
+STATIC void
 summarize_protover_flags(protover_summary_flags_t *out,
                          const char *protocols,
                          const char *version)
index c4c8635f4bfac448213a9fe399b52220a613df8f..418fd3acdba497a25f5fe86d4033721eed55cf28 100644 (file)
@@ -133,6 +133,10 @@ MOCK_DECL(STATIC int, router_compute_hash_final,(char *digest,
                            digest_algorithm_t alg));
 MOCK_DECL(STATIC int, signed_digest_equals,
           (const uint8_t *d1, const uint8_t *d2, size_t len));
+
+STATIC void summarize_protover_flags(protover_summary_flags_t *out,
+                                     const char *protocols,
+                                     const char *version);
 #endif /* defined(ROUTERPARSE_PRIVATE) */
 
 #define ED_DESC_SIGNATURE_PREFIX "Tor router descriptor signature v1"
index 3e3a7d8e0d630fc25d4d9246d0f846a68dc14ce4..fad65e61f7ecf38055ca2afd6212ce1876382e8d 100644 (file)
@@ -20,6 +20,7 @@
 #define STATEFILE_PRIVATE
 #define TOR_CHANNEL_INTERNAL_
 #define HS_CLIENT_PRIVATE
+#define ROUTERPARSE_PRIVATE
 
 #include "test.h"
 #include "test_helpers.h"
@@ -37,6 +38,7 @@
 #include "networkstatus.h"
 #include "nodelist.h"
 #include "relay.h"
+#include "routerparse.h"
 
 #include "hs_common.h"
 #include "hs_config.h"
@@ -1210,6 +1212,7 @@ test_build_update_descriptors(void *arg)
     /* Ugly yes but we never free the "ri" object so this just makes things
      * easier. */
     ri.protocol_list = (char *) "HSDir=1-2 LinkAuth=3";
+    summarize_protover_flags(&ri.pv, ri.protocol_list, NULL);
     ret = curve25519_secret_key_generate(&curve25519_secret_key, 0);
     tt_int_op(ret, OP_EQ, 0);
     ri.onion_curve25519_pkey =