Commit 4f43bd96 authored by zhiqiangxu's avatar zhiqiangxu Committed by GitHub

op-challenger: fail immediately if `VmBin` and `Server` don't exist (#13588)

* ensure VmBin and Server exist

* only check when not in test

* test file exists

* reuse TempDir()

* add tests for new errors

* address comments
parent 38aa19f3
...@@ -4,6 +4,7 @@ import ( ...@@ -4,6 +4,7 @@ import (
"errors" "errors"
"fmt" "fmt"
"net/url" "net/url"
"os"
"runtime" "runtime"
"slices" "slices"
"strconv" "strconv"
...@@ -216,6 +217,14 @@ func (c Config) Check() error { ...@@ -216,6 +217,14 @@ func (c Config) Check() error {
if c.Cannon.Server == "" { if c.Cannon.Server == "" {
return ErrMissingCannonServer 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.Network == "" {
if c.Cannon.RollupConfigPath == "" { if c.Cannon.RollupConfigPath == "" {
return ErrMissingCannonRollupConfig return ErrMissingCannonRollupConfig
...@@ -254,6 +263,14 @@ func (c Config) Check() error { ...@@ -254,6 +263,14 @@ func (c Config) Check() error {
if c.Asterisc.Server == "" { if c.Asterisc.Server == "" {
return ErrMissingAsteriscServer 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.Network == "" {
if c.Asterisc.RollupConfigPath == "" { if c.Asterisc.RollupConfigPath == "" {
return ErrMissingAsteriscRollupConfig return ErrMissingAsteriscRollupConfig
...@@ -289,6 +306,14 @@ func (c Config) Check() error { ...@@ -289,6 +306,14 @@ func (c Config) Check() error {
if c.AsteriscKona.Server == "" { if c.AsteriscKona.Server == "" {
return ErrMissingAsteriscKonaServer 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.Network == "" {
if c.AsteriscKona.RollupConfigPath == "" { if c.AsteriscKona.RollupConfigPath == "" {
return ErrMissingAsteriscKonaRollupConfig return ErrMissingAsteriscKonaRollupConfig
......
This diff is collapsed.
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