Skip to content

Commit

Permalink
✨ move to yaml config for simulation
Browse files Browse the repository at this point in the history
  • Loading branch information
AbdelStark committed Jul 7, 2023
1 parent 3615e08 commit 74d8e01
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 13 deletions.
5 changes: 0 additions & 5 deletions config/default.toml

This file was deleted.

5 changes: 0 additions & 5 deletions config/rinnegan.toml

This file was deleted.

8 changes: 8 additions & 0 deletions config/rinnegan.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
rpc:
url: "https://rinnegan.madara.zone"

simulation:
fail_fast: true
setup:
create_accounts:
num_accounts: 10
4 changes: 2 additions & 2 deletions crates/gatling/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[package]
name = "gatling"
version = "0.1.2"
version = "0.1.3"
edition = "2021"
license = "MIT"
homepage = "https://github.com/keep-starknet-strange/gomu-gomu-no-gatling"
repository = "https://github.com/keep-starknet-strange/gomu-gomu-no-gatling"
categories = ["command-line", "benchmark", "asynchronous"]
categories = ["command-line-interface", "command-line-utilities"]
keywords = ["starknet", "cairo"]
description = "Gomu Gomu No Gatling is a blazing fast tool to benchmark Starknet sequencers."
readme = "README.md"
Expand Down
2 changes: 1 addition & 1 deletion crates/gatling/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ gatling --help
### Run a load test

```bash
gatling shoot --config-path config/rinnegan.toml
gatling shoot --config-path config/rinnegan.yaml
```

## License
Expand Down
19 changes: 19 additions & 0 deletions crates/gatling/src/actions/shoot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ impl GatlingShooter {
info!("chain id: {}", chain_id);
let block_number = self.starknet_rpc.block_number().await?;
info!("block number: {}", block_number);

if let Some(setup) = self.config.clone().simulation.unwrap_or_default().setup {
if let Some(create_accounts) = setup.create_accounts {
self.create_accounts(_simulation_report, create_accounts.num_accounts)
.await?;
}
}

Ok(())
}

Expand All @@ -57,6 +65,17 @@ impl GatlingShooter {
let _fail_fast = self.config.simulation.clone().unwrap_or_default().fail_fast;
Ok(())
}

/// Create accounts.
async fn create_accounts<'a>(
&mut self,
_simulation_report: &'a mut SimulationReport,
num_accounts: u32,
) -> Result<()> {
info!("creating {} accounts!", num_accounts);
// TODO: create accounts.
Ok(())
}
}

/// The simulation report.
Expand Down
11 changes: 11 additions & 0 deletions crates/gatling/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,17 @@ impl Default for Rpc {
#[allow(unused)]
pub struct Simulation {
pub fail_fast: bool,
pub setup: Option<Setup>,
}

#[derive(Debug, Deserialize, Default, Clone)]
pub struct Setup {
pub create_accounts: Option<CreateAccounts>,
}

#[derive(Debug, Deserialize, Default, Clone)]
pub struct CreateAccounts {
pub num_accounts: u32,
}

impl GatlingConfig {
Expand Down

0 comments on commit 74d8e01

Please sign in to comment.