diff options
author | George Kadianakis <desnacked@riseup.net> | 2018-02-14 13:40:42 +0200 |
---|---|---|
committer | David Goulet <dgoulet@torproject.org> | 2018-03-27 12:43:39 -0400 |
commit | ab16f1e2a10ee1b95118ec266ba454697e9af012 (patch) | |
tree | 19d752188e2bd80bc3e55b8fad294d3d891cfc8f /src/or | |
parent | f29d158330a8c6bcc91b71a888db741766135aaf (diff) | |
download | tor-ab16f1e2a10ee1b95118ec266ba454697e9af012.tar.gz tor-ab16f1e2a10ee1b95118ec266ba454697e9af012.zip |
test: Add unittest for the OR connection failure cache
Signed-off-by: David Goulet <dgoulet@torproject.org>
Diffstat (limited to 'src/or')
-rw-r--r-- | src/or/connection_or.c | 5 | ||||
-rw-r--r-- | src/or/connection_or.h | 5 | ||||
-rw-r--r-- | src/or/nodelist.c | 4 | ||||
-rw-r--r-- | src/or/nodelist.h | 2 |
4 files changed, 11 insertions, 5 deletions
diff --git a/src/or/connection_or.c b/src/or/connection_or.c index 976889ad0a..267463312c 100644 --- a/src/or/connection_or.c +++ b/src/or/connection_or.c @@ -28,6 +28,7 @@ * part of a subclass (channel_tls_t). */ #define TOR_CHANNEL_INTERNAL_ +#define CONNECTION_OR_PRIVATE #include "channel.h" #include "channeltls.h" #include "circuitbuild.h" @@ -1255,7 +1256,7 @@ or_connect_failure_find(const or_connection_t *or_conn) /* Note down in the connection failure cache that a failure occurred on the * given or_conn. */ -static void +STATIC void note_or_connect_failed(const or_connection_t *or_conn) { or_connect_failure_entry_t *ocf = NULL; @@ -1294,7 +1295,7 @@ or_connect_failure_map_cleanup(time_t cutoff) * * The or_conn MUST have gone through connection_or_check_canonicity() so the * base address is properly set to what we know or doesn't know. */ -static int +STATIC int should_connect_to_relay(const or_connection_t *or_conn) { time_t now, cutoff; diff --git a/src/or/connection_or.h b/src/or/connection_or.h index 7c1dced631..158eb1fdad 100644 --- a/src/or/connection_or.h +++ b/src/or/connection_or.h @@ -120,6 +120,11 @@ int connection_or_single_set_badness_(time_t now, int force); void connection_or_group_set_badness_(smartlist_t *group, int force); +#ifdef CONNECTION_OR_PRIVATE +STATIC int should_connect_to_relay(const or_connection_t *or_conn); +STATIC void note_or_connect_failed(const or_connection_t *or_conn); +#endif + #ifdef TOR_UNIT_TESTS extern int certs_cell_ed25519_disabled_for_testing; #endif diff --git a/src/or/nodelist.c b/src/or/nodelist.c index 391b31d683..7303539c87 100644 --- a/src/or/nodelist.c +++ b/src/or/nodelist.c @@ -161,8 +161,8 @@ init_nodelist(void) } /** As node_get_by_id, but returns a non-const pointer */ -node_t * -node_get_mutable_by_id(const char *identity_digest) +MOCK_IMPL(node_t *, +node_get_mutable_by_id,(const char *identity_digest)) { node_t search, *node; if (PREDICT_UNLIKELY(the_nodelist == NULL)) diff --git a/src/or/nodelist.h b/src/or/nodelist.h index dc20eaf0a5..043d7b3414 100644 --- a/src/or/nodelist.h +++ b/src/or/nodelist.h @@ -16,7 +16,7 @@ tor_assert((n)->ri || (n)->rs); \ } STMT_END -node_t *node_get_mutable_by_id(const char *identity_digest); +MOCK_DECL(node_t *, node_get_mutable_by_id,(const char *identity_digest)); MOCK_DECL(const node_t *, node_get_by_id, (const char *identity_digest)); node_t *node_get_mutable_by_ed25519_id(const ed25519_public_key_t *ed_id); MOCK_DECL(const node_t *, node_get_by_ed25519_id, |