Files
mev-beta/orig/test/e2e/e2e_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

139 lines
3.9 KiB
Go

//go:build integration
// +build integration
package e2e
import (
"context"
"math/big"
"testing"
"time"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/stretchr/testify/assert"
"github.com/fraktal/mev-beta/internal/config"
"github.com/fraktal/mev-beta/internal/logger"
"github.com/fraktal/mev-beta/internal/ratelimit"
"github.com/fraktal/mev-beta/pkg/market"
"github.com/fraktal/mev-beta/pkg/monitor"
"github.com/fraktal/mev-beta/pkg/scanner"
)
func TestEndToEndPipeline(t *testing.T) {
// Skip this test in short mode
if testing.Short() {
t.Skip("skipping end-to-end test in short mode")
}
// Create test config
arbCfg := &config.ArbitrumConfig{
RPCEndpoint: "https://arb1.arbitrum.io/rpc",
ChainID: 42161,
RateLimit: config.RateLimitConfig{
RequestsPerSecond: 10,
MaxConcurrent: 5,
Burst: 20,
},
}
botCfg := &config.BotConfig{
Enabled: true,
PollingInterval: 1,
MinProfitThreshold: 10.0,
GasPriceMultiplier: 1.2,
MaxWorkers: 2, // Use fewer workers for testing
ChannelBufferSize: 5,
RPCTimeout: 30,
}
uniswapCfg := &config.UniswapConfig{
FactoryAddress: "0x1F98431c8aD98523631AE4a59f267346ea31F984",
PositionManagerAddress: "0xC36442b4a4522E871399CD717aBDD847Ab11FE88",
FeeTiers: []int64{500, 3000, 10000},
Cache: config.CacheConfig{
Enabled: true,
Expiration: 300,
MaxSize: 10000,
},
}
// Create test logger
log := logger.New("info", "text", "")
// Create rate limiter manager
rateLimiter := ratelimit.NewLimiterManager(arbCfg)
// Create market manager
marketMgr := market.NewMarketManager(uniswapCfg, log)
// Create market scanner
scanner := scanner.NewMarketScanner(botCfg, log)
// Create monitor (this would normally connect to a real RPC endpoint)
// For testing, we'll just verify it can be created
monitor, err := monitor.NewArbitrumMonitor(
arbCfg,
botCfg,
log,
rateLimiter,
marketMgr,
scanner,
)
assert.NoError(t, err)
assert.NotNil(t, monitor)
// Test that we can process a block of transactions
// 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)
// Create pipeline
// Create pipeline with Ethereum client
var ethClient *ethclient.Client // nil for testing
pipeline := market.NewPipeline(botCfg, log, marketMgr, scanner, ethClient)
pipeline.AddDefaultStages()
// Process transactions through the pipeline
ctx := context.Background()
blockNumber := uint64(12345)
timestamp := uint64(time.Now().Unix())
err = pipeline.ProcessTransactions(ctx, transactions, blockNumber, timestamp)
assert.NoError(t, err)
}
func TestConfigurationLoading(t *testing.T) {
// This test would normally load a real config file
// For now, we'll just test that the config package works
cfg := &config.Config{
Arbitrum: config.ArbitrumConfig{
RPCEndpoint: "https://arb1.arbitrum.io/rpc",
ChainID: 42161,
},
Bot: config.BotConfig{
Enabled: true,
},
Uniswap: config.UniswapConfig{
FactoryAddress: "0x1F98431c8aD98523631AE4a59f267346ea31F984",
},
Log: config.LogConfig{
Level: "info",
},
Database: config.DatabaseConfig{
File: "mev-bot.db",
},
}
// Verify the config was created correctly
assert.Equal(t, "https://arb1.arbitrum.io/rpc", cfg.Arbitrum.RPCEndpoint)
assert.Equal(t, int64(42161), cfg.Arbitrum.ChainID)
assert.True(t, cfg.Bot.Enabled)
assert.Equal(t, "0x1F98431c8aD98523631AE4a59f267346ea31F984", cfg.Uniswap.FactoryAddress)
assert.Equal(t, "info", cfg.Log.Level)
assert.Equal(t, "mev-bot.db", cfg.Database.File)
}