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

[tor-commits] [tor] 04/07: Fix unit tests.



This is an automated email from the git hooks/post-receive script.

dgoulet pushed a commit to branch main
in repository tor.

commit 0c115779871e05586cc1aa1526d4cc65aced2b0a
Author: Mike Perry <mikeperry-git@xxxxxxxxxxxxxx>
AuthorDate: Wed May 10 21:56:52 2023 +0000

    Fix unit tests.
---
 src/core/or/conflux_pool.c   | 9 +++++++--
 src/core/or/conflux_pool.h   | 2 ++
 src/test/test_conflux_pool.c | 2 ++
 3 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/src/core/or/conflux_pool.c b/src/core/or/conflux_pool.c
index 02d511149c..b02b23f24d 100644
--- a/src/core/or/conflux_pool.c
+++ b/src/core/or/conflux_pool.c
@@ -130,6 +130,11 @@ get_linked_pool(bool is_client)
 }
 #endif
 
+/* For unit tests only: please treat these exactly as the defines in the
+ * code. */
+STATIC uint8_t DEFAULT_CLIENT_UX = CONFLUX_UX_HIGH_THROUGHPUT;
+STATIC uint8_t DEFAULT_EXIT_UX = CONFLUX_UX_MIN_LATENCY;
+
 /** Helper: Format at 8 bytes the nonce for logging. */
 static inline const char *
 fmt_nonce(const uint8_t *nonce)
@@ -1111,7 +1116,7 @@ conflux_launch_leg(const uint8_t *nonce)
   leg_t *leg = leg_new(TO_CIRCUIT(circ),
                        conflux_cell_new_link(nonce,
                                              last_seq_sent, last_seq_recv,
-                                             CONFLUX_UX_HIGH_THROUGHPUT));
+                                             DEFAULT_CLIENT_UX));
 
   /* Increase the retry count for this conflux object as in this nonce. */
   unlinked->cfx->num_leg_launch++;
@@ -1765,7 +1770,7 @@ conflux_process_link(circuit_t *circ, const cell_t *cell,
   /* Exits should always request min latency from clients */
   conflux_cell_link_t *linked = conflux_cell_new_link(nonce, last_seq_sent,
                                                       last_seq_recv,
-                                                      CONFLUX_UX_MIN_LATENCY);
+                                                      DEFAULT_EXIT_UX);
 
   conflux_cell_send_linked(linked, TO_OR_CIRCUIT(circ));
   tor_free(linked);
diff --git a/src/core/or/conflux_pool.h b/src/core/or/conflux_pool.h
index 547b4d3974..6bb858bb09 100644
--- a/src/core/or/conflux_pool.h
+++ b/src/core/or/conflux_pool.h
@@ -40,6 +40,8 @@ void conflux_process_linked_ack(circuit_t *circ);
 bool launch_new_set(int num_legs);
 digest256map_t *get_linked_pool(bool is_client);
 digest256map_t *get_unlinked_pool(bool is_client);
+extern uint8_t DEFAULT_CLIENT_UX;
+extern uint8_t DEFAULT_EXIT_UX;
 #endif /* defined(UNIT_TESTS) */
 
 #endif /* TOR_CONFLUX_POOL_H */
diff --git a/src/test/test_conflux_pool.c b/src/test/test_conflux_pool.c
index b8053b7c0a..3da85705b3 100644
--- a/src/test/test_conflux_pool.c
+++ b/src/test/test_conflux_pool.c
@@ -53,6 +53,7 @@
 #include "core/or/conflux_params.h"
 #include "core/or/conflux.h"
 #include "core/or/conflux_st.h"
+#include "trunnel/conflux.h"
 #include "lib/crypt_ops/crypto_rand.h"
 
 /* Start our monotime mocking at 1 second past whatever monotime_init()
@@ -1112,6 +1113,7 @@ test_conflux_switch(void *arg)
 {
    (void) arg;
   test_setup();
+  DEFAULT_EXIT_UX = CONFLUX_UX_HIGH_THROUGHPUT;
 
   launch_new_set(2);
 

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits