magicsvm 0.2.0

A fast and lightweight Solana + MagicBlock VM simulator for testing solana programs
//! Tests for the de-forked STOCK public account boundary

use {
    magicsvm::MagicSVM, solana_account::Account, solana_keypair::Keypair,
    solana_native_token::LAMPORTS_PER_SOL, solana_signer::Signer,
};

/// A stock `solana_account::Account` set on the SVM must come back as a stock
/// account with identical fields, proving the public boundary is stock.
#[test]
fn set_and_get_account_round_trips_stock() {
    let mut svm = MagicSVM::new();
    let key = Keypair::new();
    let account = Account {
        lamports: 5 * LAMPORTS_PER_SOL,
        data: vec![1, 2, 3, 4],
        owner: solana_sdk_ids::system_program::id(),
        executable: false,
        rent_epoch: 7,
    };

    svm.set_account(key.pubkey(), account.clone()).unwrap();

    // Return type is the STOCK `solana_account::Account`.
    let fetched: Account = svm.get_account(&key.pubkey()).unwrap();
    assert_eq!(fetched.lamports, account.lamports);
    assert_eq!(fetched.data, account.data);
    assert_eq!(fetched.owner, account.owner);
    assert_eq!(fetched.executable, account.executable);
    // Note: litesvm normalizes rent_epoch for rent-exempt accounts, so we don't
    // assert on it here; the round-trip of the remaining fields is what proves
    // the stock boundary.
}