import {test} from 'node:test';
import assert from 'node:assert';
import {getClaimableFundingFeesImpl, getClientForAddress} from '../../src/plugins/custom/gmx.js';

test('GMX Get Claimable Funding Fees', async (t) => {
    const testAccount = '0xbBA4eaA534cbD0EcAed5E2fD6036Aec2E7eE309f';

    await t.test('should get claimable funding fees for valid account', async () => {
        try {
            const sdk = await getClientForAddress(testAccount);
            const result = await getClaimableFundingFeesImpl(sdk);
            
            console.log('Claimable funding fees result:', result);
            assert.ok(typeof result === 'object', 'Result should be an object');
            
            // Check that each market entry has the expected structure
            Object.values(result).forEach(marketData => {
                assert.ok(typeof marketData.claimableFundingAmountLong === 'number', 'Long amount should be a number');
                assert.ok(typeof marketData.claimableFundingAmountShort === 'number', 'Short amount should be a number');
                assert.ok(marketData.claimableFundingAmountLong >= 0, 'Long amount should be non-negative');
                assert.ok(marketData.claimableFundingAmountShort >= 0, 'Short amount should be non-negative');
            });
        } catch (error) {
            console.warn('Expected error in test environment:', error.message);
            // In test environment, this may fail due to network issues or missing data
            assert.ok(error instanceof Error, 'Should throw an Error instance');
        }
    });
}); 