diff options
author | Nick Mathewson <nickm@torproject.org> | 2014-10-07 09:20:44 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2014-10-13 14:30:02 -0400 |
commit | 3efeb711f104b58b1f8a46c56c56246f0049e3e1 (patch) | |
tree | ba013ba65ad56ab8b19f1d1e3755703a9ec064f4 /src/or | |
parent | 24dfbfda1db41d0e9feb5def09e1b7ede350de40 (diff) | |
download | tor-3efeb711f104b58b1f8a46c56c56246f0049e3e1.tar.gz tor-3efeb711f104b58b1f8a46c56c56246f0049e3e1.zip |
Unit tests for 11243: loading ri, ei, mds from lists
These tests make sure that entries are actually marked
undownloadable as appropriate.
Diffstat (limited to 'src/or')
-rw-r--r-- | src/or/networkstatus.c | 14 | ||||
-rw-r--r-- | src/or/networkstatus.h | 17 | ||||
-rw-r--r-- | src/or/routerlist.c | 8 | ||||
-rw-r--r-- | src/or/routerlist.h | 5 |
4 files changed, 26 insertions, 18 deletions
diff --git a/src/or/networkstatus.c b/src/or/networkstatus.c index e61d1b436d..9c49d3431c 100644 --- a/src/or/networkstatus.c +++ b/src/or/networkstatus.c @@ -595,10 +595,10 @@ networkstatus_vote_find_entry_idx(networkstatus_t *ns, /** As router_get_consensus_status_by_descriptor_digest, but does not return * a const pointer. */ -routerstatus_t * -router_get_mutable_consensus_status_by_descriptor_digest( +MOCK_IMPL(routerstatus_t *, +router_get_mutable_consensus_status_by_descriptor_digest,( networkstatus_t *consensus, - const char *digest) + const char *digest)) { if (!consensus) consensus = current_consensus; @@ -628,8 +628,8 @@ router_get_consensus_status_by_descriptor_digest(networkstatus_t *consensus, /** Given the digest of a router descriptor, return its current download * status, or NULL if the digest is unrecognized. */ -download_status_t * -router_get_dl_status_by_descriptor_digest(const char *d) +MOCK_IMPL(download_status_t *, +router_get_dl_status_by_descriptor_digest,(const char *d)) { routerstatus_t *rs; if (!current_ns_consensus) @@ -995,8 +995,8 @@ networkstatus_get_latest_consensus(void) /** Return the latest consensus we have whose flavor matches <b>f</b>, or NULL * if we don't have one. */ -networkstatus_t * -networkstatus_get_latest_consensus_by_flavor(consensus_flavor_t f) +MOCK_IMPL(networkstatus_t *, +networkstatus_get_latest_consensus_by_flavor,(consensus_flavor_t f)) { if (f == FLAV_NS) return current_ns_consensus; diff --git a/src/or/networkstatus.h b/src/or/networkstatus.h index be0a86cdd8..344e4de72e 100644 --- a/src/or/networkstatus.h +++ b/src/or/networkstatus.h @@ -12,6 +12,8 @@ #ifndef TOR_NETWORKSTATUS_H #define TOR_NETWORKSTATUS_H +#include "testsupport.h" + void networkstatus_reset_warnings(void); void networkstatus_reset_download_failures(void); int router_reload_consensus_networkstatus(void); @@ -35,16 +37,19 @@ routerstatus_t *networkstatus_vote_find_mutable_entry(networkstatus_t *ns, const char *digest); int networkstatus_vote_find_entry_idx(networkstatus_t *ns, const char *digest, int *found_out); -download_status_t *router_get_dl_status_by_descriptor_digest(const char *d); + +MOCK_DECL(download_status_t *,router_get_dl_status_by_descriptor_digest, + (const char *d)); + const routerstatus_t *router_get_consensus_status_by_id(const char *digest); routerstatus_t *router_get_mutable_consensus_status_by_id( const char *digest); const routerstatus_t *router_get_consensus_status_by_descriptor_digest( networkstatus_t *consensus, const char *digest); -routerstatus_t *router_get_mutable_consensus_status_by_descriptor_digest( - networkstatus_t *consensus, - const char *digest); +MOCK_DECL(routerstatus_t *, + router_get_mutable_consensus_status_by_descriptor_digest, + (networkstatus_t *consensus, const char *digest)); const routerstatus_t *router_get_consensus_status_by_nickname( const char *nickname, int warn_if_unnamed); @@ -60,8 +65,8 @@ int consensus_is_waiting_for_certs(void); int client_would_use_router(const routerstatus_t *rs, time_t now, const or_options_t *options); networkstatus_t *networkstatus_get_latest_consensus(void); -networkstatus_t *networkstatus_get_latest_consensus_by_flavor( - consensus_flavor_t f); +MOCK_DECL(networkstatus_t *,networkstatus_get_latest_consensus_by_flavor, + (consensus_flavor_t f)); networkstatus_t *networkstatus_get_live_consensus(time_t now); networkstatus_t *networkstatus_get_reasonably_live_consensus(time_t now, int flavor); diff --git a/src/or/routerlist.c b/src/or/routerlist.c index d8e26b084e..e851845280 100644 --- a/src/or/routerlist.c +++ b/src/or/routerlist.c @@ -2615,8 +2615,8 @@ router_get_by_descriptor_digest(const char *digest) /** Return the signed descriptor for the router in our routerlist whose * 20-byte extra-info digest is <b>digest</b>. Return NULL if no such router * is known. */ -signed_descriptor_t * -router_get_by_extrainfo_digest(const char *digest) +MOCK_IMPL(signed_descriptor_t *, +router_get_by_extrainfo_digest,(const char *digest)) { tor_assert(digest); @@ -2939,8 +2939,8 @@ routerlist_insert(routerlist_t *rl, routerinfo_t *ri) /** Adds the extrainfo_t <b>ei</b> to the routerlist <b>rl</b>, if there is a * corresponding router in rl-\>routers or rl-\>old_routers. Return true iff * we actually inserted <b>ei</b>. Free <b>ei</b> if it isn't inserted. */ -static int -extrainfo_insert(routerlist_t *rl, extrainfo_t *ei) +MOCK_IMPL(STATIC int, +extrainfo_insert,(routerlist_t *rl, extrainfo_t *ei)) { int r = 0; routerinfo_t *ri = rimap_get(rl->identity_map, diff --git a/src/or/routerlist.h b/src/or/routerlist.h index 52f2303c7c..950320aa14 100644 --- a/src/or/routerlist.h +++ b/src/or/routerlist.h @@ -82,7 +82,8 @@ int hexdigest_to_digest(const char *hexdigest, char *digest); const routerinfo_t *router_get_by_id_digest(const char *digest); routerinfo_t *router_get_mutable_by_digest(const char *digest); signed_descriptor_t *router_get_by_descriptor_digest(const char *digest); -signed_descriptor_t *router_get_by_extrainfo_digest(const char *digest); +MOCK_DECL(signed_descriptor_t *,router_get_by_extrainfo_digest, + (const char *digest)); signed_descriptor_t *extrainfo_get_by_descriptor_digest(const char *digest); const char *signed_descriptor_get_body(const signed_descriptor_t *desc); const char *signed_descriptor_get_annotations(const signed_descriptor_t *desc); @@ -215,6 +216,8 @@ STATIC void scale_array_elements_to_u64(u64_dbl_t *entries, int n_entries, MOCK_DECL(int, router_descriptor_is_older_than, (const routerinfo_t *router, int seconds)); +MOCK_DECL(STATIC int, extrainfo_insert,(routerlist_t *rl, extrainfo_t *ei)); + #endif #endif |