- Added comprehensive bounds checking to prevent buffer overruns in multicall parsing - Implemented graduated validation system (Strict/Moderate/Permissive) to reduce false positives - Added LRU caching system for address validation with 10-minute TTL - Enhanced ABI decoder with missing Universal Router and Arbitrum-specific DEX signatures - Fixed duplicate function declarations and import conflicts across multiple files - Added error recovery mechanisms with multiple fallback strategies - Updated tests to handle new validation behavior for suspicious addresses - Fixed parser test expectations for improved validation system - Applied gofmt formatting fixes to ensure code style compliance - Fixed mutex copying issues in monitoring package by introducing MetricsSnapshot - Resolved critical security vulnerabilities in heuristic address extraction - Progress: Updated TODO audit from 10% to 35% complete 🤖 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))
|
|
})
|
|
}
|