From 575e194b6b8b52a1b9548be75d4d19dd4992bc7e Mon Sep 17 00:00:00 2001 From: Keyvan Kambakhsh Date: Wed, 14 Jun 2023 18:09:17 +0430 Subject: [PATCH] Add repeat transaction for testing high-load scenarios --- src/cli/mod.rs | 29 +++++++++++++++++------------ src/core/money.rs | 2 ++ 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/src/cli/mod.rs b/src/cli/mod.rs index 185ee550..a9f4d041 100644 --- a/src/cli/mod.rs +++ b/src/cli/mod.rs @@ -126,6 +126,8 @@ enum WalletOptions { amount: Decimal, #[structopt(long, default_value = "0")] fee: Decimal, + #[structopt(long, default_value = "1")] + repeat: usize, }, /// Register your validator RegisterValidator { @@ -511,19 +513,22 @@ pub async fn initialize_cli() { amount, fee, token_id, + repeat, } => { - crate::cli::wallet::send( - memo, - from, - to, - amount, - fee, - token_id, - conf.expect(BAZUKA_NOT_INITILIZED), - wallet.expect(BAZUKA_NOT_INITILIZED), - &wallet_path, - ) - .await; + for _ in 0..repeat { + crate::cli::wallet::send( + memo.clone(), + from.clone(), + to.clone(), + amount, + fee, + token_id.clone(), + conf.clone().expect(BAZUKA_NOT_INITILIZED), + wallet.clone().expect(BAZUKA_NOT_INITILIZED), + &wallet_path, + ) + .await; + } } WalletOptions::Reset {} => { crate::cli::wallet::reset(wallet.expect(BAZUKA_NOT_INITILIZED), &wallet_path); diff --git a/src/core/money.rs b/src/core/money.rs index 3ea81d6a..c5c54556 100644 --- a/src/core/money.rs +++ b/src/core/money.rs @@ -21,6 +21,8 @@ pub enum ParseDecimalError { #[error("amount invalid")] Invalid, } + +#[derive(Clone, Copy)] pub struct Decimal { pub value: u64, pub num_decimals: u8,