import {before, describe, it} from 'node:test'
import assert from 'node:assert'
import {getClientForAddress, swapGmxTokensImpl} from '../../src/plugins/custom/gmx.js'
import {Ticker} from '../../src/generated/ManagingApiTypes'

describe('swap tokens implementation', () => {
  let sdk: any

  before(async () => {
    // Initialize the SDK with a test account
    const testAccount = '0xbba4eaa534cbd0ecaed5e2fd6036aec2e7ee309f'
    sdk = await getClientForAddress(testAccount)
  })

  it('should swap USDC to ETH successfully', async () => {
    try {
      const result = await swapGmxTokensImpl(
        sdk,
        Ticker.BTC,  // fromTicker
        Ticker.USDC,   // toTicker   
        0.000056     // amount
      )
      
      assert.strictEqual(typeof result, 'string')
      assert.strictEqual(result, 'swap_order_created')
    } catch (error) {
      // Test that the error is related to actual execution rather than parameter validation
      assert.ok(error instanceof Error)
      console.log('Expected error during test execution:', error.message)
    }
  })
})
