Skip to content

Commit 5dc3bb7

Browse files
committed
WIP
1 parent 1b8e891 commit 5dc3bb7

File tree

2 files changed

+28
-9
lines changed

2 files changed

+28
-9
lines changed

.github/workflows/juno-test.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ jobs:
1818
fail-fast: false
1919
matrix:
2020
os: [ubuntu-latest, macos-latest, ubuntu-arm64-4-core]
21+
iteration: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
2122
runs-on: ${{ matrix.os }}
2223
env:
2324
VM_DEBUG: true

consensus/integtest/integ_test.go

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@ package integtest
22

33
import (
44
"fmt"
5+
goitre "iter"
56
"maps"
67
"slices"
78
gosync "sync"
89
"testing"
10+
"time"
911

1012
"github.com/NethermindEth/juno/blockchain"
1113
"github.com/NethermindEth/juno/consensus"
@@ -28,8 +30,8 @@ import (
2830

2931
const (
3032
commitBufferSize = 1024
31-
maxLag = 10
3233
hostAddress = "/ip4/0.0.0.0/tcp/0"
34+
maxCommitWait = 30 * time.Second
3335
)
3436

3537
var (
@@ -169,6 +171,21 @@ func writeBlock(
169171
}
170172
}
171173

174+
func commitStream(t *testing.T, commits chan commit) goitre.Seq[commit] {
175+
return func(yield func(commit) bool) {
176+
for {
177+
select {
178+
case commit := <-commits:
179+
if !yield(commit) {
180+
return
181+
}
182+
case <-time.After(maxCommitWait):
183+
require.FailNow(t, "timed out waiting for commit")
184+
}
185+
}
186+
}
187+
}
188+
172189
func assertCommits(t *testing.T, commits chan commit, cfg testConfig, logger *utils.ZapLogger) {
173190
t.Helper()
174191

@@ -182,22 +199,23 @@ func assertCommits(t *testing.T, commits chan commit, cfg testConfig, logger *ut
182199
commitCount := make(map[uint64]int)
183200

184201
nextHeight := uint64(1)
185-
for commit := range commits {
202+
for commit := range commitStream(t, commits) {
186203
blockNumber := commit.committedBlock.Block.Number
187204
blockHash := commit.committedBlock.Block.Hash
188-
// Ignore commits after the target height
189-
if blockNumber > cfg.targetHeight {
190-
continue
191-
}
192205

193206
require.Falsef(
194207
t,
195-
blockNumber > nextHeight+maxLag,
208+
blockNumber > nextHeight+cfg.targetHeight,
196209
"finished height %d is too far behind committed height %d",
197210
nextHeight,
198211
blockNumber,
199212
)
200213

214+
// Ignore commits after the target height
215+
if blockNumber > cfg.targetHeight {
216+
continue
217+
}
218+
201219
// Ignore faulty nodes
202220
if commit.nodeIndex >= honestNodeCount {
203221
continue
@@ -218,12 +236,12 @@ func assertCommits(t *testing.T, commits chan commit, cfg testConfig, logger *ut
218236
commitCount[blockNumber]++
219237

220238
// If all honest nodes committed at this height, increment the finished counter
221-
for commitCount[nextHeight] == honestNodeCount && nextHeight < cfg.targetHeight {
239+
for commitCount[nextHeight] == honestNodeCount && nextHeight <= cfg.targetHeight {
222240
logger.Infow("all honest nodes committed", "height", nextHeight)
223241
nextHeight++
224242
}
225243

226-
if nextHeight == cfg.targetHeight {
244+
if nextHeight > cfg.targetHeight {
227245
break
228246
}
229247
}

0 commit comments

Comments
 (0)