diff options
author | George Kadianakis <desnacked@riseup.net> | 2020-10-21 14:17:30 +0300 |
---|---|---|
committer | George Kadianakis <desnacked@riseup.net> | 2020-11-03 11:12:17 +0200 |
commit | 131da887d75bd112e668db3c1695ad8cc5a76433 (patch) | |
tree | 9adf7e0cd9bbbd3f5203ade14c661515df460b3a /src/feature/stats | |
parent | 5c00bee1b1cde4bb77a2e3fa1f5110850ddede6e (diff) | |
download | tor-131da887d75bd112e668db3c1695ad8cc5a76433.tar.gz tor-131da887d75bd112e668db3c1695ad8cc5a76433.zip |
Write unittests for v3 metrics.
Diffstat (limited to 'src/feature/stats')
-rw-r--r-- | src/feature/stats/rephist.c | 6 | ||||
-rw-r--r-- | src/feature/stats/rephist.h | 11 |
2 files changed, 10 insertions, 7 deletions
diff --git a/src/feature/stats/rephist.c b/src/feature/stats/rephist.c index 24712707ca..ada19b447a 100644 --- a/src/feature/stats/rephist.c +++ b/src/feature/stats/rephist.c @@ -1871,8 +1871,8 @@ rep_hist_reset_hs_v3_stats(time_t now) * on the real network) and hence we don't want to collect statistics if it's * not yet the time to do so. */ -static bool -should_collect_v3_stats(void) +MOCK_IMPL(STATIC bool, +should_collect_v3_stats,(void)) { return start_of_hs_v3_stats_interval <= approx_time(); } @@ -1973,7 +1973,7 @@ rep_hist_hs_stats_term(void) /** Allocate and return a string containing hidden service stats that * are meant to be placed in the extra-info descriptor. */ -static char * +STATIC char * rep_hist_format_hs_v2_stats(time_t now) { char t[ISO_TIME_LEN+1]; diff --git a/src/feature/stats/rephist.h b/src/feature/stats/rephist.h index 3bb4f996a2..b2a4a5048d 100644 --- a/src/feature/stats/rephist.h +++ b/src/feature/stats/rephist.h @@ -117,6 +117,9 @@ typedef struct hs_v3_stats_t { STATIC char *rep_hist_format_hs_v2_stats(time_t now); STATIC char *rep_hist_format_hs_v3_stats(time_t now); + +MOCK_DECL(STATIC bool, should_collect_v3_stats,(void)); + #endif /* defined(REPHIST_PRIVATE) */ /** @@ -145,10 +148,10 @@ void rep_hist_prep_published_padding_counts(time_t now); void rep_hist_padding_count_timers(uint64_t num_timers); #ifdef TOR_UNIT_TESTS -typedef struct hs_v2_stats_t hs_v2_stats_t; -const hs_v2_stats_t *rep_hist_get_hs_v2_stats(void); -typedef struct hs_v3_stats_t hs_v3_stats_t; -const hs_v3_stats_t *rep_hist_get_hs_v3_stats(void); +struct hs_v2_stats_t; +const struct hs_v2_stats_t *rep_hist_get_hs_v2_stats(void); +struct hs_v3_stats_t; +const struct hs_v3_stats_t *rep_hist_get_hs_v3_stats(void); #endif #endif /* !defined(TOR_REPHIST_H) */ |