use foundry_test_utils::util::ExtTester;

// Actively maintained tests
// Last updated: April 29th 2026

// <https://github.com/foundry-rs/forge-std>
#[test]
fn forge_std() {
    ExtTester::new("foundry-rs", "forge-std", "8987040ede9553cea20c95ad40d0455930f9c8e0")
        // Skip fork tests.
        .args(["--nmc", "Fork"])
        .verbosity(2)
        .run();
}

// <https://github.com/PaulRBerg/prb-math>
#[test]
#[cfg_attr(windows, ignore = "Windows cannot find installed programs")]
fn prb_math() {
    ExtTester::new("PaulRBerg", "prb-math", "82e5ed5561d0a1c43a3a59edbf4291c8de26479e")
        .install_command(&["bun", "install", "--prefer-offline"])
        // Try npm if bun fails / is not installed.
        .install_command(&["npm", "install", "--prefer-offline"])
        .run();
}

// <https://github.com/PaulRBerg/prb-proxy>
#[test]
#[cfg_attr(windows, ignore = "Windows cannot find installed programs")]
fn prb_proxy() {
    ExtTester::new("PaulRBerg", "prb-proxy", "e45f5325d4b6003227a6c4bdaefac9453f89de2e")
        .install_command(&["bun", "install", "--prefer-offline"])
        // Try npm if bun fails / is not installed.
        .install_command(&["npm", "install", "--prefer-offline"])
        .run();
}

// <https://github.com/sablier-labs/v2-core>
#[test]
#[cfg_attr(windows, ignore = "Windows cannot find installed programs")]
fn sablier_v2_core() {
    let mut tester =
        ExtTester::new("sablier-labs", "v2-core", "8b6823c019ff7556ac9ad24cbb5ac62821854d2f")
            // Skip fork tests.
            .args(["--nmc", "Fork"])
            // Increase the gas limit: https://github.com/sablier-labs/v2-core/issues/956
            .args(["--gas-limit", &u64::MAX.to_string()])
            // Run tests without optimizations.
            .env("FOUNDRY_PROFILE", "lite")
            .install_command(&["bun", "install", "--prefer-offline"])
            // Try npm if bun fails / is not installed.
            .install_command(&["npm", "install", "--prefer-offline"])
            .verbosity(2);

    // This test reverts due to memory limit without isolation. This revert is not reached with
    // isolation because memory is divided between separate EVMs created by inner calls.
    tester = tester.args(["--nmt", "test_RevertWhen_LoopCalculationOverflowsBlockGasLimit"]);

    tester.run();
}

// <https://github.com/Vectorized/solady>
#[test]
fn solady() {
    let mut tester =
        ExtTester::new("Vectorized", "solady", "90db92ce173856605d24a554969f2c67cadbc7e9");

    // This test expects the mover contract created via CREATE2 to be selfdestructed within the
    // same transaction. In isolation mode, each top-level call runs as a separate transaction
    // context, so the selfdestruct doesn't clear the code as expected by the test.
    tester = tester.args(["--nmt", "testSafeMoveETHViaMover"]);

    tester.run();
}

// <https://github.com/pcaversaccio/snekmate>
#[test]
#[cfg_attr(windows, ignore = "Windows cannot find installed programs")]
fn snekmate() {
    ExtTester::new("pcaversaccio", "snekmate", "df2816d6a5ecdb8dcc1257e22089422825fd5e27")
        .fuzz_runs(256)
        .python_package("git+https://github.com/vyperlang/vyper@v0.5.0a3")
        .install_command(&["pnpm", "install", "--prefer-offline"])
        // Try npm if pnpm fails / is not installed.
        .install_command(&["npm", "install", "--prefer-offline"])
        .run();
}

// <https://github.com/mds1/multicall>
#[test]
fn mds1_multicall3() {
    ExtTester::new("mds1", "multicall", "b667d67ecfa5361a81e8f110234ce242613b0012").run();
}

// Legacy tests

// <https://github.com/Arachnid/solidity-stringutils>
#[test]
fn solidity_stringutils() {
    ExtTester::new("Arachnid", "solidity-stringutils", "4b2fcc43fa0426e19ce88b1f1ec16f5903a2e461")
        .run();
}

// <https://github.com/m1guelpf/lil-web3>
#[test]
fn lil_web3() {
    ExtTester::new("m1guelpf", "lil-web3", "7346bd28c2586da3b07102d5290175a276949b15").run();
}

// <https://github.com/makerdao/multicall>
#[test]
fn makerdao_multicall() {
    ExtTester::new("makerdao", "multicall", "103a8a28e4e372d582d6539b30031bda4cd48e21").run();
}

// Legacy forking tests

// <https://github.com/hexonaut/guni-lev>
#[test]
fn gunilev() {
    ExtTester::new("hexonaut", "guni-lev", "15ee8b4c2d28e553c5cd5ba9a2a274af97563bc4")
        .fork_block(13633752)
        .run();
}

// <https://github.com/mds1/convex-shutdown-simulation>
#[test]
fn convex_shutdown_simulation() {
    ExtTester::new(
        "mds1",
        "convex-shutdown-simulation",
        "2537cdebce4396753225c5e616c8e00547d2fcea",
    )
    .fork_block(14445961)
    .run();
}
