File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -47,27 +47,30 @@ class rate_limiter : public dds::rate_limiter {
47
47
48
48
TEST (RateLimitTest, OnlyAllowedMaxPerSecond)
49
49
{
50
+ auto first_round_time = system_clock::now ();
51
+ auto second_round_time = first_round_time + std::chrono::seconds (5 );
52
+
50
53
std::unique_ptr<mock::timer> timer = std::make_unique<mock::timer>();
51
54
// Four calls within the same second
52
- timer->responses .push (system_clock::duration ( 1708963615 ));
55
+ timer->responses .push (first_round_time. time_since_epoch ( ));
53
56
54
57
mock::rate_limiter rate_limiter (2 );
55
58
rate_limiter.set_timer (std::move (timer));
56
59
57
60
int allowed = 0 ;
58
- for (int i = 0 ; i < 100 ; i++) {
61
+ for (int i = 0 ; i < 10 ; i++) {
59
62
if (rate_limiter.allow ()) {
60
63
allowed++;
61
64
}
62
65
}
63
66
EXPECT_EQ (2 , allowed);
64
67
65
68
timer = std::make_unique<mock::timer>();
66
- timer->responses .push (system_clock::duration ( 1709963630 ));
69
+ timer->responses .push (second_round_time. time_since_epoch ( ));
67
70
rate_limiter.set_timer (std::move (timer));
68
71
69
72
allowed = 0 ;
70
- for (int i = 0 ; i < 100 ; i++) {
73
+ for (int i = 0 ; i < 10 ; i++) {
71
74
if (rate_limiter.allow ()) {
72
75
allowed++;
73
76
}
You can’t perform that action at this time.
0 commit comments