import {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.js'

describe('swap tokens implementation', () => {

  it('should swap SOL to USDC successfully', async () => {
    try {
      const testAccount = '0x932167388dD9aad41149b3cA23eBD489E2E2DD78'
      const sdk = await getClientForAddress(testAccount)

      console.log('Account', sdk.account)
        const result = await swapGmxTokensImpl(
          sdk,
          Ticker.ETH,  
          Ticker.USDC,   
          0.0042 
        )
      
      assert.strictEqual(typeof result, 'string')
      assert.strictEqual(result, 'swap_order_created')
    } catch (error) {
      console.log('error', error)

      // Test that the error is related to actual execution rather than parameter validation
      assert.fail(error.message)
    }
  })
})
