//! Integration tests for the public surface of `dynamic_waas_sdk::mpc_config`.
//!
//! Lives outside the source file because the source file holds the
//! Evervault relay-key constants (committed by design — every SDK in
//! the repo, python + node + rust, ships the same values; they're
//! per-environment relay identifiers, not customer secrets). Keeping
//! these tests separate means routine test edits don't trigger the
//! repo's pre-commit secret scanner against the diff context of the
//! constants file.

use dynamic_waas_sdk::mpc_config::{
    keyshares_relay_url_for, relay_api_key_for, relay_app_id_for, EVM_DERIVATION_PATH,
    PREPROD_KEYSHARES_RELAY_URL, PREPROD_RELAY_API_KEY, PREPROD_RELAY_APP_ID,
    PROD_KEYSHARES_RELAY_URL, PROD_RELAY_API_KEY, PROD_RELAY_APP_ID, SVM_DERIVATION_PATH,
};
use dynamic_waas_sdk::Environment;

#[test]
fn evm_derivation_path_is_bip44_60() {
    // BIP-44: m/44'/60'/0'/0/0 — 60 is Ethereum SLIP-0044
    assert_eq!(EVM_DERIVATION_PATH, &[44, 60, 0, 0, 0]);
}

#[test]
fn svm_derivation_path_is_bip44_501() {
    // BIP-44: m/44'/501'/0'/0/0 — 501 is Solana SLIP-0044
    assert_eq!(SVM_DERIVATION_PATH, &[44, 501, 0, 0, 0]);
}

#[test]
fn relay_app_id_per_env() {
    assert_eq!(
        relay_app_id_for(Environment::Production),
        Some(PROD_RELAY_APP_ID)
    );
    assert_eq!(
        relay_app_id_for(Environment::Preprod),
        Some(PREPROD_RELAY_APP_ID)
    );
    assert_eq!(relay_app_id_for(Environment::Development), None);
}

#[test]
fn relay_api_key_per_env() {
    // Note: we compare reference identity via Some/None, not reproduce
    // the literal strings here — keeps the test file scrub-friendly.
    assert!(relay_api_key_for(Environment::Production).is_some());
    assert!(relay_api_key_for(Environment::Preprod).is_some());
    assert_eq!(relay_api_key_for(Environment::Development), None);
    assert_ne!(
        relay_api_key_for(Environment::Production),
        relay_api_key_for(Environment::Preprod),
    );
}

#[test]
fn keyshares_relay_url_prod() {
    assert_eq!(
        keyshares_relay_url_for(Environment::Production),
        PROD_KEYSHARES_RELAY_URL,
    );
}

#[test]
fn keyshares_relay_url_non_prod_falls_back_to_preprod() {
    // Non-production envs all resolve to the preprod relay (preprod is
    // the wildcard match in the function).
    for env in [Environment::Preprod, Environment::Development] {
        assert_eq!(keyshares_relay_url_for(env), PREPROD_KEYSHARES_RELAY_URL);
    }
}

#[test]
fn relay_api_keys_distinct_and_present() {
    // sanity-check the constants didn't get accidentally truncated.
    // Using length-and-distinctness checks rather than reproducing the
    // values keeps this test out of the secret-scanner's path.
    assert!(PREPROD_RELAY_API_KEY.len() > 16);
    assert!(PROD_RELAY_API_KEY.len() > 16);
    assert_ne!(PREPROD_RELAY_API_KEY, PROD_RELAY_API_KEY);
}

#[test]
fn relay_app_ids_distinct() {
    assert_ne!(PREPROD_RELAY_APP_ID, PROD_RELAY_APP_ID);
    assert!(PREPROD_RELAY_APP_ID.starts_with("app_"));
    assert!(PROD_RELAY_APP_ID.starts_with("app_"));
}
