upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/grasp-audit/examples/simple_audit.rs
blob: e363d5c9e14673c73472c008c9a45323b60de3b5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
//! Simple audit example
//!
//! Run with: cargo run --example simple_audit

use grasp_audit::*;

#[tokio::main]
async fn main() -> Result<()> {
    // Create audit config for CI testing
    let config = AuditConfig::ci();

    println!("GRASP Audit Example");
    println!("==================");
    println!("Audit Run ID: {}", config.run_id);
    println!();

    // Connect to relay
    println!("Connecting to relay at ws://localhost:7000...");
    let client = match AuditClient::new("ws://localhost:7000", config).await {
        Ok(c) => c,
        Err(e) => {
            eprintln!("Failed to connect: {}", e);
            eprintln!();
            eprintln!("Make sure a Nostr relay is running at ws://localhost:7000");
            eprintln!("You can use: https://github.com/rust-nostr/nostr/tree/master/crates/nostr-relay-builder");
            return Err(e);
        }
    };

    if !client.is_connected().await {
        eprintln!("Not connected to relay");
        return Err(anyhow!("Connection failed"));
    }

    println!("✓ Connected");
    println!();

    // Run NIP-01 smoke tests
    println!("Running NIP-01 smoke tests...");
    println!();

    let results = specs::Nip01SmokeTests::run_all(&client).await;

    // Print results
    results.print_report();

    // Exit with error if tests failed
    if !results.all_passed() {
        std::process::exit(1);
    }

    Ok(())
}