Skip to content
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 28 additions & 24 deletions utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ pub struct SpamCmd {
/// Rate of transactions per second
#[clap(short, long, default_value = "1000")]
rate: u64,
/// Interval in ms for sending batches of transactions
#[clap(short, long, default_value = "200")]
interval: u64,
/// Time to run the spammer for in seconds
#[clap(short, long, default_value = "0")]
time: u64,
Expand All @@ -150,24 +153,23 @@ impl SpamCmd {
rpc_url,
num_txs,
rate,
interval,
time,
blobs,
signer_index,
chain_id,
} = self;

let url: Url = rpc_url.parse()?;
Spammer::new(
url,
*signer_index,
*num_txs,
*time,
*rate,
*blobs,
*chain_id,
)?
.run()
.await
let config = spammer::SpammerConfig {
max_num_txs: *num_txs,
max_time: *time,
max_rate: *rate,
batch_interval: *interval,
blobs: *blobs,
chain_id: *chain_id,
};
Spammer::new(url, *signer_index, config)?.run().await
}
}

Expand Down Expand Up @@ -296,6 +298,9 @@ pub struct SpamContractCmd {
/// Rate of transactions per second
#[clap(short, long, default_value_t = 1000)]
rate: u64,
/// Interval in ms for sending batches of transactions
#[clap(short, long, default_value = "200")]
interval: u64,
/// Time to run the spammer for in seconds
#[clap(short, long, default_value_t = 0)]
time: u64,
Expand All @@ -315,23 +320,22 @@ impl SpamContractCmd {
rpc_url,
num_txs,
rate,
interval,
time,
signer_index,
chain_id,
} = self;
let url = format!("http://{rpc_url}").parse()?;
Spammer::new_contract(
url,
*signer_index,
*num_txs,
*time,
*rate,
contract,
function,
args,
*chain_id,
)?
.run()
.await
let config = spammer::SpammerConfig {
max_num_txs: *num_txs,
max_time: *time,
max_rate: *rate,
batch_interval: *interval,
blobs: false,
chain_id: *chain_id,
};
Spammer::new_contract(url, *signer_index, config, contract, function, args)?
.run()
.await
}
}
Loading