toast-api 0.1.9

An unofficial CLI client and API server for Claude/Deepseek
Documentation
use toast_api::deepseek::{DeepSeekPOW, PowChallenge};
use serde_json::json;

#[test]
fn test_wasm_compatibility() {
    // Create a challenge that matches the exact format WASM would receive
    let challenge_json = json!({
        "algorithm": "sha3_256",
        "challenge": "abc123",
        "salt": "salt123", 
        "difficulty": 0.25,  // 2 zero bits - reasonable for testing
        "expire_at": 1735689600_u64,
        "signature": "sig123",
        "target_path": "/api/v0/chat/completion"
    });
    
    let challenge: PowChallenge = serde_json::from_value(challenge_json).unwrap();
    let pow_solver = DeepSeekPOW::new().unwrap();
    
    // Test multiple times to ensure consistency
    let result1 = pow_solver.solve_challenge(&challenge);
    let result2 = pow_solver.solve_challenge(&challenge);
    
    assert!(result1.is_ok(), "First solve attempt failed: {:?}", result1.err());
    assert!(result2.is_ok(), "Second solve attempt failed: {:?}", result2.err());
    
    // Results should be consistent (deterministic based on challenge content)
    assert_eq!(result1.unwrap(), result2.unwrap(), "Results should be deterministic");
    
    println!("WASM compatibility test passed!");
}