4 releases

Uses new Rust 2024

new 0.1.0-alpha.4 Apr 15, 2025
0.1.0-alpha.3 Apr 14, 2025
0.1.0-alpha.1 Apr 9, 2025

#532 in Magic Beans

Download history 414/week @ 2025-04-09

414 downloads per month
Used in 2 crates (via blueprint-testing-utils)

MIT/Apache and GPL-3.0-only

1MB
13K SLoC

Tangle Testing Framework

A lightweight testing framework for Tangle blueprints that provides a complete test environment with minimal setup.

Architecture

The framework consists of three main components:

TangleTestHarness

The main test harness that manages the complete test infrastructure. It handles:

  • Local node setup and management
  • Key/signer initialization
  • MBSM deployment
  • Service deployment and configuration
  • Job execution and verification

TangleTestEnv

The test environment implementation that manages blueprint runners and event handlers. It's used internally by the harness to:

  • Initialize event handlers
  • Manage job execution
  • Handle test-specific configurations

Blueprint Context

Your blueprint-specific context (e.g. MyContext) that holds the state needed by your event handlers.

Usage Example

#[tokio::test]
async fn test_my_blueprint() -> Result<()> {
    // Initialize test harness (node, keys, deployment)
    let harness = TangleTestHarness::setup().await?;

    // Create your blueprint context
    let blueprint_ctx = MyContext {
        env: harness.env.clone(),
        call_id: None,
    };

    // Initialize your event handler
    let handler = MyEventHandler::new(&harness.env, blueprint_ctx).await?;

    // Setup service and run test
    let (_blueprint_id, service_id) = harness.setup_service(vec![handler]).await?;

    // Execute jobs and verify results
    let results = harness
        .execute_job(
            service_id,
            JOB_ID,
            inputs,
            expected_outputs,
        )
        .await?;
}

Dependencies

~239MB
~4M SLoC