64 lines
2.0 KiB
Rust
64 lines
2.0 KiB
Rust
#!/usr/bin/env rust-script
|
|
|
|
//! Simple test script to verify HyperBFT core functionality
|
|
//! Run with: cargo run --bin test_hyper_bft
|
|
|
|
use hyper_bft::blockchain::{HyperValidator, ValidatorConfig, Transaction, NetworkConfig};
|
|
use std::time::Duration;
|
|
|
|
#[tokio::main]
|
|
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|
println!("🧪 Testing HyperBFT Core Functionality");
|
|
println!("=====================================");
|
|
|
|
// Create a simple validator configuration
|
|
let config = ValidatorConfig {
|
|
validator_id: "test_validator".to_string(),
|
|
private_key: "test_key".to_string(),
|
|
validators: vec!["test_validator".to_string()],
|
|
network: NetworkConfig {
|
|
chain_id: 9999,
|
|
genesis_hash: String::new(),
|
|
block_time_ms: 400,
|
|
max_block_size: 1_000_000,
|
|
target_tps: 1000,
|
|
},
|
|
consensus: Default::default(),
|
|
block_interval: Duration::from_millis(400),
|
|
batch_size: 100,
|
|
metrics_enabled: false, // Disable metrics to avoid heavy dependencies
|
|
rpc_port: 9999,
|
|
};
|
|
|
|
println!("✅ Validator config created");
|
|
|
|
// Create validator
|
|
let mut validator = HyperValidator::new(config);
|
|
println!("✅ HyperValidator instance created");
|
|
|
|
// Start validator
|
|
validator.start().await?;
|
|
println!("✅ Validator started successfully");
|
|
|
|
// Get status
|
|
let status = validator.get_status();
|
|
println!("✅ Validator status: ID={}, Height={}, Running={}",
|
|
status.validator_id,
|
|
status.current_height,
|
|
status.is_running
|
|
);
|
|
|
|
// Submit a test transaction
|
|
let tx = Transaction::new("alice".to_string(), "bob".to_string(), 1000, 10);
|
|
validator.submit_transaction(tx).await?;
|
|
println!("✅ Test transaction submitted");
|
|
|
|
// Stop validator
|
|
validator.stop().await?;
|
|
println!("✅ Validator stopped successfully");
|
|
|
|
println!("\n🎉 HyperBFT Core Test PASSED!");
|
|
println!("All basic functionality is working correctly.");
|
|
|
|
Ok(())
|
|
} |