Skip to content

Commit 3cc48d7

Browse files
author
tac0turtle
committed
run evm tests in another job
1 parent bb7454a commit 3cc48d7

4 files changed

Lines changed: 65 additions & 45 deletions

File tree

.github/workflows/test.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ jobs:
4545
with:
4646
token: ${{ secrets.CODECOV_TOKEN }}
4747
file: ./coverage.txt
48+
4849

4950
e2e-tests:
5051
name: Run E2E System Tests
@@ -57,3 +58,15 @@ jobs:
5758
go-version-file: ./go.mod
5859
- name: E2E Tests
5960
run: make test-e2e
61+
62+
evm-tests:
63+
name: Run EVM Execution Tests
64+
runs-on: ubuntu-latest
65+
steps:
66+
- uses: actions/checkout@v4
67+
- name: set up go
68+
uses: actions/setup-go@v5
69+
with:
70+
go-version-file: ./go.mod
71+
- name: EVM Tests
72+
run: make test-evm

execution/evm/execution_test.go

Lines changed: 40 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"os"
1111
"path/filepath"
1212
"strings"
13-
"sync"
1413
"testing"
1514
"time"
1615

@@ -67,8 +66,8 @@ func TestEngineExecution(t *testing.T) {
6766
genesisStateRoot := common.HexToHash(GENESIS_STATEROOT)
6867
rollkitGenesisStateRoot := genesisStateRoot[:]
6968

70-
t.Run("build phase", func(t *testing.T) {
71-
jwtSecret := setupTestRethEngine(t, "jwttoken")
69+
t.Run("Build chain", func(tt *testing.T) {
70+
jwtSecret := setupTestRethEngine(tt)
7271

7372
executionClient, err := NewEngineExecutionClient(
7473
TEST_ETH_URL,
@@ -87,7 +86,7 @@ func TestEngineExecution(t *testing.T) {
8786
require.NotZero(t, gasLimit)
8887

8988
prevStateRoot := rollkitGenesisStateRoot
90-
lastHeight, lastHash, lastTxs := checkLatestBlock(t, ctx)
89+
lastHeight, lastHash, lastTxs := checkLatestBlock(tt, ctx)
9190

9291
for blockHeight := initialHeight; blockHeight <= 10; blockHeight++ {
9392
nTxs := int(blockHeight) + 10
@@ -105,47 +104,48 @@ func TestEngineExecution(t *testing.T) {
105104
time.Sleep(1000 * time.Millisecond)
106105

107106
payload, err := executionClient.GetTxs(ctx)
108-
require.NoError(t, err)
109-
require.Lenf(t, payload, nTxs, "expected %d transactions, got %d", nTxs, len(payload))
107+
require.NoError(tt, err)
108+
require.Lenf(tt, payload, nTxs, "expected %d transactions, got %d", nTxs, len(payload))
110109

111110
allPayloads = append(allPayloads, payload)
112111

113112
// Check latest block before execution
114-
beforeHeight, beforeHash, beforeTxs := checkLatestBlock(t, ctx)
115-
require.Equal(t, lastHeight, beforeHeight, "Latest block height should match")
116-
require.Equal(t, lastHash.Hex(), beforeHash.Hex(), "Latest block hash should match")
117-
require.Equal(t, lastTxs, beforeTxs, "Number of transactions should match")
113+
beforeHeight, beforeHash, beforeTxs := checkLatestBlock(tt, ctx)
114+
require.Equal(tt, lastHeight, beforeHeight, "Latest block height should match")
115+
require.Equal(tt, lastHash.Hex(), beforeHash.Hex(), "Latest block hash should match")
116+
require.Equal(tt, lastTxs, beforeTxs, "Number of transactions should match")
118117

119118
newStateRoot, maxBytes, err := executionClient.ExecuteTxs(ctx, payload, blockHeight, time.Now(), prevStateRoot)
120-
require.NoError(t, err)
119+
require.NoError(tt, err)
121120
if nTxs > 0 {
122-
require.NotZero(t, maxBytes)
121+
require.NotZero(tt, maxBytes)
123122
}
124123

125124
err = executionClient.SetFinal(ctx, blockHeight)
126-
require.NoError(t, err)
125+
require.NoError(tt, err)
127126

128127
// Check latest block after execution
129-
lastHeight, lastHash, lastTxs = checkLatestBlock(t, ctx)
130-
require.Equal(t, blockHeight, lastHeight, "Latest block height should match")
131-
require.NotEmpty(t, lastHash.Hex(), "Latest block hash should not be empty")
132-
require.GreaterOrEqual(t, lastTxs, 0, "Number of transactions should be non-negative")
128+
lastHeight, lastHash, lastTxs = checkLatestBlock(tt, ctx)
129+
require.Equal(tt, blockHeight, lastHeight, "Latest block height should match")
130+
require.NotEmpty(tt, lastHash.Hex(), "Latest block hash should not be empty")
131+
require.GreaterOrEqual(tt, lastTxs, 0, "Number of transactions should be non-negative")
133132

134133
if nTxs == 0 {
135-
require.Equal(t, prevStateRoot, newStateRoot)
134+
require.Equal(tt, prevStateRoot, newStateRoot)
136135
} else {
137-
require.NotEqual(t, prevStateRoot, newStateRoot)
136+
require.NotEqual(tt, prevStateRoot, newStateRoot)
138137
}
139138
prevStateRoot = newStateRoot
140139
}
141140
})
141+
142142
if t.Failed() {
143143
return
144144
}
145145

146146
// start new container and try to sync
147-
t.Run("sync phase", func(t *testing.T) {
148-
jwtSecret := setupTestRethEngine(t, "jwttoken2")
147+
t.Run("Sync chain", func(tt *testing.T) {
148+
jwtSecret := setupTestRethEngine(t)
149149

150150
executionClient, err := NewEngineExecutionClient(
151151
TEST_ETH_URL,
@@ -164,34 +164,36 @@ func TestEngineExecution(t *testing.T) {
164164
require.NotZero(t, gasLimit)
165165

166166
prevStateRoot := rollkitGenesisStateRoot
167-
lastHeight, lastHash, lastTxs := checkLatestBlock(t, ctx)
167+
lastHeight, lastHash, lastTxs := checkLatestBlock(tt, ctx)
168168

169169
for blockHeight := initialHeight; blockHeight <= 10; blockHeight++ {
170170
payload := allPayloads[blockHeight-1]
171171

172172
// Check latest block before execution
173-
beforeHeight, beforeHash, beforeTxs := checkLatestBlock(t, ctx)
174-
require.Equal(t, lastHeight, beforeHeight, "Latest block height should match")
175-
require.Equal(t, lastHash.Hex(), beforeHash.Hex(), "Latest block hash should match")
176-
require.Equal(t, lastTxs, beforeTxs, "Number of transactions should match")
173+
beforeHeight, beforeHash, beforeTxs := checkLatestBlock(tt, ctx)
174+
require.Equal(tt, lastHeight, beforeHeight, "Latest block height should match")
175+
require.Equal(tt, lastHash.Hex(), beforeHash.Hex(), "Latest block hash should match")
176+
require.Equal(tt, lastTxs, beforeTxs, "Number of transactions should match")
177177

178178
newStateRoot, maxBytes, err := executionClient.ExecuteTxs(ctx, payload, blockHeight, time.Now(), prevStateRoot)
179179
require.NoError(t, err)
180180
if len(payload) > 0 {
181-
require.NotZero(t, maxBytes)
182-
require.NotEqual(t, prevStateRoot, newStateRoot)
181+
require.NotZero(tt, maxBytes)
182+
}
183+
if len(payload) == 0 {
184+
require.Equal(tt, prevStateRoot, newStateRoot)
183185
} else {
184-
require.Equal(t, prevStateRoot, newStateRoot)
186+
require.NotEqual(tt, prevStateRoot, newStateRoot)
185187
}
186188

187189
err = executionClient.SetFinal(ctx, blockHeight)
188-
require.NoError(t, err)
190+
require.NoError(tt, err)
189191

190192
// Check latest block after execution
191-
lastHeight, lastHash, lastTxs = checkLatestBlock(t, ctx)
192-
require.Equal(t, blockHeight, lastHeight, "Latest block height should match")
193-
require.NotEmpty(t, lastHash.Hex(), "Latest block hash should not be empty")
194-
require.GreaterOrEqual(t, lastTxs, 0, "Number of transactions should be non-negative")
193+
lastHeight, lastHash, lastTxs = checkLatestBlock(tt, ctx)
194+
require.Equal(tt, blockHeight, lastHeight, "Latest block height should match")
195+
require.NotEmpty(tt, lastHash.Hex(), "Latest block hash should not be empty")
196+
require.GreaterOrEqual(tt, lastTxs, 0, "Number of transactions should be non-negative")
195197

196198
prevStateRoot = newStateRoot
197199
fmt.Println("all good blockheight", blockHeight)
@@ -253,23 +255,16 @@ func generateJWTSecret() (string, error) {
253255
return hex.EncodeToString(jwtSecret), nil
254256
}
255257

256-
// Global mutex to serialize Docker Compose operations
257-
var dockerMutex sync.Mutex
258-
259258
// setupTestRethEngine starts a reth container using docker-compose and returns the JWT secret
260-
func setupTestRethEngine(t *testing.T, jp string) string {
259+
func setupTestRethEngine(t *testing.T) string {
261260
t.Helper()
262261

263-
// Serialize Docker Compose operations
264-
dockerMutex.Lock()
265-
defer dockerMutex.Unlock()
266-
267262
// Get absolute path to docker directory
268263
dockerPath, err := filepath.Abs(DOCKER_PATH)
269264
require.NoError(t, err)
270265

271266
// Create JWT directory if it doesn't exist
272-
jwtPath := filepath.Join(dockerPath, jp)
267+
jwtPath := filepath.Join(dockerPath, "jwttoken")
273268
err = os.MkdirAll(jwtPath, 0750) // More permissive directory permissions
274269
require.NoError(t, err)
275270

@@ -397,9 +392,9 @@ func TestSubmitTransaction(t *testing.T) {
397392
lastNonce, err = rpcClient.NonceAt(ctx, address, new(big.Int).SetUint64(height))
398393
require.NoError(t, err)
399394

400-
for s := 0; s < 15; s++ {
395+
for s := 0; s < 30; s++ {
401396
startTime := time.Now()
402-
for i := 0; i < 50; i++ {
397+
for i := 0; i < 5000; i++ {
403398
tx := getRandomTransaction(t, 22000)
404399
submitTransaction(t, tx)
405400
}

scripts/test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@ func main() {
2424
modDir := filepath.Dir(path)
2525
fmt.Printf("--> Found go.mod in: %s\n", modDir)
2626

27+
// Skip the execution/evm directory
28+
if modDir == filepath.Join("execution", "evm") {
29+
fmt.Printf("--> Skipping tests in: %s\n", modDir)
30+
fmt.Println(strings.Repeat("-", 40)) // Separator
31+
return nil // Continue walking
32+
}
33+
2734
// Skip the root go.mod if it exists and we only want submodules,
2835
// or adjust logic if root tests are also desired.
2936
// For this example, we'll run tests in all directories with go.mod.

scripts/test.mk

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,8 @@ test-cover:
2828
@echo "--> Running unit tests"
2929
@go run -tags=cover scripts/test_cover.go
3030
.PHONY: test-cover
31+
32+
## test-evm: Running EVM tests
33+
test-evm:
34+
@echo "--> Running EVM tests"
35+
@cd execution/evm && go test -mod=readonly -failfast -timeout=15m ./...

0 commit comments

Comments
 (0)