-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
68de70d
commit 5f46ad5
Showing
9 changed files
with
11,357 additions
and
5,086 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
fn main() { | ||
println!("cargo:rerun-if-changed=src/main.rs"); | ||
blueprint_metadata::generate_json(); | ||
use blueprint_sdk::build; | ||
|
||
fn main() { | ||
let contract_dirs: Vec<&str> = vec!["./contracts"]; | ||
blueprint_build_utils::soldeer_update(); | ||
blueprint_build_utils::build_contracts(contract_dirs); | ||
build::utils::soldeer_update(); | ||
build::utils::build_contracts(contract_dirs); | ||
|
||
println!("cargo:rerun-if-changed=src/lib.rs"); | ||
println!("cargo:rerun-if-changed=src/main.rs"); | ||
build::blueprint_metadata::generate_json(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,28 @@ | ||
use color_eyre::Result; | ||
use blueprint_sdk::logging; | ||
use blueprint_sdk::runners::core::runner::BlueprintRunner; | ||
use blueprint_sdk::runners::tangle::tangle::TangleConfig; | ||
use {{project-name | snake_case}} as blueprint; | ||
use gadget_sdk as sdk; | ||
use sdk::runners::tangle::TangleConfig; | ||
use sdk::runners::BlueprintRunner; | ||
|
||
#[sdk::main(env)] | ||
async fn main() -> Result<()> { | ||
#[blueprint_sdk::main(env)] | ||
async fn main() { | ||
// Create your service context | ||
// Here you can pass any configuration or context that your service needs. | ||
let context = blueprint::ServiceContext { | ||
config: env.clone(), | ||
call_id: None, | ||
}; | ||
|
||
// Create the event handler from the job | ||
let say_hello_job = blueprint::SayHelloEventHandler::new(&env, context).await?; | ||
|
||
tracing::info!("Starting the event watcher ..."); | ||
logging::info!("Starting the event watcher ..."); | ||
let tangle_config = TangleConfig::default(); | ||
BlueprintRunner::new(tangle_config, env) | ||
.job(say_hello_job) | ||
.run() | ||
.await?; | ||
|
||
tracing::info!("Exiting..."); | ||
logging::info!("Exiting..."); | ||
Ok(()) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
use blueprint_sdk::logging; | ||
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::blueprint_serde::to_field; | ||
use blueprint_sdk::testing::utils::tangle::TangleTestHarness; | ||
use blueprint_sdk::tokio; | ||
use {{project-name | snake_case}}::{SayHelloEventHandler, ServiceContext}; | ||
|
||
#[tokio::test] | ||
async fn test_blueprint() -> color_eyre::Result<()> { | ||
logging::setup_log(); | ||
|
||
// Initialize test harness (node, keys, deployment) | ||
let temp_dir = tempfile::TempDir::new()?; | ||
let harness = TangleTestHarness::setup(temp_dir).await?; | ||
let env = harness.env().clone(); | ||
|
||
// Create blueprint-specific context | ||
let blueprint_ctx = ServiceContext { | ||
config: env.clone(), | ||
call_id: None, | ||
}; | ||
|
||
// Initialize event handler | ||
let handler = SayHelloEventHandler::new(&env.clone(), blueprint_ctx) | ||
.await | ||
.unwrap(); | ||
|
||
// 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(); | ||
}); | ||
|
||
// Execute job and verify result | ||
let job_inputs = vec![to_field("Alice").unwrap()]; | ||
let expected_outputs = vec![to_field("Hello, Alice!").unwrap()]; | ||
|
||
let results = harness | ||
.execute_job( | ||
service_id, | ||
0, | ||
job_inputs, | ||
expected_outputs, | ||
) | ||
.await?; | ||
|
||
assert_eq!(results.service_id, service_id); | ||
Ok(()) | ||
} |