Commit ef7a44e2 authored by OptimismBot's avatar OptimismBot Committed by GitHub

Merge pull request #7363 from ethereum-optimism/fix-beta-flags

op-node: update flags, remove BETA_ prefix
parents 8393e837 fc381232
...@@ -246,12 +246,12 @@ var ( ...@@ -246,12 +246,12 @@ var (
RollupHalt = &cli.StringFlag{ RollupHalt = &cli.StringFlag{
Name: "rollup.halt", Name: "rollup.halt",
Usage: "Opt-in option to halt on incompatible protocol version requirements of the given level (major/minor/patch/none), as signaled onchain in L1", Usage: "Opt-in option to halt on incompatible protocol version requirements of the given level (major/minor/patch/none), as signaled onchain in L1",
EnvVars: prefixEnvVars("BETA_ROLLUP_HALT"), EnvVars: prefixEnvVars("ROLLUP_HALT"),
} }
RollupLoadProtocolVersions = &cli.BoolFlag{ RollupLoadProtocolVersions = &cli.BoolFlag{
Name: "rollup.load-protocol-versions", Name: "rollup.load-protocol-versions",
Usage: "Load protocol versions from the superchain L1 ProtocolVersions contract (if available), and report in logs and metrics", Usage: "Load protocol versions from the superchain L1 ProtocolVersions contract (if available), and report in logs and metrics",
EnvVars: prefixEnvVars("BETA_ROLLUP_LOAD_PROTOCOL_VERSIONS"), EnvVars: prefixEnvVars("ROLLUP_LOAD_PROTOCOL_VERSIONS"),
} }
CanyonOverrideFlag = &cli.Uint64Flag{ CanyonOverrideFlag = &cli.Uint64Flag{
Name: "override.canyon", Name: "override.canyon",
......
package flags package flags
import ( import (
"strings"
"testing" "testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/urfave/cli/v2" "github.com/urfave/cli/v2"
) )
...@@ -29,3 +31,23 @@ func TestUniqueFlags(t *testing.T) { ...@@ -29,3 +31,23 @@ func TestUniqueFlags(t *testing.T) {
seenCLI[name] = struct{}{} seenCLI[name] = struct{}{}
} }
} }
// TestBetaFlags test that all flags starting with "beta." have "BETA_" in the env var, and vice versa.
func TestBetaFlags(t *testing.T) {
for _, flag := range Flags {
envFlag, ok := flag.(interface {
GetEnvVars() []string
})
if !ok || len(envFlag.GetEnvVars()) == 0 { // skip flags without env-var support
continue
}
name := flag.Names()[0]
envName := envFlag.GetEnvVars()[0]
if strings.HasPrefix(name, "beta.") {
assert.Contains(t, envName, "BETA_", "%q flag must contain BETA in env var to match \"beta.\" flag name", name)
}
if strings.Contains(envName, "BETA_") {
assert.True(t, strings.HasPrefix(name, "beta."), "%q flag must start with \"beta.\" in flag name to match \"BETA_\" env var", name)
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment