Files
pumpfun-bonkfun-bot/.cursor/rules/tests.mdc
T

154 lines
4.1 KiB
Plaintext
Raw Normal View History

2025-07-15 14:33:17 +00:00
---
2025-07-18 11:37:11 +00:00
description: Performance testing and listener comparison scripts for token detection systems. Apply when benchmarking listener performance or validating detection accuracy.
2025-07-15 14:33:17 +00:00
globs: tests/*.py
alwaysApply: true
---
2025-07-18 11:37:11 +00:00
# Listener Performance Testing Guide
2025-07-14 20:07:50 +00:00
2025-07-15 14:33:17 +00:00
## Overview
2025-07-18 11:37:11 +00:00
The test scripts provide performance comparison and validation tools for different listener implementations. These are standalone scripts designed to measure which listener is fastest at discovering new tokens, helping optimize the bot's detection capabilities.
2025-07-15 14:33:17 +00:00
2025-07-18 11:37:11 +00:00
## Individual Listener Tests
2025-07-15 14:33:17 +00:00
2025-07-18 11:37:11 +00:00
Each listener has a dedicated test script for standalone performance analysis:
2025-07-15 14:33:17 +00:00
2025-07-18 11:37:11 +00:00
### Geyser Listener Test
2025-07-15 14:33:17 +00:00
2025-07-18 11:37:11 +00:00
@tests/test_geyser_listener.py tests the fastest detection method:
- Direct gRPC connection to Geyser endpoint
- Real-time token creation monitoring
- Performance measurement and token logging
2025-07-15 14:33:17 +00:00
```bash
2025-07-18 11:37:11 +00:00
# Run Geyser listener test for 30 seconds
2025-07-18 12:03:00 +00:00
uv run tests/test_geyser_listener.py
2025-07-15 14:33:17 +00:00
```
2025-07-18 11:37:11 +00:00
### Logs Listener Test
2025-07-15 14:33:17 +00:00
2025-07-18 11:37:11 +00:00
@tests/test_logs_listener.py validates log-based monitoring:
- WebSocket subscription to program logs
- Pattern matching for token creation events
- Detection accuracy verification
2025-07-15 14:33:17 +00:00
```bash
2025-07-18 11:37:11 +00:00
# Run logs listener test
2025-07-18 12:03:00 +00:00
uv run tests/test_logs_listener.py
2025-07-15 14:33:17 +00:00
```
2025-07-18 11:37:11 +00:00
### Block Listener Test
@tests/test_block_listener.py tests block-based scanning:
- Full block processing for token discovery
- Transaction analysis and extraction
- Comprehensive but potentially slower detection
2025-07-15 14:33:17 +00:00
```bash
2025-07-18 11:37:11 +00:00
# Run block listener test
2025-07-18 12:03:00 +00:00
uv run tests/test_block_listener.py
2025-07-15 14:33:17 +00:00
```
2025-07-18 11:37:11 +00:00
## Comparative Performance Analysis
### Listener Comparison Tool
@tests/compare_listeners.py runs all listeners simultaneously:
- Side-by-side performance measurement
- Detection speed comparison with timing data
- Accuracy analysis (tokens detected by each method)
- Statistical reporting on detection overlap
```bash
# Compare all listeners for 60 seconds
2025-07-18 12:03:00 +00:00
uv run tests/compare_listeners.py 60
2025-07-18 11:37:11 +00:00
# Default 60-second comparison
2025-07-18 12:03:00 +00:00
uv run tests/compare_listeners.py
2025-07-18 11:37:11 +00:00
```
### Performance Metrics
The comparison tool provides:
| Metric | Description |
|--------|-------------|
| Detection Speed | Time to detect each token (microsecond precision) |
| Detection Count | Total tokens found by each listener |
| Overlap Analysis | Tokens detected by multiple listeners |
| Unique Detections | Tokens found only by specific listeners |
## Test Output Analysis
### Individual Test Results
Each listener test displays:
```
==================================================
NEW TOKEN: TokenName
Symbol: SYMBOL
Mint: TokenMintAddress
URI: MetadataURI
Creator: CreatorAddress
==================================================
```
### Comparison Results
The comparison tool generates:
```
Geyser detected: 15 tokens
Logs detected: 12 tokens
Block detected: 18 tokens
Token | Geyser | Logs | Block | Fastest
------|--------|------|-------|--------
ABC123... | 1.234567 | N/A | 2.345678 | Geyser
DEF456... | 0.987654 | 1.123456 | 1.567890 | Geyser
```
## Environment Configuration
Tests require these environment variables:
```bash
export SOLANA_NODE_RPC_ENDPOINT="https://api.mainnet-beta.solana.com"
export SOLANA_NODE_WSS_ENDPOINT="wss://api.mainnet-beta.solana.com"
export GEYSER_ENDPOINT="wss://your-geyser-endpoint"
export GEYSER_API_TOKEN="your-api-token"
```
## Common Usage Patterns
### Quick Performance Check
```bash
# 30-second comparison of all listeners
2025-07-18 12:03:00 +00:00
uv run tests/compare_listeners.py 30
2025-07-18 11:37:11 +00:00
```
### Extended Performance Analysis
```bash
# 10-minute deep analysis
2025-07-18 12:03:00 +00:00
uv run tests/compare_listeners.py 600
2025-07-18 11:37:11 +00:00
```
### Individual Listener Validation
```bash
# Test specific listener implementation
2025-07-18 12:03:00 +00:00
uv run tests/test_geyser_listener.py
2025-07-18 11:37:11 +00:00
```
## Use Cases
1. **Performance Optimization**: Determine fastest listener for production
2. **Reliability Testing**: Verify consistent token detection
3. **Configuration Tuning**: Optimize listener parameters
4. **Debugging**: Isolate listener-specific issues
2025-07-15 14:33:17 +00:00
## Related Files
2025-07-18 11:37:11 +00:00
- @tests/test_geyser_listener.py: Geyser performance testing
2025-07-15 14:33:17 +00:00
- @tests/test_logs_listener.py: Logs listener validation
2025-07-18 11:37:11 +00:00
- @tests/test_block_listener.py: Block listener analysis
- @tests/compare_listeners.py: Multi-listener performance comparison