#!/usr/bin/env node

/**
 * Test the drift trading service directly
 */

require('dotenv').config();

async function testDriftService() {
  console.log('🌊 Testing DriftTradingService directly...');
  
  try {
    // Import the service
    const { driftTradingService } = require('./lib/drift-trading.ts');
    
    console.log('📦 Service imported successfully');
    
    // Test login
    console.log('🔐 Testing login...');
    const loginResult = await driftTradingService.login();
    
    console.log('Login result:', JSON.stringify(loginResult, null, 2));
    
    if (loginResult.isLoggedIn) {
      console.log('✅ Login successful! Testing balance...');
      
      try {
        const balance = await driftTradingService.getAccountBalance();
        console.log('💰 Balance:', JSON.stringify(balance, null, 2));
      } catch (e) {
        console.log('⚠️ Balance error:', e.message);
      }
      
      try {
        const positions = await driftTradingService.getPositions();
        console.log('📊 Positions:', positions.length);
      } catch (e) {
        console.log('⚠️ Positions error:', e.message);
      }
    }
    
  } catch (error) {
    console.error('❌ Service test failed:', error.message);
    console.error('Stack:', error.stack);
  }
}

testDriftService().catch(console.error);
