Skip to content

Commit

Permalink
feat: add correct logic, trait type needs attn
Browse files Browse the repository at this point in the history
  • Loading branch information
tbraun96 committed Jan 31, 2025
1 parent 93e68e9 commit 29e33fe
Show file tree
Hide file tree
Showing 5 changed files with 197 additions and 110 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions blueprints/incredible-squaring/src/tests.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
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;
use blueprint_sdk::testing::utils::runner::TestEnv;
use blueprint_sdk::testing::utils::tangle::{InputValue, OutputValue, TangleTestHarness};
use color_eyre::Result;

Expand All @@ -16,15 +14,17 @@ async fn test_incredible_squaring() -> Result<()> {
let temp_dir = tempfile::TempDir::new()?;
let harness = TangleTestHarness::<1>::setup(temp_dir).await?;

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

// Initialize event handler
XsquareEventHandler::new(&env, blueprint_ctx).await?
XsquareEventHandler::new(&env, blueprint_ctx)
.await
.expect("Failed to create event handler")
};

// Setup service
Expand Down
1 change: 1 addition & 0 deletions crates/event-listeners/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ gadget-std = { workspace = true }
async-trait = { workspace = true }
thiserror = { workspace = true }
tokio = { workspace = true, features = ["sync"] }
auto_impl = { workspace = true }

[features]
default = ["std"]
Expand Down
2 changes: 2 additions & 0 deletions crates/event-listeners/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ pub mod executor;
pub mod testing;

use async_trait::async_trait;
use auto_impl::auto_impl;
use exponential_backoff::ExponentialBackoff;
use gadget_std::iter::Take;

Expand All @@ -29,6 +30,7 @@ pub fn get_exponential_backoff<const N: usize>() -> Take<ExponentialBackoff> {
}

#[async_trait]
#[auto_impl(Arc, Box)]
pub trait InitializableEventHandler {
async fn init_event_handler(
&self,
Expand Down
Loading

0 comments on commit 29e33fe

Please sign in to comment.