#![allow(
    clippy::allow_attributes,
    clippy::allow_attributes_without_reason,
    clippy::unwrap_used,
    clippy::expect_used,
    clippy::panic,
    clippy::arithmetic_side_effects
)]

use pyra_accounts::*;
use pyra_tokens::{AssetId, SUPPORTED_TOKENS};
use solana_pubkey::{pubkey, Pubkey};

const OWNER: Pubkey = pubkey!("5DXPwzc9VurVGVZfpet9bbaL7XQvFSVz5AKQo7z11r4");

#[test]
fn test_get_vault() {
    let vault = get_vault(&OWNER);
    assert_eq!(
        vault,
        pubkey!("75eLjyjszgrpqqL4udoyyRS57J1m6zKqSQ5EUm4Dgrjf")
    );
}

#[test]
fn test_get_deposit_address() {
    let deposit_address = get_deposit_address(&OWNER);
    assert_eq!(
        deposit_address,
        pubkey!("HkpWHP7wuF6wYKKPEgNk35mL5hoG4LStfcFRnU4ur2oz")
    );
}

#[test]
fn test_get_send_hold() {
    let send_hold = get_spend_hold();
    assert_eq!(
        send_hold,
        pubkey!("CaMDMNNVqfqEJzALZ5TtMH19fTfhSnnXSW9EgCyJUGP")
    );
}

#[test]
fn test_get_swap_ledger() {
    // USDC
    let swap_ledger = get_swap_ledger(&SUPPORTED_TOKENS[0].mint);
    assert_eq!(
        swap_ledger,
        pubkey!("5TkaghhdPNyNjJ6ucyFik25dWPgNx4SNzMZ9MShDJ7qu")
    );

    // wSOL
    let swap_ledger = get_swap_ledger(&SUPPORTED_TOKENS[1].mint);
    assert_eq!(
        swap_ledger,
        pubkey!("7EGL54SwicuLda36Pjg7ih5pBCj6gG7MAHDgJyizAvH3")
    );
}

#[test]
fn test_get_drift_user() {
    let drift_user = get_drift_user(&OWNER, 0);
    assert_eq!(
        drift_user,
        pubkey!("4fmAhVBhpQdbSc9SLhHvxxYRoxfWw9s2fUZq44vyfFTg")
    );
}

#[test]
fn test_get_drift_user_stats() {
    let drift_user_stats = get_drift_user_stats(&OWNER);
    assert_eq!(
        drift_user_stats,
        pubkey!("5ZLpBrU2z3QL4CgZxmyYg8Zv8skJ82gP2v27fprMdcJs")
    );
}

#[test]
fn test_get_drift_state() {
    let drift_state = get_drift_state();
    assert_eq!(
        drift_state,
        pubkey!("5zpq7DvB6UdFFvpmBPspGPNfUGoBRRCE2HHg5u3gxcsN")
    );
}

#[test]
fn test_get_drift_signer() {
    let drift_signer = get_drift_signer();
    assert_eq!(
        drift_signer,
        pubkey!("JCNCMFXo5M5qwUPg2Utu1u6YWp3MbygxqBsBeXXJfrw")
    );
}

#[test]
fn test_get_drift_spot_market_vault() {
    // USDC (asset_id 0)
    let vault = get_drift_spot_market_vault(AssetId::USDC).unwrap();
    assert_eq!(
        vault,
        pubkey!("GXWqPpjQpdz7KZw9p7f5PX2eGxHAhvpNXiviFkAB8zXg")
    );

    // wSOL (asset_id 1)
    let vault = get_drift_spot_market_vault(AssetId::WSOL).unwrap();
    assert_eq!(
        vault,
        pubkey!("DfYCNezifxAEsQbAJ1b3j6PX3JVBe8fu11KBhxsbw5d2")
    );
}

#[test]
fn test_get_drift_spot_market() {
    // USDC (asset_id 0)
    let market = get_drift_spot_market(AssetId::USDC).unwrap();
    assert_eq!(
        market,
        pubkey!("6gMq3mRCKf8aP3ttTyYhuijVZ2LGi14oDsBbkgubfLB3")
    );

    // wSOL (asset_id 1)
    let market = get_drift_spot_market(AssetId::WSOL).unwrap();
    assert_eq!(
        market,
        pubkey!("3x85u7SWkmmr7YQGYhtjARgxwegTLJgkSLRprfXod6rh")
    );
}

// --- Kamino PDAs ---

const DUMMY_MARKET: Pubkey = pubkey!("5wJeMrUYECGq41fxRESKALVcHnNX26TAWy4W98yULsua");
const DUMMY_RESERVE: Pubkey = pubkey!("d4A2prbA2nCUQNB76kBasQ2toVbEBY2Mfr4MnUQKust");

#[test]
fn test_get_kamino_lending_market_authority() {
    let authority = get_kamino_lending_market_authority(&DUMMY_MARKET);
    assert_eq!(
        authority,
        pubkey!("2Z7zhqp1eddmHNmEqexftST6DFPWmoL4QqfgiG5uJMJx")
    );
}

#[test]
fn test_get_kamino_obligation() {
    let obligation = get_kamino_obligation(&OWNER, &DUMMY_MARKET);
    assert_eq!(
        obligation,
        pubkey!("5eYqX327jmBdKJpCxShNVtRhe3nRhab69nxJKNe8TiBs")
    );
}

#[test]
fn test_get_kamino_user_metadata() {
    let user_metadata = get_kamino_user_metadata(&OWNER);
    assert_eq!(
        user_metadata,
        pubkey!("2oTFsSMZyWPKP7mDUQBwekeVMHS2cCAeQTRxez7jMDhW")
    );
}

#[test]
fn test_get_kamino_reserve_fee_vault() {
    let fee_vault = get_kamino_reserve_fee_vault(&DUMMY_RESERVE);
    assert_eq!(
        fee_vault,
        pubkey!("CPbHibpya6J2bEzy1XoDbNYKZVAv6gria1Pn7Sm4soxa")
    );
}

#[test]
fn test_get_kamino_owner_queued_collateral_vault() {
    let vault = get_kamino_owner_queued_collateral_vault(&OWNER, &DUMMY_RESERVE);
    assert_eq!(
        vault,
        pubkey!("6eTLk8BFvrCMfyW9ovGLK57iLAtz4Br8tBRXaeivXzou")
    );
}

#[test]
fn test_get_kamino_withdraw_ticket() {
    let ticket = get_kamino_withdraw_ticket(&DUMMY_RESERVE, 42);
    assert_eq!(
        ticket,
        pubkey!("FepLHWn5JcyAftVkFhBvxMx9Nsr1R4n4LFD6MtxssQg8")
    );
}
