use {
    super::SvmContext, solana_keypair::Keypair as SolanaKeypair,
    solana_signer::Signer,
};

pub const PAYER_NAME: &str = "payer";
pub const AUTHORITY_NAME: &str = "authority";
pub const NEW_AUTHORITY_NAME: &str = "new_authority";
pub const MALICIOUS_ACTOR_NAME: &str = "malicious_actor";
pub const VALIDATOR_NAME: &str = "validator";
pub const WITHDRAWER_NAME: &str = "withdrawer";

pub fn setup_actors(context: &mut SvmContext) {
    setup_new_actor(context, PAYER_NAME);
    setup_new_actor(context, AUTHORITY_NAME);
    setup_new_actor(context, NEW_AUTHORITY_NAME);
    setup_new_actor(context, VALIDATOR_NAME);
    setup_new_actor(context, WITHDRAWER_NAME);
    setup_new_actor(context, MALICIOUS_ACTOR_NAME);
}

pub fn setup_new_actor(context: &mut SvmContext, name: &str) {
    setup_new_actor_with_amount(context, name, 10_000_000_000);
}

pub fn setup_new_actor_with_amount(
    context: &mut SvmContext,
    name: &str,
    amount: u64,
) {
    let keypair = SolanaKeypair::new();
    let pubkey = keypair.pubkey();
    context.add_actor(name, keypair);
    context
        .svm
        .airdrop(&pubkey, amount) // Default to 10 SOL
        .unwrap();
}
