]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Bug 40709: Update and clean up tests for consensus params
authorMike Perry <mikeperry-git@torproject.org>
Tue, 20 Jun 2023 23:25:27 +0000 (23:25 +0000)
committerMike Perry <mikeperry-git@torproject.org>
Fri, 23 Jun 2023 15:08:54 +0000 (15:08 +0000)
src/core/or/congestion_control_common.c
src/core/or/congestion_control_common.h
src/test/test_conflux_pool.c
src/test/test_hs_client.c
src/test/test_hs_descriptor.c
src/test/test_ntor_v3.c

index ece93a33704b5306a6ff685493ee4c31fe8aaaa7..6ef29ba63722b2798f8310986763befe459f0ff7 100644 (file)
@@ -90,9 +90,6 @@ static bool congestion_control_update_circuit_bdp(congestion_control_t *,
                                                   const circuit_t *,
                                                   const crypt_path_t *,
                                                   uint64_t, uint64_t);
-/* For unit tests */
-void congestion_control_set_cc_enabled(void);
-
 /* Number of times the RTT value was reset. For MetricsPort. */
 static uint64_t num_rtt_reset;
 
@@ -387,6 +384,7 @@ congestion_control_enabled(void)
   return cc_alg != CC_ALG_SENDME;
 }
 
+#ifdef TOR_UNIT_TESTS
 /**
  * For unit tests only: set the cached consensus cc alg to
  * specified value.
@@ -397,6 +395,17 @@ congestion_control_set_cc_enabled(void)
   cc_alg = CC_ALG_VEGAS;
 }
 
+/**
+ * For unit tests only: set the cached consensus cc alg to
+ * specified value.
+ */
+void
+congestion_control_set_cc_disabled(void)
+{
+  cc_alg = CC_ALG_SENDME;
+}
+#endif
+
 /**
  * Allocate and initialize fields in congestion control object.
  *
index cf3e9d4fdb368e7bedc51e2f8af7c1f19802672d..767e4c52e6b21f11816d31e15d3ca66b27cd58f1 100644 (file)
@@ -174,7 +174,7 @@ percent_max_mix(uint64_t a, uint64_t b, uint8_t pct_max)
 }
 
 /* Private section starts. */
-#ifdef TOR_CONGESTION_CONTROL_PRIVATE
+#ifdef TOR_CONGESTION_CONTROL_COMMON_PRIVATE
 
 /*
  * Unit tests declaractions.
@@ -182,6 +182,7 @@ percent_max_mix(uint64_t a, uint64_t b, uint8_t pct_max)
 #ifdef TOR_UNIT_TESTS
 
 void congestion_control_set_cc_enabled(void);
+void congestion_control_set_cc_disabled(void);
 
 #endif /* defined(TOR_UNIT_TESTS) */
 
index 3da85705b343f2b191869d060f9694a1db74b3eb..ad78283fe3f6de45f15f783205d649bd9ac6fa16 100644 (file)
@@ -6,6 +6,7 @@
 #define CRYPT_PATH_PRIVATE
 #define RELAY_PRIVATE
 #define CONNECTION_PRIVATE
+#define TOR_CONGESTION_CONTROL_COMMON_PRIVATE
 #define TOR_CONGESTION_CONTROL_PRIVATE
 
 #include "core/or/or.h"
@@ -25,8 +26,8 @@
 #include "core/or/circuitstats.h"
 #include "core/or/circuitbuild.h"
 #include "core/or/circuituse.h"
-#include "core/or/congestion_control_common.h"
 #include "core/or/congestion_control_st.h"
+#include "core/or/congestion_control_common.h"
 #include "core/or/extendinfo.h"
 #include "core/mainloop/netstatus.h"
 #include "core/crypto/relay_crypto.h"
index f873d90212e6dc361646d840101e5522f80e94b8..be74da1198d6556e51a3c5f7c71f7e3c906326d2 100644 (file)
@@ -15,6 +15,7 @@
 #define CIRCUITLIST_PRIVATE
 #define CONNECTION_PRIVATE
 #define CRYPT_PATH_PRIVATE
+#define TOR_CONGESTION_CONTROL_COMMON_PRIVATE
 
 #include "test/test.h"
 #include "test/test_helpers.h"
@@ -54,7 +55,6 @@
 #include "core/or/origin_circuit_st.h"
 #include "core/or/socks_request_st.h"
 
-#define TOR_CONGESTION_CONTROL_PRIVATE
 #include "core/or/congestion_control_common.h"
 
 static int
index fe9bc24fb23c8dcb12fa4d024c1be303e0d76812..3b715863ada4215e620ae1d55121c87ac80660f8 100644 (file)
@@ -7,6 +7,7 @@
  */
 
 #define HS_DESCRIPTOR_PRIVATE
+#define TOR_CONGESTION_CONTROL_COMMON_PRIVATE
 
 #include "lib/crypt_ops/crypto_ed25519.h"
 #include "lib/crypt_ops/crypto_format.h"
@@ -24,7 +25,6 @@
 #include "test/log_test_helpers.h"
 #include "test/rng_test_helpers.h"
 
-#define TOR_CONGESTION_CONTROL_PRIVATE
 #include "core/or/congestion_control_common.h"
 
 #ifdef HAVE_CFLAG_WOVERLENGTH_STRINGS
index 1d06403076237a05a1ef0eaab40059f61cb32af6..c4a7d04deb30f17690c00ee4ed31a03d3683a976 100644 (file)
@@ -13,7 +13,7 @@
 #include "core/crypto/onion_crypto.h"
 #include "core/or/extend_info_st.h"
 #include "core/or/crypt_path_st.h"
-#define TOR_CONGESTION_CONTROL_PRIVATE
+#define TOR_CONGESTION_CONTROL_COMMON_PRIVATE
 #include "core/or/congestion_control_common.h"
 #include "app/config/config.h"
 
@@ -262,6 +262,7 @@ test_ntor3_handshake(void *arg)
   tt_int_op(serv_params.cc_enabled, OP_EQ, 0);
 
   /* client off, serv on -> off */
+  congestion_control_set_cc_disabled();
   serv_ns_params.cc_enabled = 1;
   run_full_handshake(&serv_ns_params, &client_params, &serv_params);
   tt_int_op(client_params.cc_enabled, OP_EQ, 0);