hs: Fix tests for congestion control

This commit is contained in:
David Goulet 2022-02-03 12:11:42 +00:00 committed by Mike Perry
parent 6f45ad3771
commit 27d948dab8
3 changed files with 9 additions and 17 deletions

View File

@ -54,6 +54,9 @@
#include "core/or/origin_circuit_st.h" #include "core/or/origin_circuit_st.h"
#include "core/or/socks_request_st.h" #include "core/or/socks_request_st.h"
#define TOR_CONGESTION_CONTROL_PRIVATE
#include "core/or/congestion_control_common.h"
static int static int
mock_connection_ap_handshake_send_begin(entry_connection_t *ap_conn) mock_connection_ap_handshake_send_begin(entry_connection_t *ap_conn)
{ {
@ -771,6 +774,7 @@ test_desc_has_arrived_cleanup(void *arg)
(void) arg; (void) arg;
hs_init(); hs_init();
congestion_control_set_cc_enabled();
MOCK(networkstatus_get_reasonably_live_consensus, MOCK(networkstatus_get_reasonably_live_consensus,
mock_networkstatus_get_reasonably_live_consensus); mock_networkstatus_get_reasonably_live_consensus);

View File

@ -24,6 +24,9 @@
#include "test/log_test_helpers.h" #include "test/log_test_helpers.h"
#include "test/rng_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 #ifdef HAVE_CFLAG_WOVERLENGTH_STRINGS
DISABLE_GCC_WARNING("-Woverlength-strings") DISABLE_GCC_WARNING("-Woverlength-strings")
/* We allow huge string constants in the unit tests, but not in the code /* We allow huge string constants in the unit tests, but not in the code
@ -247,6 +250,8 @@ test_decode_descriptor(void *arg)
(void) arg; (void) arg;
congestion_control_set_cc_enabled();
ret = ed25519_keypair_generate(&signing_kp, 0); ret = ed25519_keypair_generate(&signing_kp, 0);
tt_int_op(ret, OP_EQ, 0); tt_int_op(ret, OP_EQ, 0);
desc = hs_helper_build_hs_desc_with_ip(&signing_kp); desc = hs_helper_build_hs_desc_with_ip(&signing_kp);

View File

@ -355,7 +355,6 @@ test_protover_supports_version(void *arg)
#define PROTOVER_PADDING_V1 1 #define PROTOVER_PADDING_V1 1
#define PROTOVER_FLOWCTRL_V1 1 #define PROTOVER_FLOWCTRL_V1 1
#define PROTOVER_FLOWCTRL_V2 2
#define PROTOVER_RELAY_NTOR_V3 4 #define PROTOVER_RELAY_NTOR_V3 4
@ -704,22 +703,6 @@ test_protover_summarize_flags(void *args)
/* Now check version exceptions */ /* Now check version exceptions */
/* Congestion control. */
memset(&flags, 0, sizeof(flags));
summarize_protover_flags(&flags,
PROTOVER("FlowCtrl", PROTOVER_FLOWCTRL_V2),
NULL);
summarize_protover_flags(&flags,
PROTOVER("Relay", PROTOVER_RELAY_NTOR_V3),
NULL);
DEBUG_PROTOVER(flags);
tt_int_op(flags.protocols_known, OP_EQ, 1);
tt_int_op(flags.supports_congestion_control, OP_EQ, 1);
/* Now clear those flags, and check the rest are zero */
flags.protocols_known = 0;
flags.supports_congestion_control = 0;
tt_mem_op(&flags, OP_EQ, &zero_flags, sizeof(flags));
/* EXTEND2 cell support */ /* EXTEND2 cell support */
memset(&flags, 0, sizeof(flags)); memset(&flags, 0, sizeof(flags));
summarize_protover_flags(&flags, NULL, "Tor 0.2.4.8-alpha"); summarize_protover_flags(&flags, NULL, "Tor 0.2.4.8-alpha");