Skip to content

Commit

Permalink
chore(simple_client): Add explicit ServiceUnavailable error type - ad…
Browse files Browse the repository at this point in the history
…dress PR comment
  • Loading branch information
ethenotethan committed Dec 3, 2024
1 parent 68a6979 commit b3dd92b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
11 changes: 10 additions & 1 deletion server/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,20 @@ func (cfg *Config) Check() error {

// provide dummy values to eigenda client config. Since the client won't be called in this
// mode it doesn't matter.
if cfg.MemstoreEnabled || !cfg.VerifierConfig.VerifyCerts {
if cfg.MemstoreEnabled {
cfg.EdaClientConfig.SvcManagerAddr = "0x0000000000000000000000000000000000000000"
cfg.EdaClientConfig.EthRpcUrl = "http://0.0.0.0:666"
}

if !cfg.MemstoreEnabled {
if cfg.EdaClientConfig.SvcManagerAddr == "" {
return fmt.Errorf("service manager address is required for communication with EigenDA")
}
if cfg.EdaClientConfig.EthRpcUrl == "" {
return fmt.Errorf("eth prc url is required for communication with EigenDA")
}
}

// cert verification is enabled
// TODO: move this verification logic to verify/cli.go
if cfg.VerifierConfig.VerifyCerts {
Expand Down
15 changes: 6 additions & 9 deletions server/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,7 @@ func TestConfigVerification(t *testing.T) {
require.Error(t, err)
})

t.Run("EigenDAClientFieldsAreDefaultSetWhenCertVerifierDisabled", func(t *testing.T) {
// 1 - memstore
t.Run("EigenDAClientFieldsAreDefaultSetWhenMemStoreEnabled", func(t *testing.T) {
cfg := validCfg()
cfg.MemstoreEnabled = true
cfg.VerifierConfig.VerifyCerts = false
Expand All @@ -102,18 +101,16 @@ func TestConfigVerification(t *testing.T) {
require.NoError(t, err)
require.True(t, len(cfg.EdaClientConfig.EthRpcUrl) > 1)
require.True(t, len(cfg.EdaClientConfig.SvcManagerAddr) > 1)
})

// 2 - cert verification disabled
cfg = validCfg()
t.Run("FailWhenEigenDAClientFieldsAreUnsetAndMemStoreDisabled", func(t *testing.T) {
cfg := validCfg()
cfg.MemstoreEnabled = false
cfg.VerifierConfig.VerifyCerts = false
cfg.VerifierConfig.RPCURL = ""
cfg.VerifierConfig.SvcManagerAddr = ""

err = cfg.Check()
require.NoError(t, err)
require.True(t, len(cfg.EdaClientConfig.EthRpcUrl) > 1)
require.True(t, len(cfg.EdaClientConfig.SvcManagerAddr) > 1)
err := cfg.Check()
require.Error(t, err)
})
})

Expand Down

0 comments on commit b3dd92b

Please sign in to comment.