diff options
author | Nick Mathewson <nickm@torproject.org> | 2020-08-04 13:51:28 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2020-08-04 13:56:28 -0400 |
commit | 1d0695fe7eb0b1b8176c71ecc6e5fe74a5b71378 (patch) | |
tree | f871ac06dd771d467b0a0e06c57b5e691ba5e35c /src/test/test_logging.c | |
parent | 04926126ee7fd9bbaefe5890d238fd8156124a5b (diff) | |
download | tor-1d0695fe7eb0b1b8176c71ecc6e5fe74a5b71378.tar.gz tor-1d0695fe7eb0b1b8176c71ecc6e5fe74a5b71378.zip |
Improve ratelimit message to list true interval.
Previous message would say "N messages in the last T seconds", but
would give an inaccurate number for N.
We now give an accurate number, rounded up to the nearest 60 seconds.
Closes #19431.
Diffstat (limited to 'src/test/test_logging.c')
-rw-r--r-- | src/test/test_logging.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/test/test_logging.c b/src/test/test_logging.c index e09f7a21cd..58d0f24bd3 100644 --- a/src/test/test_logging.c +++ b/src/test/test_logging.c @@ -160,6 +160,7 @@ test_ratelim(void *arg) tor_free(msg); int i; + time_t first_suppressed_at = now + 60; for (i = 0; i < 9; ++i) { now += 60; /* one minute has passed. */ msg = rate_limit_log(&ten_min, now); @@ -167,12 +168,15 @@ test_ratelim(void *arg) tt_int_op(ten_min.last_allowed, OP_EQ, start); tt_int_op(ten_min.n_calls_since_last_time, OP_EQ, i + 1); } + tt_i64_op(ten_min.started_limiting, OP_EQ, first_suppressed_at); now += 240; /* Okay, we can be done. */ msg = rate_limit_log(&ten_min, now); tt_ptr_op(msg, OP_NE, NULL); tt_str_op(msg, OP_EQ, - " [9 similar message(s) suppressed in last 600 seconds]"); + " [9 similar message(s) suppressed in last 720 seconds]"); + tt_i64_op(now, OP_EQ, first_suppressed_at + 720); + done: tor_free(msg); } |