UNPKG

python-proxy-scraper-client

Version:

A TypeScript client for interacting with a Python proxy scraper service

176 lines (175 loc) 10.9 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); /// <reference types="jest" /> const geckoterminal_api_client_1 = require("./geckoterminal-api-client"); const testCases = [ { network: 'eth', tokenAddress: '0x43C5034469bCe262d32F64C5e7f9F359f5B1495F', poolAddress: '0x5D6B5238809077AB58744eC30401fC142dfb9E73' }, { network: 'solana', tokenAddress: 'HAUWqZTnQNhSqC3AG4GYtuoqTZMi3ywvgqWMyKC7pump', poolAddress: 'DsTLvcheqvYEygnzSdNk9qTnhik8hPMLCnZ6hz8aa9QR' }, { network: 'base', tokenAddress: '0x3ec2156D4c0A9CBdAB4a016633b7BcF6a8d68Ea2', poolAddress: '0x5116773e18A9C7bB03EBB961b38678E45E238923' } ]; describe('GeckoTerminal API Tests', () => { testCases.forEach(({ network, tokenAddress, poolAddress }) => { describe(`${network} network tests`, () => { describe('getTrades', () => { test.concurrent('should return trades with correct structure', async () => { const client = new geckoterminal_api_client_1.GeckoTerminalApiClient(); const response = await client.getTrades(network, poolAddress); expect(Array.isArray(response)).toBe(true); if (response.length > 0) { const trade = response[0]; expect(trade).toHaveProperty('id'); expect(trade).toHaveProperty('type'); expect(trade).toHaveProperty('attributes'); const attributes = trade.attributes; expect(attributes).toHaveProperty('block_number'); expect(attributes).toHaveProperty('tx_hash'); expect(attributes).toHaveProperty('tx_from_address'); expect(attributes).toHaveProperty('from_token_amount'); expect(attributes).toHaveProperty('to_token_amount'); expect(attributes).toHaveProperty('price_from_in_currency_token'); expect(attributes).toHaveProperty('price_to_in_currency_token'); expect(attributes).toHaveProperty('price_from_in_usd'); expect(attributes).toHaveProperty('price_to_in_usd'); expect(attributes).toHaveProperty('block_timestamp'); expect(attributes).toHaveProperty('kind'); expect(attributes).toHaveProperty('volume_in_usd'); expect(attributes).toHaveProperty('from_token_address'); expect(attributes).toHaveProperty('to_token_address'); } }, 30000); }); describe('getPoolInfo', () => { test.concurrent('should return pool info with correct structure', async () => { const client = new geckoterminal_api_client_1.GeckoTerminalApiClient(); const response = await client.getPoolInfo(network, poolAddress); expect(Array.isArray(response)).toBe(true); if (response.length > 0) { const token = response[0]; expect(token).toHaveProperty('id'); expect(token).toHaveProperty('type'); expect(token).toHaveProperty('attributes'); const attributes = token.attributes; expect(attributes).toHaveProperty('address'); expect(attributes).toHaveProperty('name'); expect(attributes).toHaveProperty('symbol'); expect(attributes).toHaveProperty('decimals'); expect(attributes).toHaveProperty('image_url'); expect(attributes).toHaveProperty('coingecko_coin_id'); expect(attributes).toHaveProperty('websites'); expect(attributes).toHaveProperty('description'); expect(attributes).toHaveProperty('gt_score'); expect(attributes).toHaveProperty('discord_url'); expect(attributes).toHaveProperty('telegram_handle'); expect(attributes).toHaveProperty('twitter_handle'); } }, 30000); }); describe('getTokenPools', () => { test.concurrent('should return token pools with correct structure', async () => { const client = new geckoterminal_api_client_1.GeckoTerminalApiClient(); const response = await client.getTokenPools(network, tokenAddress); expect(Array.isArray(response)).toBe(true); if (response.length > 0) { const pool = response[0]; expect(pool).toHaveProperty('id'); expect(pool).toHaveProperty('type'); expect(pool).toHaveProperty('attributes'); expect(pool).toHaveProperty('relationships'); const attributes = pool.attributes; expect(attributes).toHaveProperty('base_token_price_usd'); expect(attributes).toHaveProperty('base_token_price_native_currency'); expect(attributes).toHaveProperty('quote_token_price_usd'); expect(attributes).toHaveProperty('quote_token_price_native_currency'); expect(attributes).toHaveProperty('base_token_price_quote_token'); expect(attributes).toHaveProperty('quote_token_price_base_token'); expect(attributes).toHaveProperty('address'); expect(attributes).toHaveProperty('name'); expect(attributes).toHaveProperty('pool_created_at'); expect(attributes).toHaveProperty('fdv_usd'); expect(attributes).toHaveProperty('market_cap_usd'); expect(attributes).toHaveProperty('price_change_percentage'); expect(attributes).toHaveProperty('transactions'); expect(attributes).toHaveProperty('volume_usd'); expect(attributes).toHaveProperty('reserve_in_usd'); const relationships = pool.relationships; expect(relationships).toHaveProperty('base_token'); expect(relationships).toHaveProperty('quote_token'); expect(relationships).toHaveProperty('dex'); } }, 30000); }); describe('getTrendingPools', () => { test.concurrent('should return trending pools with correct structure', async () => { const client = new geckoterminal_api_client_1.GeckoTerminalApiClient(); const response = await client.getTrendingPools(network); expect(Array.isArray(response)).toBe(true); if (response.length > 0) { const pool = response[0]; expect(pool).toHaveProperty('id'); expect(pool).toHaveProperty('type'); expect(pool).toHaveProperty('attributes'); expect(pool).toHaveProperty('relationships'); const attributes = pool.attributes; expect(attributes).toHaveProperty('base_token_price_usd'); expect(attributes).toHaveProperty('base_token_price_native_currency'); expect(attributes).toHaveProperty('quote_token_price_usd'); expect(attributes).toHaveProperty('quote_token_price_native_currency'); expect(attributes).toHaveProperty('base_token_price_quote_token'); expect(attributes).toHaveProperty('quote_token_price_base_token'); expect(attributes).toHaveProperty('address'); expect(attributes).toHaveProperty('name'); expect(attributes).toHaveProperty('pool_created_at'); expect(attributes).toHaveProperty('fdv_usd'); expect(attributes).toHaveProperty('market_cap_usd'); expect(attributes).toHaveProperty('price_change_percentage'); expect(attributes).toHaveProperty('transactions'); expect(attributes).toHaveProperty('volume_usd'); expect(attributes).toHaveProperty('reserve_in_usd'); } }, 30000); }); describe('getTokenPrice', () => { test.concurrent('should return token price with correct structure', async () => { const client = new geckoterminal_api_client_1.GeckoTerminalApiClient(); const response = await client.getTokenPrice(network, tokenAddress); expect(response).toHaveProperty('price'); expect(typeof response.price).toBe('number'); }, 30000); }); describe('getTokenDetails', () => { test.concurrent('should return token details with correct structure', async () => { const client = new geckoterminal_api_client_1.GeckoTerminalApiClient(); const response = await client.getTokenDetails(network, tokenAddress); expect(response).toHaveProperty('id'); expect(response).toHaveProperty('type'); expect(response).toHaveProperty('attributes'); expect(response).toHaveProperty('relationships'); const attributes = response.attributes; expect(attributes).toHaveProperty('name'); expect(attributes).toHaveProperty('address'); expect(attributes).toHaveProperty('symbol'); expect(attributes).toHaveProperty('decimals'); expect(attributes).toHaveProperty('total_supply'); expect(attributes).toHaveProperty('coingecko_coin_id'); expect(attributes).toHaveProperty('price_usd'); expect(attributes).toHaveProperty('fdv_usd'); expect(attributes).toHaveProperty('total_reserve_in_usd'); expect(attributes).toHaveProperty('volume_usd'); expect(attributes).toHaveProperty('market_cap_usd'); }, 30000); }); }); }); });