-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
35e3174
commit 256b4a4
Showing
22 changed files
with
582 additions
and
598 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,21 @@ | ||
package config | ||
|
||
import ( | ||
"testing" | ||
) | ||
func TestCorrectDefaultBaseConfig(t *testing.T) { | ||
baseConfig := BaseConfig{} | ||
|
||
baseConfig = baseConfig.Default() | ||
|
||
if baseConfig.RpcBindIp != "127.0.0.1" { | ||
t.Errorf("Expected RpcBindIP to be %s, but got %s", "127.0.0.1", baseConfig.RpcBindIp) | ||
} | ||
if baseConfig.RpcPort != 0 { | ||
t.Errorf("Expected RpcPort to be %v, but got %v", 0, baseConfig.RpcPort) | ||
} | ||
if baseConfig.ConsensusRpc != nil { | ||
t.Errorf("Expected ConsensusRpc to be %v, but got %v", nil, baseConfig.ConsensusRpc) | ||
} | ||
} | ||
package config | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestCorrectDefaultBaseConfig(t *testing.T) { | ||
baseConfig := BaseConfig{} | ||
|
||
baseConfig = baseConfig.Default() | ||
|
||
if baseConfig.RpcBindIp != "127.0.0.1" { | ||
t.Errorf("Expected RpcBindIP to be %s, but got %s", "127.0.0.1", baseConfig.RpcBindIp) | ||
} | ||
if baseConfig.RpcPort != 0 { | ||
t.Errorf("Expected RpcPort to be %v, but got %v", 0, baseConfig.RpcPort) | ||
} | ||
if baseConfig.ConsensusRpc != nil { | ||
t.Errorf("Expected ConsensusRpc to be %v, but got %v", nil, baseConfig.ConsensusRpc) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,52 @@ | ||
package config | ||
|
||
import ( | ||
"encoding/hex" | ||
"encoding/hex" | ||
) | ||
|
||
// The format of configuration to be stored in the configuratin file is map[string]interface{} | ||
type CliConfig struct { | ||
ExecutionRpc *string `mapstructure:"execution_rpc"` | ||
ConsensusRpc *string `mapstructure:"consensus_rpc"` | ||
Checkpoint *[]byte `mapstructure:"checkpoint"` | ||
RpcBindIp *string `mapstructure:"rpc_bind_ip"` | ||
RpcPort *uint16 `mapstructure:"rpc_port"` | ||
DataDir *string `mapstructure:"data_dir"` | ||
Fallback *string `mapstructure:"fallback"` | ||
LoadExternalFallback *bool `mapstructure:"load_external_fallback"` | ||
StrictCheckpointAge *bool `mapstructure:"strict_checkpoint_age"` | ||
ExecutionRpc *string `mapstructure:"execution_rpc"` | ||
ConsensusRpc *string `mapstructure:"consensus_rpc"` | ||
Checkpoint *[]byte `mapstructure:"checkpoint"` | ||
RpcBindIp *string `mapstructure:"rpc_bind_ip"` | ||
RpcPort *uint16 `mapstructure:"rpc_port"` | ||
DataDir *string `mapstructure:"data_dir"` | ||
Fallback *string `mapstructure:"fallback"` | ||
LoadExternalFallback *bool `mapstructure:"load_external_fallback"` | ||
StrictCheckpointAge *bool `mapstructure:"strict_checkpoint_age"` | ||
} | ||
|
||
func (cfg *CliConfig) as_provider() map[string]interface{} { | ||
// Create a map to hold the configuration data | ||
userDict := make(map[string]interface{}) | ||
// Populate the map with values from the CliConfig struct | ||
if cfg.ExecutionRpc != nil { | ||
userDict["execution_rpc"] = *cfg.ExecutionRpc | ||
} | ||
if cfg.ConsensusRpc != nil { | ||
userDict["consensus_rpc"] = *cfg.ConsensusRpc | ||
} | ||
if cfg.Checkpoint != nil { | ||
userDict["checkpoint"] = hex.EncodeToString(*cfg.Checkpoint) | ||
} | ||
if cfg.RpcBindIp != nil { | ||
userDict["rpc_bind_ip"] = *cfg.RpcBindIp | ||
} | ||
if cfg.RpcPort != nil { | ||
userDict["rpc_port"] = *cfg.RpcPort | ||
} | ||
if cfg.DataDir != nil { | ||
userDict["data_dir"] = *cfg.DataDir | ||
} | ||
if cfg.Fallback != nil { | ||
userDict["fallback"] = *cfg.Fallback | ||
} | ||
if cfg.LoadExternalFallback != nil { | ||
userDict["load_external_fallback"] = *cfg.LoadExternalFallback | ||
} | ||
if cfg.StrictCheckpointAge != nil { | ||
userDict["strict_checkpoint_age"] = *cfg.StrictCheckpointAge | ||
} | ||
return userDict | ||
// Create a map to hold the configuration data | ||
userDict := make(map[string]interface{}) | ||
// Populate the map with values from the CliConfig struct | ||
if cfg.ExecutionRpc != nil { | ||
userDict["execution_rpc"] = *cfg.ExecutionRpc | ||
} | ||
if cfg.ConsensusRpc != nil { | ||
userDict["consensus_rpc"] = *cfg.ConsensusRpc | ||
} | ||
if cfg.Checkpoint != nil { | ||
userDict["checkpoint"] = hex.EncodeToString(*cfg.Checkpoint) | ||
} | ||
if cfg.RpcBindIp != nil { | ||
userDict["rpc_bind_ip"] = *cfg.RpcBindIp | ||
} | ||
if cfg.RpcPort != nil { | ||
userDict["rpc_port"] = *cfg.RpcPort | ||
} | ||
if cfg.DataDir != nil { | ||
userDict["data_dir"] = *cfg.DataDir | ||
} | ||
if cfg.Fallback != nil { | ||
userDict["fallback"] = *cfg.Fallback | ||
} | ||
if cfg.LoadExternalFallback != nil { | ||
userDict["load_external_fallback"] = *cfg.LoadExternalFallback | ||
} | ||
if cfg.StrictCheckpointAge != nil { | ||
userDict["strict_checkpoint_age"] = *cfg.StrictCheckpointAge | ||
} | ||
return userDict | ||
} |
Oops, something went wrong.