Files
mev-beta/orig/test/integration/pipeline_test.go
Administrator c54c569f30 refactor: move all remaining files to orig/ directory
Completed clean root directory structure:
- Root now contains only: .git, .env, docs/, orig/
- Moved all remaining files and directories to orig/:
  - Config files (.claude, .dockerignore, .drone.yml, etc.)
  - All .env variants (except active .env)
  - Git config (.gitconfig, .github, .gitignore, etc.)
  - Tool configs (.golangci.yml, .revive.toml, etc.)
  - Documentation (*.md files, @prompts)
  - Build files (Dockerfiles, Makefile, go.mod, go.sum)
  - Docker compose files
  - All source directories (scripts, tests, tools, etc.)
  - Runtime directories (logs, monitoring, reports)
  - Dependency files (node_modules, lib, cache)
  - Special files (--delete)

- Removed empty runtime directories (bin/, data/)

V2 structure is now clean:
- docs/planning/ - V2 planning documents
- orig/ - Complete V1 codebase preserved
- .env - Active environment config (not in git)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-10 10:53:05 +01:00

146 lines
3.9 KiB
Go

//go:build integration && legacy && forked
// +build integration,legacy,forked
package integration_test
import (
"context"
"math/big"
"testing"
"time"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/stretchr/testify/assert"
"github.com/fraktal/mev-beta/internal/config"
"github.com/fraktal/mev-beta/internal/logger"
"github.com/fraktal/mev-beta/pkg/events"
"github.com/fraktal/mev-beta/pkg/market"
"github.com/fraktal/mev-beta/pkg/scanner"
)
func TestPipelineIntegration(t *testing.T) {
// Create test config
cfg := &config.BotConfig{
MaxWorkers: 2,
ChannelBufferSize: 5,
MinProfitThreshold: 10.0,
}
// Create test logger
logger := logger.New("info", "text", "")
// Create market manager
marketMgr := market.NewMarketManager(&config.UniswapConfig{
Cache: config.CacheConfig{
Expiration: 300,
MaxSize: 10000,
},
}, logger)
// Create market scanner
scanner := scanner.NewMarketScanner(cfg, logger)
// Create pipeline
pipeline := market.NewPipeline(cfg, logger, marketMgr, scanner, nil)
// Add default stages
pipeline.AddDefaultStages()
// Create test transactions
transactions := make([]*types.Transaction, 0)
// Create a transaction that interacts with a DEX
to := common.HexToAddress("0x88e6A0c2dDD26FEEb64F039a2c41296FcB3f5640") // Uniswap V3 pool
tx := types.NewTransaction(0, to, big.NewInt(0), 0, big.NewInt(0), nil)
transactions = append(transactions, tx)
// Process transactions through the pipeline
ctx := context.Background()
blockNumber := uint64(12345)
timestamp := uint64(time.Now().Unix())
err := pipeline.ProcessTransactions(ctx, transactions, blockNumber, timestamp)
// Verify no error
assert.NoError(t, err)
}
func TestMarketManagerAndScannerIntegration(t *testing.T) {
// Create test logger
logger := logger.New("info", "text", "")
// Create market manager
marketMgr := market.NewMarketManager(&config.UniswapConfig{
Cache: config.CacheConfig{
Expiration: 300,
MaxSize: 10000,
},
}, logger)
// Get a pool from the market manager
ctx := context.Background()
poolAddress := common.HexToAddress("0x88e6A0c2dDD26FEEb64F039a2c41296FcB3f5640")
pool, err := marketMgr.GetPool(ctx, poolAddress)
// Verify no error and pool is not nil
assert.NoError(t, err)
assert.NotNil(t, pool)
// Get pools by tokens
token0 := common.HexToAddress("0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48") // USDC
token1 := common.HexToAddress("0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2") // WETH
pools := marketMgr.GetPoolsByTokens(token0, token1)
// Verify pools are returned
assert.NotNil(t, pools)
}
func TestEventParserAndPipelineIntegration(t *testing.T) {
// Create test config
cfg := &config.BotConfig{
MaxWorkers: 2,
ChannelBufferSize: 5,
}
// Create test logger
logger := logger.New("info", "text", "")
// Create market manager
marketMgr := market.NewMarketManager(&config.UniswapConfig{
Cache: config.CacheConfig{
Expiration: 300,
MaxSize: 10000,
},
}, logger)
// Create market scanner
scnr := scanner.NewMarketScanner(cfg, logger)
// Create pipeline
pipe := market.NewPipeline(cfg, logger, marketMgr, scnr, nil)
pipe.AddDefaultStages()
// Create event parser
parser := events.NewEventParser()
// Create a transaction that interacts with a DEX
to := common.HexToAddress("0x88e6A0c2dDD26FEEb64F039a2c41296FcB3f5640") // Uniswap V3 pool
tx := types.NewTransaction(0, to, big.NewInt(0), 0, big.NewInt(0), nil)
blockNumber := uint64(12345)
timestamp := uint64(time.Now().Unix())
// Parse the transaction
parsedEvents, err := parser.ParseTransaction(tx, blockNumber, timestamp)
assert.NoError(t, err)
assert.Len(t, parsedEvents, 1)
// Verify the parsed event
event := parsedEvents[0]
assert.Equal(t, events.Swap, event.Type)
assert.Equal(t, "UniswapV3", event.Protocol)
assert.Equal(t, to, event.PoolAddress)
assert.Equal(t, blockNumber, event.BlockNumber)
assert.Equal(t, timestamp, event.Timestamp)
}