diff options
author | Micah Elizabeth Scott <beth@torproject.org> | 2023-02-24 18:25:25 -0800 |
---|---|---|
committer | Micah Elizabeth Scott <beth@torproject.org> | 2023-05-10 07:38:28 -0700 |
commit | 48c67263d9b3779e1f3296564192b13b6b0895b4 (patch) | |
tree | 79808b8e059916a49a6e2619f02a641a7fe1d4a3 /src/test | |
parent | 09afc5eacf67d83cd75b3a659fc23a6120e0033e (diff) | |
download | tor-48c67263d9b3779e1f3296564192b13b6b0895b4.tar.gz tor-48c67263d9b3779e1f3296564192b13b6b0895b4.zip |
hs_metrics: Proof of Work pqueue depth, suggested effort
Adds two new metrics for hs_pow, and an internal parameter within
hs_metrics for implementing gauge parameters that reset before
every update.
Signed-off-by: Micah Elizabeth Scott <beth@torproject.org>
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/test_hs_metrics.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/src/test/test_hs_metrics.c b/src/test/test_hs_metrics.c index c3c7ef57bc..acb0649434 100644 --- a/src/test/test_hs_metrics.c +++ b/src/test/test_hs_metrics.c @@ -40,7 +40,8 @@ test_metrics(void *arg) /* Update entry by identifier. */ hs_metrics_update_by_ident(HS_METRICS_NUM_INTRODUCTIONS, - &service->keys.identity_pk, 0, NULL, 42, 0); + &service->keys.identity_pk, 0, NULL, 42, + 0, false); /* Confirm the entry value. */ const smartlist_t *entries = metrics_store_get_all(service->metrics.store, @@ -53,14 +54,15 @@ test_metrics(void *arg) /* Update entry by service now. */ hs_metrics_update_by_service(HS_METRICS_NUM_INTRODUCTIONS, - service, 0, NULL, 42, 0); + service, 0, NULL, 42, 0, false); tt_int_op(metrics_store_entry_get_value(entry), OP_EQ, 84); const char *reason = HS_METRICS_ERR_INTRO_REQ_BAD_AUTH_KEY; /* Update tor_hs_intro_rejected_intro_req_count */ hs_metrics_update_by_ident(HS_METRICS_NUM_REJECTED_INTRO_REQ, - &service->keys.identity_pk, 0, reason, 112, 0); + &service->keys.identity_pk, 0, + reason, 112, 0, false); entries = metrics_store_get_all(service->metrics.store, "tor_hs_intro_rejected_intro_req_count"); @@ -75,9 +77,19 @@ test_metrics(void *arg) /* Update tor_hs_intro_rejected_intro_req_count entry by service now. */ hs_metrics_update_by_service(HS_METRICS_NUM_REJECTED_INTRO_REQ, service, 0, - reason, 10, 0); + reason, 10, 0, false); tt_int_op(metrics_store_entry_get_value(entry), OP_EQ, 122); + /* So far these have been relative updates. Test updates with reset */ + hs_metrics_update_by_service(HS_METRICS_NUM_REJECTED_INTRO_REQ, + service, 0, reason, 10, 0, true); + tt_int_op(metrics_store_entry_get_value(entry), OP_EQ, 10); + + hs_metrics_update_by_ident(HS_METRICS_NUM_REJECTED_INTRO_REQ, + &service->keys.identity_pk, 0, reason, + 345, 0, true); + tt_int_op(metrics_store_entry_get_value(entry), OP_EQ, 345); + done: hs_free_all(); } |