|
@@ -8,6 +8,9 @@
|
|
|
|
|
|
#include "protover.h"
|
|
|
|
|
|
+#include "or.h"
|
|
|
+#include "connection_or.h"
|
|
|
+
|
|
|
static void
|
|
|
test_protover_parse(void *arg)
|
|
|
{
|
|
@@ -250,6 +253,154 @@ test_protover_supports_version(void *arg)
|
|
|
;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+#define MAX_PROTOCOLS_TO_TEST 1024
|
|
|
+
|
|
|
+
|
|
|
+ * Hard-coded here, because they are not in the code, or not exposed in the
|
|
|
+ * headers. */
|
|
|
+#define PROTOVER_LINKAUTH_V1 1
|
|
|
+#define PROTOVER_LINKAUTH_V3 3
|
|
|
+
|
|
|
+#define PROTOVER_RELAY_V1 1
|
|
|
+#define PROTOVER_RELAY_V2 2
|
|
|
+
|
|
|
+
|
|
|
+ * Hard-coded here, because it does not appear anywhere in the code.
|
|
|
+ * It's not clear if we actually support version 2, see #25068. */
|
|
|
+#define PROTOVER_HSINTRO_V2 3
|
|
|
+
|
|
|
+
|
|
|
+ * Hard-coded here, because they do not appear anywhere in the code. */
|
|
|
+#define PROTOVER_HS_RENDEZVOUS_POINT_V2 1
|
|
|
+#define PROTOVER_HSDIR_V2 1
|
|
|
+
|
|
|
+
|
|
|
+ * Hard-coded here, because they do not appear anywhere in the code. */
|
|
|
+#define PROTOVER_DIRCACHE_V1 1
|
|
|
+#define PROTOVER_DIRCACHE_V2 2
|
|
|
+
|
|
|
+#define PROTOVER_DESC_V1 1
|
|
|
+#define PROTOVER_DESC_V2 2
|
|
|
+
|
|
|
+#define PROTOVER_MICRODESC_V1 1
|
|
|
+#define PROTOVER_MICRODESC_V2 2
|
|
|
+
|
|
|
+#define PROTOVER_CONS_V1 1
|
|
|
+#define PROTOVER_CONS_V2 2
|
|
|
+
|
|
|
+
|
|
|
+static void
|
|
|
+test_protover_supported_protocols(void *arg)
|
|
|
+{
|
|
|
+ (void)arg;
|
|
|
+
|
|
|
+ const char *supported_protocols = protover_get_supported_protocols();
|
|
|
+
|
|
|
+
|
|
|
+ * protocols */
|
|
|
+ tt_assert(protocol_list_supports_protocol(supported_protocols,
|
|
|
+ PRT_LINK,
|
|
|
+ MAX_LINK_PROTO));
|
|
|
+ for (uint16_t i = 0; i < MAX_PROTOCOLS_TO_TEST; i++) {
|
|
|
+ if (is_or_protocol_version_known(i)) {
|
|
|
+ tt_assert(protocol_list_supports_protocol(supported_protocols,
|
|
|
+ PRT_LINK,
|
|
|
+ i));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ tt_assert(protocol_list_supports_protocol(supported_protocols,
|
|
|
+ PRT_LINKAUTH,
|
|
|
+ PROTOVER_LINKAUTH_V1));
|
|
|
+
|
|
|
+ tt_assert(protocol_list_supports_protocol(supported_protocols,
|
|
|
+ PRT_LINKAUTH,
|
|
|
+ PROTOVER_LINKAUTH_V3));
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ tt_assert(protocol_list_supports_protocol(supported_protocols,
|
|
|
+ PRT_RELAY,
|
|
|
+ PROTOVER_RELAY_V1));
|
|
|
+ tt_assert(protocol_list_supports_protocol(supported_protocols,
|
|
|
+ PRT_RELAY,
|
|
|
+ PROTOVER_RELAY_V2));
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ * and checking the protocols field. But that's unlikely to change, so
|
|
|
+ * we just use a hard-coded value. */
|
|
|
+ tt_assert(protocol_list_supports_protocol(supported_protocols,
|
|
|
+ PRT_HSINTRO,
|
|
|
+ PROTOVER_HSINTRO_V2));
|
|
|
+
|
|
|
+ tt_assert(protocol_list_supports_protocol(supported_protocols,
|
|
|
+ PRT_HSINTRO,
|
|
|
+ PROTOVER_HS_INTRO_V3));
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ tt_assert(protocol_list_supports_protocol(supported_protocols,
|
|
|
+ PRT_HSREND,
|
|
|
+ PROTOVER_HS_RENDEZVOUS_POINT_V2));
|
|
|
+
|
|
|
+ tt_assert(protocol_list_supports_protocol(supported_protocols,
|
|
|
+ PRT_HSREND,
|
|
|
+ PROTOVER_HS_RENDEZVOUS_POINT_V3));
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ tt_assert(protocol_list_supports_protocol(supported_protocols,
|
|
|
+ PRT_HSDIR,
|
|
|
+ PROTOVER_HSDIR_V2));
|
|
|
+
|
|
|
+ tt_assert(protocol_list_supports_protocol(supported_protocols,
|
|
|
+ PRT_HSDIR,
|
|
|
+ PROTOVER_HSDIR_V3));
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ tt_assert(protocol_list_supports_protocol(supported_protocols,
|
|
|
+ PRT_DIRCACHE,
|
|
|
+ PROTOVER_DIRCACHE_V1));
|
|
|
+ tt_assert(protocol_list_supports_protocol(supported_protocols,
|
|
|
+ PRT_DIRCACHE,
|
|
|
+ PROTOVER_DIRCACHE_V2));
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ tt_assert(protocol_list_supports_protocol(supported_protocols,
|
|
|
+ PRT_DESC,
|
|
|
+ PROTOVER_DESC_V1));
|
|
|
+ tt_assert(protocol_list_supports_protocol(supported_protocols,
|
|
|
+ PRT_DESC,
|
|
|
+ PROTOVER_DESC_V2));
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ tt_assert(protocol_list_supports_protocol(supported_protocols,
|
|
|
+ PRT_MICRODESC,
|
|
|
+ PROTOVER_MICRODESC_V1));
|
|
|
+ tt_assert(protocol_list_supports_protocol(supported_protocols,
|
|
|
+ PRT_MICRODESC,
|
|
|
+ PROTOVER_MICRODESC_V2));
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ tt_assert(protocol_list_supports_protocol(supported_protocols,
|
|
|
+ PRT_CONS,
|
|
|
+ PROTOVER_CONS_V1));
|
|
|
+ tt_assert(protocol_list_supports_protocol(supported_protocols,
|
|
|
+ PRT_CONS,
|
|
|
+ PROTOVER_CONS_V2));
|
|
|
+
|
|
|
+
|
|
|
+ done:
|
|
|
+ ;
|
|
|
+}
|
|
|
+
|
|
|
#define PV_TEST(name, flags) \
|
|
|
{ #name, test_protover_ ##name, (flags), NULL, NULL }
|
|
|
|
|
@@ -261,6 +412,7 @@ struct testcase_t protover_tests[] = {
|
|
|
PV_TEST(list_supports_protocol_for_unsupported_returns_false, 0),
|
|
|
PV_TEST(list_supports_protocol_returns_true, 0),
|
|
|
PV_TEST(supports_version, 0),
|
|
|
+ PV_TEST(supported_protocols, 0),
|
|
|
END_OF_TESTCASES
|
|
|
};
|
|
|
|