forked from ethereum-optimism/optimism
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cli_test.go
41 lines (35 loc) · 920 Bytes
/
cli_test.go
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
package txmgr
import (
"testing"
"github.com/stretchr/testify/require"
"github.com/urfave/cli/v2"
)
var (
l1EthRpcValue = "http://localhost:9546"
)
func TestDefaultCLIOptionsMatchDefaultConfig(t *testing.T) {
cfg := configForArgs()
defaultCfg := NewCLIConfig(l1EthRpcValue, DefaultBatcherFlagValues)
require.Equal(t, defaultCfg, cfg)
}
func TestDefaultConfigIsValid(t *testing.T) {
cfg := NewCLIConfig(l1EthRpcValue, DefaultBatcherFlagValues)
require.NoError(t, cfg.Check())
}
func configForArgs(args ...string) CLIConfig {
app := cli.NewApp()
// txmgr expects the --l1-eth-rpc option to be declared externally
flags := append(CLIFlags("TEST_"), &cli.StringFlag{
Name: L1RPCFlagName,
Value: l1EthRpcValue,
})
app.Flags = flags
app.Name = "test"
var config CLIConfig
app.Action = func(ctx *cli.Context) error {
config = ReadCLIConfig(ctx)
return nil
}
_ = app.Run(args)
return config
}