From 8966ee972c81fa5cabac0d51f1312650b456746b Mon Sep 17 00:00:00 2001 From: maximilien-hyle Date: Tue, 17 Dec 2024 15:46:15 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=A7=20=20Adding=20Goose=20scenario=20f?= =?UTF-8?q?or=20loadtesting?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crates/hyle-loadtest/Cargo.toml | 16 ++++++++++++++ crates/hyle-loadtest/src/main.rs | 36 ++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 crates/hyle-loadtest/Cargo.toml create mode 100644 crates/hyle-loadtest/src/main.rs diff --git a/crates/hyle-loadtest/Cargo.toml b/crates/hyle-loadtest/Cargo.toml new file mode 100644 index 00000000..abe956c6 --- /dev/null +++ b/crates/hyle-loadtest/Cargo.toml @@ -0,0 +1,16 @@ +[package] +name = "hyle-loadtest" +version.workspace = true +edition.workspace = true +homepage.workspace = true +repository.workspace = true + +[dependencies] +goose = "^0.17" +serde_json = "1.0.133" +tokio = "^1.12" +hyle = { path = "../../" } +# hyllar = { path = "../../contracts/hyllar" } +# amm = { path = "../../contracts/amm" } +# hydentity = { path = "../../contracts/hydentity" } +hyle-contract-sdk = { path = "../../contract-sdk", features = ["tracing"] } diff --git a/crates/hyle-loadtest/src/main.rs b/crates/hyle-loadtest/src/main.rs new file mode 100644 index 00000000..8f71aab3 --- /dev/null +++ b/crates/hyle-loadtest/src/main.rs @@ -0,0 +1,36 @@ +use goose::prelude::*; +use hyle::model::{BlobTransaction, ContractName}; +use hyle_contract_sdk::identity_provider::IdentityAction; + +async fn register_user(user: &mut GooseUser) -> TransactionResult { + for i in 0..10000 { + let identity = format!("identity-{}.hydentity", i); + + // Register identity + let blobs = vec![IdentityAction::RegisterIdentity { + account: identity.clone(), + } + .as_blob(ContractName("hydentity".to_owned()))]; + + let register_identity_blob_transaction = BlobTransaction { + identity: identity.into(), + blobs, + }; + user.post_json("/v1/tx/send/blob", ®ister_identity_blob_transaction) + .await?; + } + Ok(()) +} + +#[tokio::main] +async fn main() -> Result<(), GooseError> { + GooseAttack::initialize()? + .register_scenario( + scenario!("RegisterUsersBlobTransactions") + .register_transaction(transaction!(register_user)), + ) + .execute() + .await?; + + Ok(()) +}