import { rootLogger } from '@hyperlane-xyz/utils';
import { TEST_SVM_CHAIN_METADATA } from '../testing/constants.js';
import { getPreloadedPrograms, } from '../testing/setup.js';
import { runSolanaNode, } from '../testing/solana-container.js';
const SETUP_TIMEOUT_MS = 150_000;
const TESTS_WITHOUT_VALIDATOR = new Set(['read-token']);
const SKIP_VALIDATOR = TESTS_WITHOUT_VALIDATOR.has(process.env.SVM_SDK_E2E_TEST ?? '');
const ALL_PRELOADED_PROGRAMS = [
    'mailbox',
    'igp',
    'testIsm',
    'multisigIsm',
    'validatorAnnounce',
];
let validator;
let programCleanup;
before(async function () {
    if (SKIP_VALIDATOR)
        return;
    this.timeout(SETUP_TIMEOUT_MS);
    rootLogger.info('Preparing SVM programs...');
    const { programs, cleanup } = getPreloadedPrograms(ALL_PRELOADED_PROGRAMS);
    programCleanup = cleanup;
    try {
        rootLogger.info('Starting Solana test validator...');
        validator = await runSolanaNode(TEST_SVM_CHAIN_METADATA, programs);
        rootLogger.info(`Solana test validator started at ${validator.rpcUrl}`);
    }
    catch (error) {
        cleanup();
        throw error;
    }
});
after(async function () {
    if (SKIP_VALIDATOR)
        return;
    this.timeout(SETUP_TIMEOUT_MS);
    if (validator) {
        rootLogger.info('Stopping Solana test validator...');
        await validator.stop();
        rootLogger.info('Solana test validator stopped');
    }
    programCleanup?.();
});
//# sourceMappingURL=e2e-test.setup.js.map