]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
test: New test for ntorv3 subproto ext
authorDavid Goulet <dgoulet@torproject.org>
Tue, 23 Jan 2024 15:08:47 +0000 (10:08 -0500)
committerDavid Goulet <dgoulet@torproject.org>
Wed, 31 Jan 2024 15:15:07 +0000 (10:15 -0500)
Signed-off-by: David Goulet <dgoulet@torproject.org>
src/test/test_ntor_v3.c

index 0d51c684a0f10fc372af06ac9f17297ab5c406f2..0eefe9e69ea82e466cc3482b83b80ada2bfd2b7d 100644 (file)
@@ -13,6 +13,7 @@
 #include "core/crypto/onion_crypto.h"
 #include "core/or/extend_info_st.h"
 #include "core/or/crypt_path_st.h"
+#include "core/or/protover.h"
 #define TOR_CONGESTION_CONTROL_PRIVATE
 #define TOR_CONGESTION_CONTROL_COMMON_PRIVATE
 #include "core/or/congestion_control_st.h"
@@ -192,7 +193,11 @@ run_full_handshake(circuit_params_t *serv_params_in,
   uint8_t client_keys[CELL_PAYLOAD_SIZE];
   uint8_t rend_auth[DIGEST_LEN];
 
-  info.exit_supports_congestion_control = 1;
+  if (serv_params_in->subproto.flow_ctrl != 0) {
+    info.supports_ntorv3_subproto_req = 1;
+  } else {
+    info.exit_supports_congestion_control = 1;
+  }
 
   unhex(relay_onion_key.seckey.secret_key,
         "4051daa5921cfa2a1c27b08451324919538e79e788a81b38cbed097a5dff454a");
@@ -303,6 +308,19 @@ test_ntor3_handshake(void *arg)
   tt_int_op(client_params.sendme_inc_cells, OP_NE,
             congestion_control_sendme_inc());
 
+  /* client on, serv on, sendme_inc -> serv sendme_inc. Using subproto
+   * extension. */
+  serv_ns_params.subproto.flow_ctrl = PROTOVER_FLOWCTRL_CC;
+  serv_ns_params.cc_enabled = 1;
+  serv_ns_params.sendme_inc_cells = congestion_control_sendme_inc();
+  run_full_handshake(&serv_ns_params, &client_params, &serv_params);
+  tt_int_op(client_params.cc_enabled, OP_EQ, 1);
+  tt_int_op(serv_params.cc_enabled, OP_EQ, 1);
+  tt_int_op(serv_params.sendme_inc_cells, OP_EQ,
+            client_params.sendme_inc_cells);
+  tt_int_op(client_params.sendme_inc_cells, OP_EQ,
+            serv_ns_params.sendme_inc_cells);
+
  done:
   return;
 }