mirror of
https://relay.ngit.dev/npub15qydau2hjma6ngxkl2cyar74wzyjshvl65za5k5rl69264ar2exs5cyejr/ngit-grasp.git
synced 2026-10-06 07:28:23 +00:00
54 lines
1.4 KiB
Rust
54 lines
1.4 KiB
Rust
//! 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(())
|
|
}
|