-
Notifications
You must be signed in to change notification settings - Fork 726
Expand file tree
/
Copy patheth_sync_test.go
More file actions
82 lines (69 loc) · 2.09 KB
/
Copy patheth_sync_test.go
File metadata and controls
82 lines (69 loc) · 2.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
// Copyright 2024-2026, Offchain Labs, Inc.
// For license information, see https://github.com/OffchainLabs/nitro/blob/master/LICENSE.md
package arbtest
import (
"context"
"math/big"
"testing"
"time"
"github.com/offchainlabs/nitro/arbutil"
)
func TestEthSyncing(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
builder := NewNodeBuilder(ctx).DefaultConfig(t, true)
builder.L2Info = nil
cleanup := builder.Build(t)
defer cleanup()
builder.execConfig.SyncMonitor.MsgLag = builder.nodeConfig.SyncMonitor.MsgLag
testClientB, cleanupB := builder.Build2ndNode(t, &SecondNodeParams{})
defer cleanupB()
// stop txstreamer so it won't feed execution messages
testClientB.ConsensusNode.TxStreamer.StopAndWait()
countBefore, err := testClientB.ConsensusNode.TxStreamer.GetMessageCount()
Require(t, err)
builder.L2Info.GenerateAccount("User2")
numTxs := uint64(5)
for range numTxs {
builder.L2.TransferBalance(t, "Owner", "User2", big.NewInt(1e12), builder.L2Info)
}
// Give the inbox reader of testClientB a bit of time to pick up batches from L1 and add it to the consensus db
time.Sleep(time.Millisecond * 500)
// Advance parent chain enough to get the batches in
AdvanceL1(t, ctx, builder.L1.Client, builder.L1Info, 30)
attempt := 0
for {
if attempt > 30 {
Fatal(t, "2nd node didn't get all txs on time")
}
Require(t, ctx.Err())
countAfter, err := testClientB.ConsensusNode.TxStreamer.GetMessageCount()
Require(t, err)
if countAfter >= countBefore+arbutil.MessageIndex(numTxs) {
break
}
select {
case <-time.After(time.Millisecond * 100):
case <-ctx.Done():
}
attempt++
}
progress, err := testClientB.Client.SyncProgress(ctx)
Require(t, err)
if progress == nil {
Fatal(t, "eth_syncing returned nil but shouldn't have")
}
for testClientB.ConsensusNode.TxStreamer.ExecuteNextMsg(ctx) {
}
for range 10 {
progress, err = testClientB.Client.SyncProgress(ctx)
Require(t, err)
if progress == nil {
break
}
time.Sleep(time.Second)
}
if progress != nil {
Fatal(t, "eth_syncing did not return nil but should have")
}
}