The testDetector.rs provides historical testing capabilities while keeping the exact same core logic as detector.rs.
✅ ALL CORE DETECTION LOGIC IS UNCHANGED:
extract_token_and_caller()- Identical regex and confidence logicverify_caller()- Same caching and verification processprocess_event()- Same confidence handling and callback execution- Same constants, patterns, and cache management
# Test a specific block number
cargo run --bin testDetector 12345678# Test a range of blocks
cargo run --bin testDetector 12345678 12345680-
Test Recent Block:
# Replace with actual block number cargo run --bin testDetector 21850000 -
Test Block Range (max ~1000 blocks recommended):
# Test last 10 blocks of activity cargo run --bin testDetector 21850000 21850010 -
Live Mode (original detector):
# Live monitoring (default) cargo run # Or explicitly cargo run --bin detector
🧪 Testing block 12345678 for token deployments...
📊 Found 3 logs in block 12345678
🔍 Found token: 0xabc123... (confidence: Verify)
✅ VERIFIED token detected: 0xabc123...
🎯 Detected 1 matching tokens in block 12345678
🎯 DETECTED TOKENS:
0xabc123...
🧪 Testing block 12345678 for token deployments...
📊 Found 0 logs in block 12345678
🔍 No matching tokens found in block 12345678
- Historical Log Retrieval: Uses
eth_getLogswith block filters - Same Detection Logic: Processes logs through identical core functions
- Confidence Processing: Applies same WANTED/UNWANTED/VERIFY logic
- Transaction Verification: Uses same caching and verification when needed
- Output Summary: Lists all detected tokens that would trigger in live mode
The testing mode uses the exact same configuration as live mode:
- Same
TARGET_TOPIC,DEPLOYER,WANTED,UNWANTEDconstants - Same
USE_TX_VERIFICATIONsetting - Same WSS_URL environment variable requirement
- Block Range Limit: Keep ranges under 1000 blocks to avoid timeouts
- Network Calls: Each verification still requires individual transaction lookups
- Cache Benefits: Repeated calls benefit from caller verification caching
- Logging: Use
RUST_LOG=infofor detailed output,RUST_LOG=errorfor quiet mode
Since the core logic is 100% identical, tokens detected in testing mode will behave exactly the same in live monitoring mode. This allows you to:
- ✅ Validate detection accuracy against historical data
- ✅ Test configuration changes before going live
- ✅ Debug specific block ranges where issues occurred
- ✅ Verify that historical deployments would have been caught