summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorDavid Goulet <dgoulet@torproject.org>2022-02-03 20:06:36 +0000
committerMike Perry <mikeperry-git@torproject.org>2022-02-22 19:28:34 +0000
commit89f5eeefb83231c6eb7b8a857b173a9f962f3c0d (patch)
tree2095691800547cf08dec4aa2e6cd8e7a3bfda1e5 /src/test
parent95639f35aede81bfde8bd4ee1616e10048176cc7 (diff)
downloadtor-89f5eeefb83231c6eb7b8a857b173a9f962f3c0d.tar.gz
tor-89f5eeefb83231c6eb7b8a857b173a9f962f3c0d.zip
hs: Decode flow-control line
This puts the flow control version (unparsed) in the descriptor. The client doesn't use it yet. Signed-off-by: David Goulet <dgoulet@torproject.org>
Diffstat (limited to 'src/test')
-rw-r--r--src/test/hs_test_helpers.c6
-rw-r--r--src/test/test_protover.c25
2 files changed, 29 insertions, 2 deletions
diff --git a/src/test/hs_test_helpers.c b/src/test/hs_test_helpers.c
index 2af4f71d72..20b225ba4a 100644
--- a/src/test/hs_test_helpers.c
+++ b/src/test/hs_test_helpers.c
@@ -4,6 +4,7 @@
#define HS_CLIENT_PRIVATE
#include "core/or/or.h"
+#include "core/or/versions.h"
#include "lib/crypt_ops/crypto_ed25519.h"
#include "test/test.h"
#include "feature/nodelist/torcert.h"
@@ -186,6 +187,7 @@ hs_helper_build_hs_desc_impl(unsigned int no_ip,
desc->encrypted_data.create2_ntor = 1;
desc->encrypted_data.intro_auth_types = smartlist_new();
desc->encrypted_data.single_onion_service = 1;
+ desc->encrypted_data.flow_control_pv = tor_strdup("FlowCtrl=1-2");
smartlist_add(desc->encrypted_data.intro_auth_types, tor_strdup("ed25519"));
desc->encrypted_data.intro_points = smartlist_new();
if (!no_ip) {
@@ -332,6 +334,10 @@ hs_helper_desc_equal(const hs_descriptor_t *desc1,
/* Encrypted data section. */
tt_uint_op(desc1->encrypted_data.create2_ntor, OP_EQ,
desc2->encrypted_data.create2_ntor);
+ tt_uint_op(desc1->encrypted_data.single_onion_service, OP_EQ,
+ desc2->encrypted_data.single_onion_service);
+ tt_str_op(desc1->encrypted_data.flow_control_pv, OP_EQ,
+ desc2->encrypted_data.flow_control_pv);
/* Authentication type. */
tt_int_op(!!desc1->encrypted_data.intro_auth_types, OP_EQ,
diff --git a/src/test/test_protover.c b/src/test/test_protover.c
index ae40556220..7ad02cb9c1 100644
--- a/src/test/test_protover.c
+++ b/src/test/test_protover.c
@@ -355,6 +355,9 @@ test_protover_supports_version(void *arg)
#define PROTOVER_PADDING_V1 1
#define PROTOVER_FLOWCTRL_V1 1
+#define PROTOVER_FLOWCTRL_V2 2
+
+#define PROTOVER_RELAY_NTOR_V3 4
/* Make sure we haven't forgotten any supported protocols */
static void
@@ -644,7 +647,8 @@ test_protover_vote_roundtrip_ours(void *args)
"supports_establish_intro_dos_extension: %d,\n" \
"supports_v3_hsdir: %d,\n" \
"supports_v3_rendezvous_point: %d,\n" \
- "supports_hs_setup_padding: %d.", \
+ "supports_hs_setup_padding: %d,\n" \
+ "supports_congestion_control: %d.", \
(flags).protocols_known, \
(flags).supports_extend2_cells, \
(flags).supports_accepting_ipv6_extends, \
@@ -656,7 +660,8 @@ test_protover_vote_roundtrip_ours(void *args)
(flags).supports_establish_intro_dos_extension, \
(flags).supports_v3_hsdir, \
(flags).supports_v3_rendezvous_point, \
- (flags).supports_hs_setup_padding); \
+ (flags).supports_hs_setup_padding, \
+ (flags).supports_congestion_control); \
STMT_END
/* Test that the proto_string version version_macro sets summary_flag. */
@@ -699,6 +704,22 @@ test_protover_summarize_flags(void *args)
/* 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 */
memset(&flags, 0, sizeof(flags));
summarize_protover_flags(&flags, NULL, "Tor 0.2.4.8-alpha");