diff --git a/core/jest.config.js b/core/jest.config.js index 9d609fa6785..46684bcb9bc 100644 --- a/core/jest.config.js +++ b/core/jest.config.js @@ -2,9 +2,9 @@ export default { preset: "ts-jest", testEnvironment: "node", - rootDir: "./src", + rootDir: "./", testMatch: ["**/*.test.ts"], - setupFilesAfterEnv: ["/test_resources/testSetup.ts"], + setupFilesAfterEnv: ["/src/test_resources/testSetup.ts"], testTimeout: 120000, globals: { __DEV__: true, @@ -23,4 +23,4 @@ export default { "^(\\.{1,2}/.*)\\.js$": "$1", }, extensionsToTreatAsEsm: [".ts"], -} +}; diff --git a/core/tests/token.test.ts b/core/tests/token.test.ts index 46abfe6f8a1..9f6edf8b969 100644 --- a/core/tests/token.test.ts +++ b/core/tests/token.test.ts @@ -8,12 +8,9 @@ jest.mock("fs"); jest.mock("node-cache"); describe("TokenProvider Tests", () => { - // let connection: Connection; let tokenProvider: TokenProvider; beforeEach(() => { - // Initialize the connection and token provider before each test - // connection = new Connection("https://api.mainnet-beta.solana.com"); tokenProvider = new TokenProvider( "2weMjPLLybRMMva1fM3U31goWWrCpF59CHWNhnCJ9Vyh" ); @@ -28,12 +25,123 @@ describe("TokenProvider Tests", () => { const mockFetchResponse = { success: true, data: { - ownerBalance: "100", - creatorBalance: "50", - ownerPercentage: 10, - creatorPercentage: 5, - top10HolderBalance: "200", - top10HolderPercent: 20, + // Security Data + security: { + ownerBalance: "1000", + creatorBalance: "500", + ownerPercentage: 10, // Represents 10% + creatorPercentage: 5, // Represents 5% + top10HolderBalance: "2000", + top10HolderPercent: 20, // Represents 20% + }, + // Trade Data + tradeData: { + holder: 1500, + unique_wallet_24h: 120, + price_change_24h_percent: 4.5, // 4.5% + price_change_12h_percent: 2.3, // 2.3% + volume_24h_usd: "75000.50", // String representation for consistency + price: "2.50", // Current price in USD as a string + // Add additional trade-related fields if necessary + }, + // Holder Distribution Trend + holderDistributionTrend: "increasing", // Possible values: 'increasing', 'decreasing', 'stable' + // High-Value Holders + highValueHolders: [ + { + holderAddress: "0xHolderAddress1", + balanceUsd: "6000.00", + }, + { + holderAddress: "0xHolderAddress2", + balanceUsd: "5500.00", + }, + // Add more high-value holders as needed + ], + // Recent Trades Indicator + recentTrades: true, // Indicates whether there have been recent trades in the last 24 hours + // High-Supply Holders Count + highSupplyHoldersCount: 15, // Number of holders holding more than 2% of the total supply + // DexScreener Data + dexScreenerData: { + schemaVersion: "1.0", + pairs: [ + { + chainId: "1", // Example Chain ID (e.g., Ethereum Mainnet) + dexId: "Uniswap", // Decentralized Exchange Identifier + url: "https://uniswap.org", // URL to the DEX + pairAddress: "0xPairAddress1", + baseToken: { + address: "0xBaseTokenAddress1", + name: "Base Token Name", + symbol: "BASE", + }, + quoteToken: { + address: "0xQuoteTokenAddress1", + name: "Quote Token Name", + symbol: "QUOTE", + }, + priceNative: "0.002", // Price in native blockchain currency (e.g., ETH) + priceUsd: "2.50", // Price in USD as a string + txns: { + m5: { buys: 15, sells: 10 }, // Transactions in the last 5 minutes + h1: { buys: 60, sells: 45 }, // Transactions in the last hour + h6: { buys: 300, sells: 270 }, // Transactions in the last 6 hours + h24: { buys: 1200, sells: 1100 }, // Transactions in the last 24 hours + }, + volume: { + h24: 50000, // Volume in the last 24 hours in USD + h6: 30000, // Volume in the last 6 hours in USD + h1: 15000, // Volume in the last hour in USD + m5: 5000, // Volume in the last 5 minutes in USD + }, + priceChange: { + m5: 0.5, // Price change in the last 5 minutes + h1: 1.2, // Price change in the last hour + h6: 3.5, // Price change in the last 6 hours + h24: 5.0, // Price change in the last 24 hours + }, + liquidity: { + usd: 1000000, // Liquidity in USD + base: 500000, // Liquidity in base token + quote: 500000, // Liquidity in quote token + }, + fdv: 2000000, // Fully Diluted Valuation in USD + marketCap: 1500000, // Market Capitalization in USD + pairCreatedAt: 1633036800, // Unix timestamp for pair creation + info: { + imageUrl: "https://example.com/image.png", // URL to the pair's image + websites: [ + { + label: "Official Website", + url: "https://example.com", + }, + { + label: "Documentation", + url: "https://docs.example.com", + }, + ], + socials: [ + { + type: "Twitter", + url: "https://twitter.com/example", + }, + { + type: "Discord", + url: "https://discord.gg/example", + }, + ], + }, + boosts: { + active: 2, // Number of active boosts + }, + }, + // Add more DexScreenerPair objects as needed + ], + }, + // DexScreener Listing Status + isDexScreenerListed: true, // Indicates if the token is listed on DexScreener + isDexScreenerPaid: false, // Indicates if the listing on DexScreener is paid }, }; @@ -67,8 +175,7 @@ describe("TokenProvider Tests", () => { // const dexScreenerData = await tokenProvider.fetchDexScreenerData(); // console.log({ dexScreenerData }); - const tokenReport = - await tokenProvider.getFormattedTokenReport(runtime); + const tokenReport = await tokenProvider.getFormattedTokenReport(); console.log({ tokenReport }); // Ensure the mock was called