Skip to content

Commit

Permalink
op-challenger: fail immediately if VmBin and Server don't exist (#…
Browse files Browse the repository at this point in the history
…13588)

* ensure VmBin and Server exist

* only check when not in test

* test file exists

* reuse TempDir()

* add tests for new errors

* address comments
  • Loading branch information
zhiqiangxu authored Jan 13, 2025
1 parent 38aa19f commit 4f43bd9
Show file tree
Hide file tree
Showing 2 changed files with 187 additions and 78 deletions.
25 changes: 25 additions & 0 deletions op-challenger/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"errors"
"fmt"
"net/url"
"os"
"runtime"
"slices"
"strconv"
Expand Down Expand Up @@ -216,6 +217,14 @@ func (c Config) Check() error {
if c.Cannon.Server == "" {
return ErrMissingCannonServer
}

if _, err := os.Stat(c.Cannon.VmBin); err != nil {
return fmt.Errorf("%w: %w", ErrMissingCannonBin, err)
}
if _, err := os.Stat(c.Cannon.Server); err != nil {
return fmt.Errorf("%w: %w", ErrMissingCannonServer, err)
}

if c.Cannon.Network == "" {
if c.Cannon.RollupConfigPath == "" {
return ErrMissingCannonRollupConfig
Expand Down Expand Up @@ -254,6 +263,14 @@ func (c Config) Check() error {
if c.Asterisc.Server == "" {
return ErrMissingAsteriscServer
}

if _, err := os.Stat(c.Asterisc.VmBin); err != nil {
return fmt.Errorf("%w: %w", ErrMissingAsteriscBin, err)
}
if _, err := os.Stat(c.Asterisc.Server); err != nil {
return fmt.Errorf("%w: %w", ErrMissingAsteriscServer, err)
}

if c.Asterisc.Network == "" {
if c.Asterisc.RollupConfigPath == "" {
return ErrMissingAsteriscRollupConfig
Expand Down Expand Up @@ -289,6 +306,14 @@ func (c Config) Check() error {
if c.AsteriscKona.Server == "" {
return ErrMissingAsteriscKonaServer
}

if _, err := os.Stat(c.AsteriscKona.VmBin); err != nil {
return fmt.Errorf("%w: %w", ErrMissingAsteriscKonaBin, err)
}
if _, err := os.Stat(c.AsteriscKona.Server); err != nil {
return fmt.Errorf("%w: %w", ErrMissingAsteriscKonaServer, err)
}

if c.AsteriscKona.Network == "" {
if c.AsteriscKona.RollupConfigPath == "" {
return ErrMissingAsteriscKonaRollupConfig
Expand Down
Loading

0 comments on commit 4f43bd9

Please sign in to comment.