Skip to content

Commit

Permalink
stdout messaging
Browse files Browse the repository at this point in the history
  • Loading branch information
drspacemn committed Jul 12, 2023
1 parent 38e0b56 commit 209cc14
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 9 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ cargo install --path .
cargo install --locked gatling
```

### Run debug

```bash
RUST_LOG=info cargo run -- shoot -c config/rinnegan.yaml
```

## Usage

```bash
Expand Down
10 changes: 10 additions & 0 deletions config/default.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
rpc:
url: "http://localhost:9944"

simulation:
fail_fast: true
setup:
create_accounts:
num_accounts: 10
seed: 1

1 change: 1 addition & 0 deletions config/rinnegan.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ simulation:
setup:
create_accounts:
num_accounts: 10
seed: 0
1 change: 1 addition & 0 deletions config/sharingan.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ simulation:
setup:
create_accounts:
num_accounts: 10
seed: 0
20 changes: 12 additions & 8 deletions src/actions/shoot.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
use crate::config::GatlingConfig;
use crate::config::{CreateAccounts, GatlingConfig};
use color_eyre::eyre::Result;
use log::info;
use starknet::{core::types::FieldElement, providers::Provider};

use starknet::providers::{jsonrpc::HttpTransport, JsonRpcClient};
use std::str;
use url::Url;

/// Shoot the load test simulation.
Expand Down Expand Up @@ -37,15 +38,17 @@ impl GatlingShooter {

/// Setup the simulation.
async fn setup<'a>(&mut self, _simulation_report: &'a mut SimulationReport) -> Result<()> {
info!("setting up!");
let chain_id = self.starknet_rpc.chain_id().await?;
info!("chain id: {}", chain_id);
let chain_id = self.starknet_rpc.chain_id().await?.to_bytes_be();
let block_number = self.starknet_rpc.block_number().await?;
info!("block number: {}", block_number);
println!(
"chain id - {:?} @ block number - {}",
str::from_utf8(&chain_id)?.trim_start_matches('\0'),
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)
self.create_accounts(_simulation_report, create_accounts)
.await?;
}
}
Expand All @@ -70,9 +73,10 @@ impl GatlingShooter {
async fn create_accounts<'a>(
&mut self,
_simulation_report: &'a mut SimulationReport,
num_accounts: u32,
account_details: CreateAccounts,
) -> Result<()> {
info!("creating {} accounts!", num_accounts);
println!("creating {} accounts w/ seed {}", account_details.num_accounts, account_details.seed);

// TODO: create accounts.
Ok(())
}
Expand Down
1 change: 1 addition & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ pub struct Setup {
#[derive(Debug, Deserialize, Default, Clone)]
pub struct CreateAccounts {
pub num_accounts: u32,
pub seed: u32,
}

impl GatlingConfig {
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ async fn main() -> Result<()> {
// Load the environment variables from the .env file.
dotenv().ok();

info!("Starting Gomu Gomu no Gatling...");
info!("Starting Gatling...");

// Parse the command line arguments.
let cli = Cli::parse();
Expand Down

0 comments on commit 209cc14

Please sign in to comment.