//! Cross-impl conformance for the Handoff trait.
//!
//! The `KvHandoff` is constructed with a registry containing the key used
//! by `run_handoff_conformance` internally (seed `[11u8; 32]`, identity
//! "source-agent"). Both sides share the same signing key so the registry
//! trust check passes.

use ed25519_dalek::SigningKey;
use klieo_bus_memory::MemoryBus;
use klieo_ops::handoff::KvHandoff;
use klieo_ops::test_fixtures::run_handoff_conformance;
use klieo_ops::types::AgentId;
use klieo_ops::{SourceIdentityRegistry, StaticSourceIdentityRegistry};
use std::collections::HashMap;
use std::sync::Arc;

#[tokio::test]
async fn kv_handoff_passes_conformance() {
    let bus = MemoryBus::new();
    // Conformance fixture uses seed [11u8; 32] for the signing key and
    // "source-agent" as the identity. Pre-register that key here.
    let conformance_sk = SigningKey::from_bytes(&[11u8; 32]);
    let mut keys = HashMap::new();
    keys.insert(
        AgentId("source-agent".into()),
        conformance_sk.verifying_key(),
    );
    let registry: Arc<dyn SourceIdentityRegistry> =
        Arc::new(StaticSourceIdentityRegistry::from_map(keys));
    let h = KvHandoff::new(bus.kv.clone(), registry);
    run_handoff_conformance(h).await;
}
