Restructured project for V2 refactor: **Structure Changes:** - Moved all V1 code to orig/ folder (preserved with git mv) - Created docs/planning/ directory - Added orig/README_V1.md explaining V1 preservation **Planning Documents:** - 00_V2_MASTER_PLAN.md: Complete architecture overview - Executive summary of critical V1 issues - High-level component architecture diagrams - 5-phase implementation roadmap - Success metrics and risk mitigation - 07_TASK_BREAKDOWN.md: Atomic task breakdown - 99+ hours of detailed tasks - Every task < 2 hours (atomic) - Clear dependencies and success criteria - Organized by implementation phase **V2 Key Improvements:** - Per-exchange parsers (factory pattern) - Multi-layer strict validation - Multi-index pool cache - Background validation pipeline - Comprehensive observability **Critical Issues Addressed:** - Zero address tokens (strict validation + cache enrichment) - Parsing accuracy (protocol-specific parsers) - No audit trail (background validation channel) - Inefficient lookups (multi-index cache) - Stats disconnection (event-driven metrics) Next Steps: 1. Review planning documents 2. Begin Phase 1: Foundation (P1-001 through P1-010) 3. Implement parsers in Phase 2 4. Build cache system in Phase 3 5. Add validation pipeline in Phase 4 6. Migrate and test in Phase 5 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
46 lines
1.4 KiB
Go
46 lines
1.4 KiB
Go
package market
|
|
|
|
import (
|
|
"errors"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"github.com/fraktal/mev-beta/internal/config"
|
|
"github.com/fraktal/mev-beta/internal/logger"
|
|
)
|
|
|
|
func TestNormalizeAndValidatePoolAddress(t *testing.T) {
|
|
cfg := &config.BotConfig{
|
|
MaxWorkers: 1,
|
|
RPCTimeout: 1,
|
|
}
|
|
log := logger.New("info", "text", "")
|
|
scanner := NewMarketScanner(cfg, log, nil, nil)
|
|
|
|
t.Run("accepts known pool", func(t *testing.T) {
|
|
address := "0xC6962004f452bE9203591991D15f6b388e09E8D0" // known Uniswap V3 pool
|
|
normalized, result, err := scanner.normalizeAndValidatePoolAddress(address)
|
|
require.NoError(t, err)
|
|
require.NotNil(t, result)
|
|
require.Equal(t, "0xc6962004f452be9203591991d15f6b388e09e8d0", normalized)
|
|
require.True(t, result.IsValid)
|
|
})
|
|
|
|
t.Run("rejects known token misclassified as pool", func(t *testing.T) {
|
|
address := "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1" // WETH
|
|
_, result, err := scanner.normalizeAndValidatePoolAddress(address)
|
|
require.Error(t, err)
|
|
require.NotNil(t, result)
|
|
require.True(t, errors.Is(err, ErrInvalidPoolCandidate))
|
|
})
|
|
|
|
t.Run("rejects corrupted address", func(t *testing.T) {
|
|
address := "0x0000000000000000000000000000000000000000"
|
|
_, result, err := scanner.normalizeAndValidatePoolAddress(address)
|
|
require.Error(t, err)
|
|
require.NotNil(t, result)
|
|
require.True(t, errors.Is(err, ErrInvalidPoolCandidate))
|
|
})
|
|
}
|