Sequencer is working (minimal parsing)

This commit is contained in:
Krypto Kajun
2025-09-14 06:21:10 -05:00
parent 7dd5b5b692
commit 518758790a
59 changed files with 10539 additions and 471 deletions

View File

@@ -0,0 +1,32 @@
package mocks
import (
"testing"
"github.com/ethereum/go-ethereum/common"
"github.com/stretchr/testify/assert"
)
// TestMockDEXInteraction tests mock DEX interaction creation
func TestMockDEXInteraction(t *testing.T) {
dexInteraction := CreateMockDEXInteraction()
assert.Equal(t, "UniswapV3", dexInteraction.Protocol)
assert.Equal(t, common.HexToAddress("0x88e6A0c2dDD26FEEb64F039a2c41296FcB3f5640"), dexInteraction.Pool)
assert.Equal(t, common.HexToAddress("0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"), dexInteraction.TokenIn)
assert.Equal(t, common.HexToAddress("0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"), dexInteraction.TokenOut)
assert.NotNil(t, dexInteraction.AmountIn)
assert.NotNil(t, dexInteraction.AmountOut)
}
// TestMockTransaction tests mock transaction creation
func TestMockTransaction(t *testing.T) {
to := common.HexToAddress("0x88e6A0c2dDD26FEEb64F039a2c41296FcB3f5640")
data := []byte("test_data")
tx := CreateMockTransaction(to, data)
assert.Equal(t, to, *tx.To())
assert.Equal(t, data, tx.Data())
assert.Equal(t, uint64(1), tx.Nonce())
}

56
test/mocks/mock_types.go Normal file
View File

@@ -0,0 +1,56 @@
package mocks
import (
"math/big"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/fraktal/mev-beta/pkg/arbitrum"
)
// CreateMockL2Message creates a realistic L2 message for testing
func CreateMockL2Message() *arbitrum.L2Message {
// Create a mock transaction
to := common.HexToAddress("0x88e6A0c2dDD26FEEb64F039a2c41296FcB3f5640") // Uniswap V3 pool
tx := types.NewTransaction(
1, // nonce
to, // to
big.NewInt(0), // value
21000, // gas limit
big.NewInt(20000000000), // gas price (20 gwei)
[]byte{}, // data
)
return &arbitrum.L2Message{
Type: arbitrum.L2Transaction,
MessageNumber: big.NewInt(12345),
ParsedTx: tx,
InnerTxs: []*types.Transaction{tx},
}
}
// CreateMockDEXInteraction creates a realistic DEX interaction for testing
func CreateMockDEXInteraction() *arbitrum.DEXInteraction {
return &arbitrum.DEXInteraction{
Protocol: "UniswapV3",
Pool: common.HexToAddress("0x88e6A0c2dDD26FEEb64F039a2c41296FcB3f5640"),
TokenIn: common.HexToAddress("0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"), // USDC
TokenOut: common.HexToAddress("0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"), // WETH
AmountIn: big.NewInt(1000000000), // 1000 USDC
AmountOut: big.NewInt(500000000000000000), // 0.5 ETH
MessageNumber: big.NewInt(12345),
Timestamp: uint64(1234567890),
}
}
// CreateMockTransaction creates a realistic transaction for testing
func CreateMockTransaction(to common.Address, data []byte) *types.Transaction {
return types.NewTransaction(
1, // nonce
to, // to
big.NewInt(0), // value
21000, // gas limit
big.NewInt(20000000000), // gas price (20 gwei)
data, // data
)
}