diff options
| author | Arnaud Bailly <arnaud.bailly@iohk.io> | 2024-10-10 08:59:21 +0200 |
|---|---|---|
| committer | Arnaud Bailly <arnaud.bailly@iohk.io> | 2024-10-10 08:59:21 +0200 |
| commit | 21b6997b690a9eaf7ba8659b0a1a895a86a7abc4 (patch) | |
| tree | 3baff3515aefc1e8065ce368e0f4c9fe9047ac20 | |
| parent | b385a464acc0163f887d759bc4c59687f76369ec (diff) | |
| download | lambda-nantes-21b6997b690a9eaf7ba8659b0a1a895a86a7abc4.tar.gz | |
Lower bound for query delay to 500ms
| -rw-r--r-- | rust/src/web.rs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/rust/src/web.rs b/rust/src/web.rs index b9bab27..291801a 100644 --- a/rust/src/web.rs +++ b/rust/src/web.rs @@ -148,6 +148,9 @@ impl Client { if actual == *expected { self.grade += 1; self.delay = Duration::from_secs_f64(self.delay.as_secs_f64() * 0.8); + if self.delay.as_millis() < 500 { + self.delay = Duration::from_millis(500); + } TestResult::TestSucceeded } else { self.delay = Duration::from_secs_f64(self.delay.as_secs_f64() * 1.2); @@ -739,4 +742,17 @@ mod app_tests { assert!(delay_before > client.time_to_next_test()); } + + #[test] + async fn client_decreases_delay_to_minimum_of_500ms() { + let mut client = client(); + let expected = "1".to_string(); + let response = Ok("1".to_string()); + + for _ in 0..100 { + client.check_result(&expected, &response); + } + + assert_eq!(Duration::from_millis(500), client.time_to_next_test()); + } } |
