forked from ethereum-optimism/optimism
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathservice_test.go
More file actions
75 lines (66 loc) · 2.04 KB
/
service_test.go
File metadata and controls
75 lines (66 loc) · 2.04 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
package opnode
import (
"fmt"
"testing"
"github.com/ethereum-optimism/optimism/op-node/flags"
"github.com/ethereum/go-ethereum/log"
"github.com/stretchr/testify/require"
"github.com/urfave/cli/v2"
)
func syncConfigCliApp() *cli.App {
syncConfigFlags := append([]cli.Flag{
flags.L2UnsafeOnly,
flags.SequencerEnabledFlag,
flags.L2EngineSyncEnabled,
flags.SyncModeFlag,
flags.SyncModeReqRespFlag,
flags.L2FollowSource,
flags.L2EngineKind,
flags.SkipSyncStartCheck,
}, flags.P2PFlags("")..., // For p2p.sync.req-resp
)
return &cli.App{
Flags: syncConfigFlags,
Action: func(c *cli.Context) error {
_, err := NewSyncConfig(c, log.New())
return err
},
}
}
func run(args []string) error {
return syncConfigCliApp().Run(append([]string{"test"}, args...))
}
func TestNewSyncConfigDefault(t *testing.T) {
require.NoError(t, run(nil))
}
func TestNewSyncConfig_DerivationDisabled_NoRRSync(t *testing.T) {
err := run([]string{
fmt.Sprintf("--%s=true", flags.L2UnsafeOnly.Name),
// No follow source with no derivation allowed
fmt.Sprintf("--%s=false", flags.SyncModeReqRespFlag.Name),
})
require.NoError(t, err)
}
func TestNewSyncConfig_FollowSourceWithDerivationDisabled(t *testing.T) {
err := run([]string{
fmt.Sprintf("--%s=true", flags.L2UnsafeOnly.Name),
fmt.Sprintf("--%s=http://example", flags.L2FollowSource.Name),
fmt.Sprintf("--%s=false", flags.SyncModeReqRespFlag.Name),
})
require.NoError(t, err)
}
func TestNewSyncConfig_FollowSourceWithDerivationEnabled(t *testing.T) {
err := run([]string{
// unsafe-only defaults in false
fmt.Sprintf("--%s=http://example", flags.L2FollowSource.Name),
})
require.ErrorContains(t, err, "cannot follow external safe/finalized with derivation enabled")
}
func TestNewSyncConfig_VerifierUnsafeOnlyWithRRSyncEnabled(t *testing.T) {
err := run([]string{
// verifier mode is default
fmt.Sprintf("--%s=true", flags.L2UnsafeOnly.Name),
fmt.Sprintf("--%s=true", flags.SyncModeReqRespFlag.Name),
})
require.ErrorContains(t, err, "reaching the unsafe tip would rely solely on RR sync")
}