Skip to content

Commit 1eb89a4

Browse files
committed
fix jest config for tests
Signed-off-by: MarcoMandar <malicemandar@gmail.com>
1 parent c56950f commit 1eb89a4

File tree

2 files changed

+121
-14
lines changed

2 files changed

+121
-14
lines changed

core/jest.config.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
export default {
33
preset: "ts-jest",
44
testEnvironment: "node",
5-
rootDir: "./src",
5+
rootDir: "./",
66
testMatch: ["**/*.test.ts"],
7-
setupFilesAfterEnv: ["<rootDir>/test_resources/testSetup.ts"],
7+
setupFilesAfterEnv: ["<rootDir>/src/test_resources/testSetup.ts"],
88
testTimeout: 120000,
99
globals: {
1010
__DEV__: true,
@@ -23,4 +23,4 @@ export default {
2323
"^(\\.{1,2}/.*)\\.js$": "$1",
2424
},
2525
extensionsToTreatAsEsm: [".ts"],
26-
}
26+
};

core/tests/token.test.ts

+118-11
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,9 @@ jest.mock("fs");
88
jest.mock("node-cache");
99

1010
describe("TokenProvider Tests", () => {
11-
// let connection: Connection;
1211
let tokenProvider: TokenProvider;
1312

1413
beforeEach(() => {
15-
// Initialize the connection and token provider before each test
16-
// connection = new Connection("https://api.mainnet-beta.solana.com");
1714
tokenProvider = new TokenProvider(
1815
"2weMjPLLybRMMva1fM3U31goWWrCpF59CHWNhnCJ9Vyh"
1916
);
@@ -28,12 +25,123 @@ describe("TokenProvider Tests", () => {
2825
const mockFetchResponse = {
2926
success: true,
3027
data: {
31-
ownerBalance: "100",
32-
creatorBalance: "50",
33-
ownerPercentage: 10,
34-
creatorPercentage: 5,
35-
top10HolderBalance: "200",
36-
top10HolderPercent: 20,
28+
// Security Data
29+
security: {
30+
ownerBalance: "1000",
31+
creatorBalance: "500",
32+
ownerPercentage: 10, // Represents 10%
33+
creatorPercentage: 5, // Represents 5%
34+
top10HolderBalance: "2000",
35+
top10HolderPercent: 20, // Represents 20%
36+
},
37+
// Trade Data
38+
tradeData: {
39+
holder: 1500,
40+
unique_wallet_24h: 120,
41+
price_change_24h_percent: 4.5, // 4.5%
42+
price_change_12h_percent: 2.3, // 2.3%
43+
volume_24h_usd: "75000.50", // String representation for consistency
44+
price: "2.50", // Current price in USD as a string
45+
// Add additional trade-related fields if necessary
46+
},
47+
// Holder Distribution Trend
48+
holderDistributionTrend: "increasing", // Possible values: 'increasing', 'decreasing', 'stable'
49+
// High-Value Holders
50+
highValueHolders: [
51+
{
52+
holderAddress: "0xHolderAddress1",
53+
balanceUsd: "6000.00",
54+
},
55+
{
56+
holderAddress: "0xHolderAddress2",
57+
balanceUsd: "5500.00",
58+
},
59+
// Add more high-value holders as needed
60+
],
61+
// Recent Trades Indicator
62+
recentTrades: true, // Indicates whether there have been recent trades in the last 24 hours
63+
// High-Supply Holders Count
64+
highSupplyHoldersCount: 15, // Number of holders holding more than 2% of the total supply
65+
// DexScreener Data
66+
dexScreenerData: {
67+
schemaVersion: "1.0",
68+
pairs: [
69+
{
70+
chainId: "1", // Example Chain ID (e.g., Ethereum Mainnet)
71+
dexId: "Uniswap", // Decentralized Exchange Identifier
72+
url: "https://uniswap.org", // URL to the DEX
73+
pairAddress: "0xPairAddress1",
74+
baseToken: {
75+
address: "0xBaseTokenAddress1",
76+
name: "Base Token Name",
77+
symbol: "BASE",
78+
},
79+
quoteToken: {
80+
address: "0xQuoteTokenAddress1",
81+
name: "Quote Token Name",
82+
symbol: "QUOTE",
83+
},
84+
priceNative: "0.002", // Price in native blockchain currency (e.g., ETH)
85+
priceUsd: "2.50", // Price in USD as a string
86+
txns: {
87+
m5: { buys: 15, sells: 10 }, // Transactions in the last 5 minutes
88+
h1: { buys: 60, sells: 45 }, // Transactions in the last hour
89+
h6: { buys: 300, sells: 270 }, // Transactions in the last 6 hours
90+
h24: { buys: 1200, sells: 1100 }, // Transactions in the last 24 hours
91+
},
92+
volume: {
93+
h24: 50000, // Volume in the last 24 hours in USD
94+
h6: 30000, // Volume in the last 6 hours in USD
95+
h1: 15000, // Volume in the last hour in USD
96+
m5: 5000, // Volume in the last 5 minutes in USD
97+
},
98+
priceChange: {
99+
m5: 0.5, // Price change in the last 5 minutes
100+
h1: 1.2, // Price change in the last hour
101+
h6: 3.5, // Price change in the last 6 hours
102+
h24: 5.0, // Price change in the last 24 hours
103+
},
104+
liquidity: {
105+
usd: 1000000, // Liquidity in USD
106+
base: 500000, // Liquidity in base token
107+
quote: 500000, // Liquidity in quote token
108+
},
109+
fdv: 2000000, // Fully Diluted Valuation in USD
110+
marketCap: 1500000, // Market Capitalization in USD
111+
pairCreatedAt: 1633036800, // Unix timestamp for pair creation
112+
info: {
113+
imageUrl: "https://example.com/image.png", // URL to the pair's image
114+
websites: [
115+
{
116+
label: "Official Website",
117+
url: "https://example.com",
118+
},
119+
{
120+
label: "Documentation",
121+
url: "https://docs.example.com",
122+
},
123+
],
124+
socials: [
125+
{
126+
type: "Twitter",
127+
url: "https://twitter.com/example",
128+
},
129+
{
130+
type: "Discord",
131+
url: "https://discord.gg/example",
132+
},
133+
],
134+
},
135+
boosts: {
136+
active: 2, // Number of active boosts
137+
},
138+
},
139+
// Add more DexScreenerPair objects as needed
140+
],
141+
},
142+
// DexScreener Listing Status
143+
isDexScreenerListed: true, // Indicates if the token is listed on DexScreener
144+
isDexScreenerPaid: false, // Indicates if the listing on DexScreener is paid
37145
},
38146
};
39147

@@ -67,8 +175,7 @@ describe("TokenProvider Tests", () => {
67175
// const dexScreenerData = await tokenProvider.fetchDexScreenerData();
68176
// console.log({ dexScreenerData });
69177

70-
const tokenReport =
71-
await tokenProvider.getFormattedTokenReport(runtime);
178+
const tokenReport = await tokenProvider.getFormattedTokenReport();
72179
console.log({ tokenReport });
73180

74181
// Ensure the mock was called

0 commit comments

Comments
 (0)