-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: plugin rabbi trader tests #2520
feat: plugin rabbi trader tests #2520
Conversation
Warning There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure. 🔧 eslint
packages/plugin-rabbi-trader/__tests__/dexscreener.test.tsOops! Something went wrong! :( ESLint: 9.18.0 ESLint couldn't find an eslint.config.(js|mjs|cjs) file. From ESLint v9.0.0, the default configuration file is now eslint.config.js. https://eslint.org/docs/latest/use/configure/migration-guide If you still have problems after following the migration guide, please stop by 📝 WalkthroughWalkthroughThis pull request introduces comprehensive test coverage for the Changes
Possibly related issues
Possibly related PRs
Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (6)
packages/plugin-rabbi-trader/__tests__/tokenUtils.test.ts (2)
31-38
: Add test case for empty token addresses array.Consider adding a test case to verify behavior when the JSON file contains an empty array.
it('should handle empty token addresses file', () => { vi.mocked(fs.readFileSync).mockReturnValue('[]'); const addresses = loadTokenAddresses(); expect(addresses).toEqual([]); });
48-52
: Add test case for malformed token addresses.The current test only checks for invalid JSON. Consider adding a test for valid JSON but invalid token address format.
it('should throw error if token addresses are malformed', () => { vi.mocked(fs.readFileSync).mockReturnValue(JSON.stringify([123, "not-an-address"])); expect(() => loadTokenAddresses()).toThrow('Invalid token address format'); });packages/plugin-rabbi-trader/__tests__/wallet.test.ts (1)
87-96
: Add specific error message assertion.The error handling test should verify the specific error message being logged.
const balance = await getWalletBalance(mockRuntime); expect(balance).toBe(0); expect(mockConnection.getBalance).toHaveBeenCalled(); + expect(mockRuntime.error).toHaveBeenCalledWith('Failed to get wallet balance:', expect.any(Error));
packages/plugin-rabbi-trader/__tests__/dexscreener.test.ts (2)
95-95
: Extract magic numbers into named constants.The volume and price change thresholds (10k, 5%) are hardcoded in multiple places. Extract these into named constants at the top of the test file.
const VOLUME_THRESHOLD = 10_000; const PRICE_CHANGE_THRESHOLD = 5.0;Also applies to: 123-123, 134-134
73-103
: Reduce duplication by reusing mock data.The mock pair data is duplicated between the Puppeteer mock and the test cases. Consider extracting it into a shared fixture.
const createMockPair = (overrides = {}) => ({ chainId: 'solana', dexId: 'raydium', // ... rest of the mock data ...overrides });packages/plugin-rabbi-trader/package.json (1)
24-27
: Add @types dependencies for better TypeScript support.Consider adding type definitions for dependencies that don't include their own types.
"devDependencies": { "vitest": "^1.2.1", - "@vitest/coverage-v8": "^1.2.1" + "@vitest/coverage-v8": "^1.2.1", + "@types/ws": "^8.0.0" },
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
packages/plugin-rabbi-trader/__tests__/dexscreener.test.ts
(1 hunks)packages/plugin-rabbi-trader/__tests__/tokenUtils.test.ts
(1 hunks)packages/plugin-rabbi-trader/__tests__/wallet.test.ts
(1 hunks)packages/plugin-rabbi-trader/package.json
(1 hunks)packages/plugin-rabbi-trader/vitest.config.ts
(1 hunks)
✅ Files skipped from review due to trivial changes (1)
- packages/plugin-rabbi-trader/vitest.config.ts
* upstream/develop: plugin-tts: enhance TTS generation flow and caching (elizaOS#2506) chore: add eliza technical report/paper (elizaOS#2517) feat: plugin rabbi trader tests (elizaOS#2520) Replace user ID with room ID in MemoryManager and other improvements (elizaOS#2492) test: plugin-tee - adjusting project structure and new tests (elizaOS#2508) fix: use header key from api config (elizaOS#2518) docs: add docs/README_JA.md (elizaOS#2515) AgentKit - Default Agent Config (elizaOS#2505) feat(plugin-openai): add OpenAI integration for text generation (elizaOS#2463) feat: add support for NVIDIA inference for ElizaOS (elizaOS#2512) test: api timeout handling for plugin-binance (elizaOS#2504) Replace type assertions Replace type assertions destroy file system after sending media support multimedia
Relates to
#2519
Risks
Low: adding test config and tests
Background
What does this PR do?
#2519
What kind of change is this?
Features/tests
#2519
Documentation changes needed?
None
Testing
Where should a reviewer start?
Detailed testing steps
Summary by CodeRabbit
New Features
Chores
package.json
with new testing scripts and dependenciesTests