summaryrefslogtreecommitdiff
path: root/src/or/circuitbuild.c
diff options
context:
space:
mode:
authorGeorge Kadianakis <desnacked@riseup.net>2017-05-02 16:33:49 +0300
committerNick Mathewson <nickm@torproject.org>2017-07-07 11:12:26 -0400
commit43a73f6eb648632552a20dd17f5736550df75e10 (patch)
tree54cf869075bc916701c84c83dca3a3b99ead4d4f /src/or/circuitbuild.c
parent9ff5613a340f220a202d3f0332f091d812068881 (diff)
downloadtor-43a73f6eb648632552a20dd17f5736550df75e10.tar.gz
tor-43a73f6eb648632552a20dd17f5736550df75e10.zip
test: Crypto groundwork for e2e circuit unittests.
- Move some crypto structures so that they are visible by tests. - Introduce a func to count number of hops in cpath which will be used by the tests. - Mark a function as mockable.
Diffstat (limited to 'src/or/circuitbuild.c')
-rw-r--r--src/or/circuitbuild.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c
index ec7ca2c4ce..fdcf3e7a75 100644
--- a/src/or/circuitbuild.c
+++ b/src/or/circuitbuild.c
@@ -2338,6 +2338,30 @@ onion_append_to_cpath(crypt_path_t **head_ptr, crypt_path_t *new_hop)
}
}
+#ifdef TOR_UNIT_TESTS
+
+/** Unittest helper function: Count number of hops in cpath linked list. */
+unsigned int
+cpath_get_n_hops(crypt_path_t **head_ptr)
+{
+ unsigned int n_hops = 0;
+ crypt_path_t *tmp;
+
+ if (!*head_ptr) {
+ return 0;
+ }
+
+ tmp = *head_ptr;
+ if (tmp) {
+ n_hops++;
+ tmp = (*head_ptr)->next;
+ }
+
+ return n_hops;
+}
+
+#endif
+
/** A helper function used by onion_extend_cpath(). Use <b>purpose</b>
* and <b>state</b> and the cpath <b>head</b> (currently populated only
* to length <b>cur_len</b> to decide a suitable middle hop for a