import { supabaseService } from '../src/services/SupabaseService.js';
import { loadDynamicConfig, config } from '../src/config/index.js';
import logger from '../src/utils/logger.js';

async function testDynamicConfigLoading() {
    logger.info('--- Testing Dynamic Config Loading from Supabase ---');

    // 1. Initial State (from .env)
    const initialSymbols = [...config.SYMBOLS];
    logger.info(`Initial Symbols (.env): ${initialSymbols.join(', ')}`);

    // 2. Load from DB
    await loadDynamicConfig(supabaseService);

    // 3. Final State
    logger.info(`Final Symbols (After DB Load): ${config.SYMBOLS.join(', ')}`);

    if (JSON.stringify(initialSymbols) !== JSON.stringify(config.SYMBOLS)) {
        logger.info('✅ SUCCESS: Dynamic config successfully overwrote .env defaults!');
    } else {
        logger.info('ℹ️  INFO: config.SYMBOLS remained the same. This is normal if DB matches .env or if DB was empty.');
    }

    // Check other keys if present
    logger.info(`Execution Provider: ${config.EXECUTION_PROVIDER}`);
    logger.info(`Total Capital: ${config.TOTAL_CAPITAL}`);
}

testDynamicConfigLoading().catch(console.error);
