mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-11 05:33:47 +01:00
Expose GETINFO download status statics for test suite and make things mockable
This commit is contained in:
parent
c692900728
commit
657eaee6ae
@ -2179,7 +2179,7 @@ download_status_to_string(const download_status_t *dl)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Handle the consensus download cases for getinfo_helper_downloads() */
|
/** Handle the consensus download cases for getinfo_helper_downloads() */
|
||||||
static void
|
STATIC void
|
||||||
getinfo_helper_downloads_networkstatus(const char *flavor,
|
getinfo_helper_downloads_networkstatus(const char *flavor,
|
||||||
download_status_t **dl_to_emit,
|
download_status_t **dl_to_emit,
|
||||||
const char **errmsg)
|
const char **errmsg)
|
||||||
@ -2208,7 +2208,7 @@ getinfo_helper_downloads_networkstatus(const char *flavor,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Handle the cert download cases for getinfo_helper_downloads() */
|
/** Handle the cert download cases for getinfo_helper_downloads() */
|
||||||
static void
|
STATIC void
|
||||||
getinfo_helper_downloads_cert(const char *fp_sk_req,
|
getinfo_helper_downloads_cert(const char *fp_sk_req,
|
||||||
download_status_t **dl_to_emit,
|
download_status_t **dl_to_emit,
|
||||||
smartlist_t **digest_list,
|
smartlist_t **digest_list,
|
||||||
@ -2308,7 +2308,7 @@ getinfo_helper_downloads_cert(const char *fp_sk_req,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Handle the routerdesc download cases for getinfo_helper_downloads() */
|
/** Handle the routerdesc download cases for getinfo_helper_downloads() */
|
||||||
static void
|
STATIC void
|
||||||
getinfo_helper_downloads_desc(const char *desc_req,
|
getinfo_helper_downloads_desc(const char *desc_req,
|
||||||
download_status_t **dl_to_emit,
|
download_status_t **dl_to_emit,
|
||||||
smartlist_t **digest_list,
|
smartlist_t **digest_list,
|
||||||
@ -2354,7 +2354,7 @@ getinfo_helper_downloads_desc(const char *desc_req,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Handle the bridge download cases for getinfo_helper_downloads() */
|
/** Handle the bridge download cases for getinfo_helper_downloads() */
|
||||||
static void
|
STATIC void
|
||||||
getinfo_helper_downloads_bridge(const char *bridge_req,
|
getinfo_helper_downloads_bridge(const char *bridge_req,
|
||||||
download_status_t **dl_to_emit,
|
download_status_t **dl_to_emit,
|
||||||
smartlist_t **digest_list,
|
smartlist_t **digest_list,
|
||||||
@ -2397,7 +2397,7 @@ getinfo_helper_downloads_bridge(const char *bridge_req,
|
|||||||
|
|
||||||
/** Implementation helper for GETINFO: knows the answers for questions about
|
/** Implementation helper for GETINFO: knows the answers for questions about
|
||||||
* download status information. */
|
* download status information. */
|
||||||
static int
|
STATIC int
|
||||||
getinfo_helper_downloads(control_connection_t *control_conn,
|
getinfo_helper_downloads(control_connection_t *control_conn,
|
||||||
const char *question, char **answer,
|
const char *question, char **answer,
|
||||||
const char **errmsg)
|
const char **errmsg)
|
||||||
|
@ -261,6 +261,31 @@ STATIC crypto_pk_t *add_onion_helper_keyarg(const char *arg, int discard_pk,
|
|||||||
char **err_msg_out);
|
char **err_msg_out);
|
||||||
STATIC rend_authorized_client_t *
|
STATIC rend_authorized_client_t *
|
||||||
add_onion_helper_clientauth(const char *arg, int *created, char **err_msg_out);
|
add_onion_helper_clientauth(const char *arg, int *created, char **err_msg_out);
|
||||||
|
|
||||||
|
STATIC void getinfo_helper_downloads_networkstatus(
|
||||||
|
const char *flavor,
|
||||||
|
download_status_t **dl_to_emit,
|
||||||
|
const char **errmsg);
|
||||||
|
STATIC void getinfo_helper_downloads_cert(
|
||||||
|
const char *fp_sk_req,
|
||||||
|
download_status_t **dl_to_emit,
|
||||||
|
smartlist_t **digest_list,
|
||||||
|
const char **errmsg);
|
||||||
|
STATIC void getinfo_helper_downloads_desc(
|
||||||
|
const char *desc_req,
|
||||||
|
download_status_t **dl_to_emit,
|
||||||
|
smartlist_t **digest_list,
|
||||||
|
const char **errmsg);
|
||||||
|
STATIC void getinfo_helper_downloads_bridge(
|
||||||
|
const char *bridge_req,
|
||||||
|
download_status_t **dl_to_emit,
|
||||||
|
smartlist_t **digest_list,
|
||||||
|
const char **errmsg);
|
||||||
|
STATIC int getinfo_helper_downloads(
|
||||||
|
control_connection_t *control_conn,
|
||||||
|
const char *question, char **answer,
|
||||||
|
const char **errmsg);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -2425,8 +2425,8 @@ num_bridges_usable(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Return a smartlist containing all bridge identity digests */
|
/** Return a smartlist containing all bridge identity digests */
|
||||||
smartlist_t *
|
MOCK_IMPL(smartlist_t *,
|
||||||
list_bridge_identities(void)
|
list_bridge_identities, (void))
|
||||||
{
|
{
|
||||||
smartlist_t *result = NULL;
|
smartlist_t *result = NULL;
|
||||||
char *digest_tmp;
|
char *digest_tmp;
|
||||||
@ -2445,8 +2445,8 @@ list_bridge_identities(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Get the download status for a bridge descriptor given its identity */
|
/** Get the download status for a bridge descriptor given its identity */
|
||||||
download_status_t *
|
MOCK_IMPL(download_status_t *,
|
||||||
get_bridge_dl_status_by_id(const char *digest)
|
get_bridge_dl_status_by_id, (const char *digest))
|
||||||
{
|
{
|
||||||
download_status_t *dl = NULL;
|
download_status_t *dl = NULL;
|
||||||
|
|
||||||
|
@ -179,8 +179,9 @@ guard_get_guardfraction_bandwidth(guardfraction_bandwidth_t *guardfraction_bw,
|
|||||||
int orig_bandwidth,
|
int orig_bandwidth,
|
||||||
uint32_t guardfraction_percentage);
|
uint32_t guardfraction_percentage);
|
||||||
|
|
||||||
smartlist_t * list_bridge_identities(void);
|
MOCK_DECL(smartlist_t *, list_bridge_identities, (void));
|
||||||
download_status_t * get_bridge_dl_status_by_id(const char *digest);
|
MOCK_DECL(download_status_t *, get_bridge_dl_status_by_id,
|
||||||
|
(const char *digest));
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -683,8 +683,8 @@ router_get_descriptor_digests_in_consensus(networkstatus_t *consensus)
|
|||||||
|
|
||||||
/** Return a smartlist of all router descriptor digests in the current
|
/** Return a smartlist of all router descriptor digests in the current
|
||||||
* consensus */
|
* consensus */
|
||||||
smartlist_t *
|
MOCK_IMPL(smartlist_t *,
|
||||||
router_get_descriptor_digests(void)
|
router_get_descriptor_digests,(void))
|
||||||
{
|
{
|
||||||
smartlist_t *result = NULL;
|
smartlist_t *result = NULL;
|
||||||
|
|
||||||
@ -1219,8 +1219,8 @@ consensus_is_waiting_for_certs(void)
|
|||||||
/** Look up the currently active (depending on bootstrap status) download
|
/** Look up the currently active (depending on bootstrap status) download
|
||||||
* status for this consensus flavor and return a pointer to it.
|
* status for this consensus flavor and return a pointer to it.
|
||||||
*/
|
*/
|
||||||
download_status_t *
|
MOCK_IMPL(download_status_t *,
|
||||||
networkstatus_get_dl_status_by_flavor(consensus_flavor_t flavor)
|
networkstatus_get_dl_status_by_flavor,(consensus_flavor_t flavor))
|
||||||
{
|
{
|
||||||
download_status_t *dl = NULL;
|
download_status_t *dl = NULL;
|
||||||
const int we_are_bootstrapping =
|
const int we_are_bootstrapping =
|
||||||
@ -1236,8 +1236,8 @@ networkstatus_get_dl_status_by_flavor(consensus_flavor_t flavor)
|
|||||||
|
|
||||||
/** Look up the bootstrap download status for this consensus flavor
|
/** Look up the bootstrap download status for this consensus flavor
|
||||||
* and return a pointer to it. */
|
* and return a pointer to it. */
|
||||||
download_status_t *
|
MOCK_IMPL(download_status_t *,
|
||||||
networkstatus_get_dl_status_by_flavor_bootstrap(consensus_flavor_t flavor)
|
networkstatus_get_dl_status_by_flavor_bootstrap,(consensus_flavor_t flavor))
|
||||||
{
|
{
|
||||||
download_status_t *dl = NULL;
|
download_status_t *dl = NULL;
|
||||||
|
|
||||||
@ -1250,8 +1250,8 @@ networkstatus_get_dl_status_by_flavor_bootstrap(consensus_flavor_t flavor)
|
|||||||
|
|
||||||
/** Look up the running (non-bootstrap) download status for this consensus
|
/** Look up the running (non-bootstrap) download status for this consensus
|
||||||
* flavor and return a pointer to it. */
|
* flavor and return a pointer to it. */
|
||||||
download_status_t *
|
MOCK_IMPL(download_status_t *,
|
||||||
networkstatus_get_dl_status_by_flavor_running(consensus_flavor_t flavor)
|
networkstatus_get_dl_status_by_flavor_running,(consensus_flavor_t flavor))
|
||||||
{
|
{
|
||||||
download_status_t *dl = NULL;
|
download_status_t *dl = NULL;
|
||||||
|
|
||||||
|
@ -38,14 +38,17 @@ routerstatus_t *networkstatus_vote_find_mutable_entry(networkstatus_t *ns,
|
|||||||
int networkstatus_vote_find_entry_idx(networkstatus_t *ns,
|
int networkstatus_vote_find_entry_idx(networkstatus_t *ns,
|
||||||
const char *digest, int *found_out);
|
const char *digest, int *found_out);
|
||||||
|
|
||||||
download_status_t * networkstatus_get_dl_status_by_flavor(
|
MOCK_DECL(download_status_t *,
|
||||||
consensus_flavor_t flavor);
|
networkstatus_get_dl_status_by_flavor,
|
||||||
download_status_t * networkstatus_get_dl_status_by_flavor_bootstrap(
|
(consensus_flavor_t flavor));
|
||||||
consensus_flavor_t flavor);
|
MOCK_DECL(download_status_t *,
|
||||||
download_status_t * networkstatus_get_dl_status_by_flavor_running(
|
networkstatus_get_dl_status_by_flavor_bootstrap,
|
||||||
consensus_flavor_t flavor);
|
(consensus_flavor_t flavor));
|
||||||
|
MOCK_DECL(download_status_t *,
|
||||||
|
networkstatus_get_dl_status_by_flavor_running,
|
||||||
|
(consensus_flavor_t flavor));
|
||||||
|
|
||||||
smartlist_t * router_get_descriptor_digests(void);
|
MOCK_DECL(smartlist_t *, router_get_descriptor_digests, (void));
|
||||||
MOCK_DECL(download_status_t *,router_get_dl_status_by_descriptor_digest,
|
MOCK_DECL(download_status_t *,router_get_dl_status_by_descriptor_digest,
|
||||||
(const char *d));
|
(const char *d));
|
||||||
|
|
||||||
|
@ -257,8 +257,8 @@ get_cert_list(const char *id_digest)
|
|||||||
* of download_status_t objects; used by controller GETINFO queries.
|
* of download_status_t objects; used by controller GETINFO queries.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
smartlist_t *
|
MOCK_IMPL(smartlist_t *,
|
||||||
list_authority_ids_with_downloads(void)
|
list_authority_ids_with_downloads, (void))
|
||||||
{
|
{
|
||||||
smartlist_t *ids = smartlist_new();
|
smartlist_t *ids = smartlist_new();
|
||||||
digestmap_iter_t *i;
|
digestmap_iter_t *i;
|
||||||
@ -288,8 +288,8 @@ list_authority_ids_with_downloads(void)
|
|||||||
/** Given an authority ID digest, return a pointer to the default download
|
/** Given an authority ID digest, return a pointer to the default download
|
||||||
* status, or NULL if there is no such entry in trusted_dir_certs */
|
* status, or NULL if there is no such entry in trusted_dir_certs */
|
||||||
|
|
||||||
download_status_t *
|
MOCK_IMPL(download_status_t *,
|
||||||
id_only_download_status_for_authority_id(const char *digest)
|
id_only_download_status_for_authority_id, (const char *digest))
|
||||||
{
|
{
|
||||||
download_status_t *dl = NULL;
|
download_status_t *dl = NULL;
|
||||||
cert_list_t *cl;
|
cert_list_t *cl;
|
||||||
@ -308,8 +308,8 @@ id_only_download_status_for_authority_id(const char *digest)
|
|||||||
* for which download_status_t is potentially queryable, or NULL if no such
|
* for which download_status_t is potentially queryable, or NULL if no such
|
||||||
* authority ID digest is known. */
|
* authority ID digest is known. */
|
||||||
|
|
||||||
smartlist_t *
|
MOCK_IMPL(smartlist_t *,
|
||||||
list_sk_digests_for_authority_id(const char *digest)
|
list_sk_digests_for_authority_id, (const char *digest))
|
||||||
{
|
{
|
||||||
smartlist_t *sks = NULL;
|
smartlist_t *sks = NULL;
|
||||||
cert_list_t *cl;
|
cert_list_t *cl;
|
||||||
@ -342,9 +342,9 @@ list_sk_digests_for_authority_id(const char *digest)
|
|||||||
/** Given an authority ID digest and a signing key digest, return the
|
/** Given an authority ID digest and a signing key digest, return the
|
||||||
* download_status_t or NULL if none exists. */
|
* download_status_t or NULL if none exists. */
|
||||||
|
|
||||||
download_status_t *
|
MOCK_IMPL(download_status_t *,
|
||||||
download_status_for_authority_id_and_sk(const char *id_digest,
|
download_status_for_authority_id_and_sk,
|
||||||
const char *sk_digest)
|
(const char *id_digest, const char *sk_digest))
|
||||||
{
|
{
|
||||||
download_status_t *dl = NULL;
|
download_status_t *dl = NULL;
|
||||||
cert_list_t *cl = NULL;
|
cert_list_t *cl = NULL;
|
||||||
|
@ -104,13 +104,13 @@ void routerlist_remove(routerlist_t *rl, routerinfo_t *ri, int make_old,
|
|||||||
void routerlist_free_all(void);
|
void routerlist_free_all(void);
|
||||||
void routerlist_reset_warnings(void);
|
void routerlist_reset_warnings(void);
|
||||||
|
|
||||||
smartlist_t * list_authority_ids_with_downloads(void);
|
MOCK_DECL(smartlist_t *, list_authority_ids_with_downloads, (void);)
|
||||||
download_status_t * id_only_download_status_for_authority_id(
|
MOCK_DECL(download_status_t *, id_only_download_status_for_authority_id,
|
||||||
const char *digest);
|
(const char *digest));
|
||||||
smartlist_t * list_sk_digests_for_authority_id(const char *digest);
|
MOCK_DECL(smartlist_t *, list_sk_digests_for_authority_id,
|
||||||
download_status_t * download_status_for_authority_id_and_sk(
|
(const char *digest));
|
||||||
const char *id_digest,
|
MOCK_DECL(download_status_t *, download_status_for_authority_id_and_sk,
|
||||||
const char *sk_digest);
|
(const char *id_digest, const char *sk_digest));
|
||||||
|
|
||||||
static int WRA_WAS_ADDED(was_router_added_t s);
|
static int WRA_WAS_ADDED(was_router_added_t s);
|
||||||
static int WRA_WAS_OUTDATED(was_router_added_t s);
|
static int WRA_WAS_OUTDATED(was_router_added_t s);
|
||||||
|
Loading…
Reference in New Issue
Block a user