Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add dynamic multinode test executor #626

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 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
30 changes: 14 additions & 16 deletions blueprints/incredible-squaring/src/tests.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
use crate::{MyContext, XsquareEventHandler};
use blueprint_sdk::config::GadgetConfiguration;
use blueprint_sdk::event_listeners::core::InitializableEventHandler;
use blueprint_sdk::logging::setup_log;
use blueprint_sdk::testing::tempfile;
use blueprint_sdk::testing::utils::harness::TestHarness;
Expand All @@ -12,27 +14,23 @@ async fn test_incredible_squaring() -> Result<()> {

// Initialize test harness (node, keys, deployment)
let temp_dir = tempfile::TempDir::new()?;
let harness = TangleTestHarness::setup(temp_dir).await?;
let env = harness.env().clone();
let harness = TangleTestHarness::<1>::setup(temp_dir).await?;

// Create blueprint-specific context
let blueprint_ctx = MyContext {
env: env.clone(),
call_id: None,
};
let xsquare_creator = |env| async move {
// Create blueprint-specific context
let blueprint_ctx = MyContext {
env: env.clone(),
call_id: None,
};

// Initialize event handler
let handler = XsquareEventHandler::new(&env.clone(), blueprint_ctx)
.await
.unwrap();
// Initialize event handler
XsquareEventHandler::new(&env, blueprint_ctx).await?
};

// Setup service
let (mut test_env, service_id) = harness.setup_services().await?;
test_env.add_job(handler);

tokio::spawn(async move {
test_env.run_runner().await.unwrap();
});
test_env.add_job(xsquare_creator)?;
test_env.start()?;

// Execute job and verify result
let results = harness
Expand Down
3 changes: 0 additions & 3 deletions crates/testing-utils/core/src/harness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ pub trait TestHarness {

/// Gets the gadget configuration
fn env(&self) -> &GadgetConfiguration;

/// Gets the configuration
fn config(&self) -> &Self::Config;
}

/// Base implementation of a test harness that can be used by specific implementations
Expand Down
Loading
Loading