From 5c5da461690684e90ecc12565d674fbca06b5f53 Mon Sep 17 00:00:00 2001 From: Hansie Odendaal <39146854+hansieodendaal@users.noreply.github.com> Date: Mon, 26 Feb 2024 10:48:10 +0200 Subject: [PATCH] fix: fixed make-it-rain delay (#6165) Description --- Fixed make-it-rain delay Motivation and Context --- The delay did not work properly How Has This Been Tested? --- System-level testing (`make-it-rain --stealth --duration 7200 --transactions-per-second 1 --start-amount 0.039000T --increase-amount 0T --start-time now --message Brian_01_(stealth) d035876f990517ff2629d7acbba9c86a760412f12c029119e545ec2f1bda1f1ec1`) What process can a PR reviewer use to test or verify this change? --- Code walk-through System-level testing Breaking Changes --- - [x] None - [ ] Requires data directory on base node to be deleted - [ ] Requires hard fork - [ ] Other - Please specify --- .../src/automation/commands.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/applications/minotari_console_wallet/src/automation/commands.rs b/applications/minotari_console_wallet/src/automation/commands.rs index 8208168bad..e09e019ef1 100644 --- a/applications/minotari_console_wallet/src/automation/commands.rs +++ b/applications/minotari_console_wallet/src/automation/commands.rs @@ -409,10 +409,19 @@ pub async fn make_it_rain( // Manage transaction submission rate let actual_ms = (Utc::now() - started_at).num_milliseconds(); - let target_ms = (i as f64 / f64::from(transactions_per_second) / 1000.0) as i64; + let target_ms = (i as f64 * (1000.0 / f64::from(transactions_per_second))) as i64; + trace!( + target: LOG_TARGET, + "make-it-rain {}: target {:?} ms vs. actual {:?} ms", i, target_ms, actual_ms + ); if target_ms - actual_ms > 0 { // Maximum delay between Txs set to 120 s - sleep(Duration::from_millis((target_ms - actual_ms).min(120_000i64) as u64)).await; + let delay_ms = Duration::from_millis((target_ms - actual_ms).min(120_000i64) as u64); + trace!( + target: LOG_TARGET, + "make-it-rain {}: delaying for {:?} ms", i, delay_ms + ); + sleep(delay_ms).await; } let delayed_for = Instant::now(); let sender_clone = sender.clone();